[PATCH in crew-stable] verify: tolerate repeated slashes in a converted repo (issue3665)

Bryan O'Sullivan bos at serpentine.com
Tue Oct 23 00:01:35 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1350954340 25200
# Node ID 7aa7380691b8815200dda268aa1af19fd56aa741
# Parent  1b51638bf44af908281ad2b533aa63bdd42a5a85
verify: tolerate repeated slashes in a converted repo (issue3665)

These slashes are a hangover from issue3612, fixed in e4da793998bf.

Although the bugfix in that commit is correct, the test it adds
does not replicate the conditions for the bug correctly.

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -7,7 +7,7 @@
 
 from node import nullid, short
 from i18n import _
-import os
+import os, posixpath
 import revlog, util, error
 
 def verify(repo):
@@ -236,7 +236,12 @@ def _verify(repo):
             try:
                 storefiles.remove(ff)
             except KeyError:
-                err(lr, _("missing revlog!"), ff)
+                # under hg < 2.4, convert didn't sanitize paths properly,
+                # so a converted repo may contain repeated slashes
+                try:
+                    storefiles.remove(posixpath.normpath(ff))
+                except KeyError:
+                    err(lr, _("missing revlog!"), ff)
 
         checklog(fl, f, lr)
         seen = {}
diff --git a/tests/test-convert-filemap.t b/tests/test-convert-filemap.t
--- a/tests/test-convert-filemap.t
+++ b/tests/test-convert-filemap.t
@@ -226,10 +226,13 @@ final file versions in this repo:
   9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo
   $ hg --cwd foo-copied.repo debugrename copied
   copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
+
+ensure that the filemap contains duplicated slashes (issue3612)
+
   $ cat > renames.fmap <<EOF
   > include dir
   > exclude dir/file2
-  > rename dir dir2
+  > rename dir dir2//dir3
   > include foo
   > include copied
   > rename foo foo2
@@ -255,12 +258,19 @@ final file versions in this repo:
   |
   o  1 "1: add bar quux; copy foo to copied" files: copied2
   |
-  o  0 "0: add foo baz dir/" files: dir2/file dir2/subdir/file3 foo2
+  o  0 "0: add foo baz dir/" files: dir2//dir3/file dir2//dir3/subdir/file3 foo2
   
+  $ hg -R renames.repo verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  4 files, 5 changesets, 7 total revisions
+
   $ hg -R renames.repo manifest --debug
   d43feacba7a4f1f2080dde4a4b985bd8a0236d46 644   copied2
-  3e20847584beff41d7cd16136b7331ab3d754be0 644   dir2/file
-  5fe139720576e18e34bcc9f79174db8897c8afe9 644   dir2/subdir/file3
+  3e20847584beff41d7cd16136b7331ab3d754be0 644   dir2//dir3/file
+  5fe139720576e18e34bcc9f79174db8897c8afe9 644   dir2//dir3/subdir/file3
   9a7b52012991e4873687192c3e17e61ba3e837a3 644   foo2
   $ hg --cwd renames.repo debugrename copied2
   copied2 renamed from foo2:2ed2a3912a0b24502043eae84ee4b279c18b90dd


More information about the Mercurial-devel mailing list