# HG changeset patch # User FUJIWARA Katsunori # Date 1384241032 -32400 # Node ID 2d0ab571b822a664ab7d41acea4ed622de7c995a # Parent 7cbb79bddee7188d072c1eb217b298a20d0ba0a2 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. diff -r 7cbb79bddee7 -r 2d0ab571b822 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)