darcs

Issue 2549 If adddir statement ends with trailing slash, patches to delete the directory cannot be pulled by repositories with patch-index enabled.

Title If adddir statement ends with trailing slash, patches to delete the directory cannot be pulled by repositories with patch-index enabled.
Priority bug Status resolved
Milestone Resolved in
Superseder Nosy List warren
Assigned To
Topics

Created on 2017-09-14.19:05:43 by warren, last changed 2020-08-01.13:42:17 by bf.

Messages
msg19660 (view) Author: warren Date: 2017-09-14.19:05:40
1. Steps to reproduce:

  Add a patch with adddir ending with a trailing slash.
  Notice the directory is created as normal, and can be deleted as 
normal.
  However, the deletion patch cannot be pulled by a Darcs repo that has 
the patch index enabled.

2. Code to reproduce:
  > mkdir a b
  > cd b
  > darcs init
  > cd ../a
  > darcs init
  > mkdir directory
  > darcs add directory
  Adding 'directory'
  > darcs record
  What is your email address? wwilkinson@dwavesys.com
  adddir ./directory
  Shall I record this change? (1/1)  [ynW...], or ? for more options: y
  Do you want to Record these changes? [Yglqk...], or ? for more options: 
y
  What is the patch name? add directory
  Do you want to add a long comment? [yn]n
  Finished recording patch 'add directory'
  > darcs send -o patch.patch ../b
  What is your email address (default wwilkinson@dwavesys.com)? 
  HINT: if you want to change the default remote repository to
        /tmp/darcs-test/b,
        quit now and issue the same command with the --set-default flag.
  patch 85affde62a9f865d72f30cb69ce64003647edd62
  Author: wwilkinson@dwavesys.com
  Date:   Thu Sep 14 11:01:14 PDT 2017
    * add directory
  Shall I send this patch? (1/1)  [ynW...], or ? for more options: y
  Do you want to Send these patches? [Yglqk...], or ? for more options: y
  Wrote patch to /tmp/darcs-test/a/patch.patch.
  > # Now, add a trailing slash to the adddir statement, and delete the 
hash so the patch can
  > # be accepted.
  > sed -e s'#adddir ./directory#adddir ./directory/#' -e '/Patch bundle 
hash:/,+2d' patch.patch > tweaked.patch
  > cd ../b
  > darcs apply ../a/tweaked.patch
  > rm -rf directory
  > darcs record
  What is your email address? wwilkinson@dwavesys.com
  rmdir ./directory
  Shall I record this change? (1/1)  [ynW...], or ? for more options: y
  Do you want to Record these changes? [Yglqk...], or ? for more options: 
y
  What is the patch name? remove directory
  Do you want to add a long comment? [yn]n
  Finished recording patch 'remove directory'
  > # Now, try pulling these patches.
  > mkdir darcs-no-index darcs-with-index
  > cd darcs-no-index
  > darcs init
  > darcs pull ../b
  HINT: if you want to change the default remote repository to
        /tmp/darcs-test/b,
        quit now and issue the same command with the --set-default flag.
  patch 85affde62a9f865d72f30cb69ce64003647edd62
  Author: wwilkinson@dwavesys.com
  Date:   Thu Sep 14 11:01:14 PDT 2017
    * add directory
  Shall I pull this patch? (1/2)  [ynW...], or ? for more options: y
  patch ec49e71e8fbbe9bc0acbaef42122ce33e1a237b3
  Author: wwilkinson@dwavesys.com
  Date:   Thu Sep 14 11:07:19 PDT 2017
    * remove directory
  Shall I pull this patch? (2/2)  [ynW...], or ? for more options: y
  Do you want to Pull these patches? [Yglqk...], or ? for more options: d
  Finished pulling.
  > cd ../darcs-with-index
  > darcs init
  > darcs optimize enable-patch-index
  > darcs pull ../b
  HINT: if you want to change the default remote repository to
        /tmp/darcs-test/b,
        quit now and issue the same command with the --set-default flag.
  patch 85affde62a9f865d72f30cb69ce64003647edd62
  Author: wwilkinson@dwavesys.com
  Date:   Thu Sep 14 11:01:14 PDT 2017
    * add directory
  Shall I pull this patch? (1/2)  [ynW...], or ? for more options: y
  patch ec49e71e8fbbe9bc0acbaef42122ce33e1a237b3
  Author: wwilkinson@dwavesys.com
  Date:   Thu Sep 14 11:07:19 PDT 2017
    * remove directory
  Shall I pull this patch? (2/2)  [ynW...], or ? for more options: y
  Do you want to Pull these patches? [Yglqk...], or ? for more options: y
  darcs: bug at src/Darcs/Repository/PatchIndex.hs:265 compiled Nov  1 
2016 11:38:36
  couldn't find ./directory in patch index
  See http://wiki.darcs.net/BugTracker/Reporting for help on bug 
reporting.


3. What I expected to happen:

  The trailing slash should make no difference. The patch should have 
been pullable even when the patch-index is enabled (just like how it's 
pullable
  when the patch-index is NOT enabled).

4. What did happen:

  The patches are only pullable when patch index is disabled.


5. What darcs version are you using? (Try: darcs --exact-version)

darcs compiled on Nov  1 2016, at 11:40:33

Context:

[TAG 2.12.4
Guillaume Hoffmann <guillaumh@gmail.com>**20160914143914
 Ignore-this: fee5b93a45e3a175e63e6fdb837ec4dc
] 

Compiled with:

HTTP-4000.3.3
array-0.5.1.0
async-2.1.0
attoparsec-0.13.1.0
base-4.8.2.0
base16-bytestring-0.1.1.6
binary-0.7.5.0
bytestring-0.10.6.0
containers-0.5.6.2
cryptohash-0.11.9
data-ordlist-0.4.7.0
directory-1.2.2.0
fgl-5.5.3.0
filepath-1.4.0.0
graphviz-2999.18.1.2
hashable-1.2.4.0
haskeline-0.7.2.1
html-1.0.1.2
mmap-0.5.9
mtl-2.2.1
network-2.6.3.1
network-uri-2.6.1.0
old-time-1.1.0.3
parsec-3.1.11
process-1.2.3.0
random-1.1
regex-applicative-0.3.3
regex-compat-tdfa-0.95.1.4
sandi-0.4.0
tar-0.5.0.3
terminfo-0.4.0.1
text-1.2.2.1
time-1.5.0.1
transformers-0.4.2.0
transformers-compat-0.5.1.4
unix-2.7.1.0
unix-compat-0.4.2.0
utf8-string-1.0.1.1
vector-0.11.0.0
zip-archive-0.3.0.5
zlib-0.6.1.1

6. What operating system are you running?

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.5 LTS
Release:	14.04
Codename:	trusty
msg19661 (view) Author: bf Date: 2017-09-22.13:48:10
When darcs reads a patch bundle it expects it to be in exactly the same
format that it would write it. If you edit the file either manually or
with a script, then all bets are off. It may work or it may not or it
may seem to work at first and then later give you serious headaches.

The only issue I can see here is that darcs accepts the edited bundle
with the trailing slash after the adddir, instead of reporting it as an
error. We should add a consistency check for paths to the patch parser.
msg22359 (view) Author: bf Date: 2020-08-01.13:42:15
I can no longer reproduce the original problem, see patch2083. This 
has most probably been fixed by consistently using AnchoredPath in the 
internal patch representation, which means we no longer write out 
patches with such a path in them.
History
Date User Action Args
2017-09-14 19:05:43warrencreate
2017-09-22 13:48:16bfsetmessages: + msg19661
2020-08-01 13:42:17bfsetstatus: unknown -> resolved
messages: + msg22359