hg: rewrite "copystore()" with vfs
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Tue, 12 Nov 2013 16:23:52 +0900
changeset 20089 2d0ab571b822
parent 20088 7cbb79bddee7
child 20090 88d8e568add1
hg: rewrite "copystore()" with vfs This patch rewrites "copystore()" with vfs, because succeeding patch requires "lock.lock()" invocation with vfs. This patch uses 'dstbase + "/lock"' instead of "join()" with both elements even on Windows environment but it should be reasonable, because target files given from "store.copyfiles()" already uses "/" as path separator. "util.copyfiles()" between two vfs-s may have to be rewritten in the future.
mercurial/hg.py
--- a/mercurial/hg.py	Tue Nov 12 16:23:52 2013 +0900
+++ b/mercurial/hg.py	Tue Nov 12 16:23:52 2013 +0900
@@ -202,19 +202,20 @@
         hardlink = None
         num = 0
         srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
+        srcvfs = scmutil.vfs(srcrepo.sharedpath)
+        dstvfs = scmutil.vfs(destpath)
         for f in srcrepo.store.copylist():
             if srcpublishing and f.endswith('phaseroots'):
                 continue
-            src = os.path.join(srcrepo.sharedpath, f)
-            dst = os.path.join(destpath, f)
-            dstbase = os.path.dirname(dst)
-            if dstbase and not os.path.exists(dstbase):
-                os.mkdir(dstbase)
-            if os.path.exists(src):
-                if dst.endswith('data'):
+            dstbase = os.path.dirname(f)
+            if dstbase and not dstvfs.exists(dstbase):
+                dstvfs.mkdir(dstbase)
+            if srcvfs.exists(f):
+                if f.endswith('data'):
                     # lock to avoid premature writing to the target
-                    destlock = lock.lock(os.path.join(dstbase, "lock"))
-                hardlink, n = util.copyfiles(src, dst, hardlink)
+                    destlock = lock.lock(dstvfs.join(dstbase + "/lock"))
+                hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
+                                             hardlink)
                 num += n
         if hardlink:
             ui.debug("linked %d files\n" % num)