streamclone: partially encode filename over the wire, not for local read (issue1847)
authorGreg Ward <greg-hg@gerg.ca>
Wed, 30 Sep 2009 16:08:11 -0400
changeset 9506 49b62395e910
parent 9505 28b089ae4001
child 9507 5987183d6e59
streamclone: partially encode filename over the wire, not for local read (issue1847) (Fixes issue1847, which was introduced by 810387f59696: stream clone of a repo with directory named *.d failed: server raises exception "IOError: [Errno 2] No such file or directory: /tmp/test/.hg/store/data/foo.d.hg.hg/foo".)
mercurial/streamclone.py
tests/test-http
tests/test-http.out
--- a/mercurial/streamclone.py	Wed Sep 30 13:15:18 2009 -0500
+++ b/mercurial/streamclone.py	Wed Sep 30 16:08:11 2009 -0400
@@ -48,8 +48,7 @@
         try:
             repo.ui.debug(_('scanning\n'))
             for name, ename, size in repo.store.walk():
-                # for backwards compat, name was partially encoded
-                entries.append((store.encodedir(name), size))
+                entries.append((name, size))
                 total_bytes += size
         finally:
             lock.release()
@@ -62,6 +61,7 @@
     yield '%d %d\n' % (len(entries), total_bytes)
     for name, size in entries:
         repo.ui.debug(_('sending %s (%d bytes)\n') % (name, size))
-        yield '%s\0%d\n' % (name, size)
+        # partially encode name over the wire for backwards compat
+        yield '%s\0%d\n' % (store.encodedir(name), size)
         for chunk in util.filechunkiter(repo.sopener(name), limit=size):
             yield chunk
--- a/tests/test-http	Wed Sep 30 13:15:18 2009 -0500
+++ b/tests/test-http	Wed Sep 30 16:08:11 2009 -0400
@@ -5,6 +5,11 @@
 hg init test
 cd test
 echo foo>foo
+mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
+echo foo>foo.d/foo
+echo bar>foo.d/bAr.hg.d/BaR
+echo bar>foo.d/baR.d.hg/bAR
+
 hg commit -A -m 1
 hg --config server.uncompressed=True serve -p $HGPORT -d --pid-file=../hg1.pid
 hg serve -p $HGPORT1 -d --pid-file=../hg2.pid
--- a/tests/test-http.out	Wed Sep 30 13:15:18 2009 -0500
+++ b/tests/test-http.out	Wed Sep 30 16:08:11 2009 -0400
@@ -1,4 +1,7 @@
 adding foo
+adding foo.d/bAr.hg.d/BaR
+adding foo.d/baR.d.hg/bAR
+adding foo.d/foo
 abort: cannot start server at ':20060':
 % clone via stream
 streaming all changes
@@ -10,31 +13,31 @@
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-1 files, 1 changesets, 1 total revisions
+4 files, 1 changesets, 4 total revisions
 % try to clone via stream, should use pull instead
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files
+added 1 changesets with 4 changes to 4 files
 updating working directory
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % clone via pull
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files
+added 1 changesets with 4 changes to 4 files
 updating working directory
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 checking changesets
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-1 files, 1 changesets, 1 total revisions
+4 files, 1 changesets, 4 total revisions
 adding bar
 % pull
-changegroup hook: HG_NODE=cfbd11a1fa315300a080c3de8fe36b0fc5820acf HG_SOURCE=pull HG_URL=http://localhost/ 
+changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost/ 
 pulling from http://localhost/
 searching for changes
 adding changesets