comparison mercurial/hg.py @ 20089:2d0ab571b822

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 12 Nov 2013 16:23:52 +0900
parents 6f72e7d28b35
children abfe6a8e619b
comparison
equal deleted inserted replaced
20088:7cbb79bddee7 20089:2d0ab571b822
200 destlock = None 200 destlock = None
201 try: 201 try:
202 hardlink = None 202 hardlink = None
203 num = 0 203 num = 0
204 srcpublishing = srcrepo.ui.configbool('phases', 'publish', True) 204 srcpublishing = srcrepo.ui.configbool('phases', 'publish', True)
205 srcvfs = scmutil.vfs(srcrepo.sharedpath)
206 dstvfs = scmutil.vfs(destpath)
205 for f in srcrepo.store.copylist(): 207 for f in srcrepo.store.copylist():
206 if srcpublishing and f.endswith('phaseroots'): 208 if srcpublishing and f.endswith('phaseroots'):
207 continue 209 continue
208 src = os.path.join(srcrepo.sharedpath, f) 210 dstbase = os.path.dirname(f)
209 dst = os.path.join(destpath, f) 211 if dstbase and not dstvfs.exists(dstbase):
210 dstbase = os.path.dirname(dst) 212 dstvfs.mkdir(dstbase)
211 if dstbase and not os.path.exists(dstbase): 213 if srcvfs.exists(f):
212 os.mkdir(dstbase) 214 if f.endswith('data'):
213 if os.path.exists(src):
214 if dst.endswith('data'):
215 # lock to avoid premature writing to the target 215 # lock to avoid premature writing to the target
216 destlock = lock.lock(os.path.join(dstbase, "lock")) 216 destlock = lock.lock(dstvfs.join(dstbase + "/lock"))
217 hardlink, n = util.copyfiles(src, dst, hardlink) 217 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
218 hardlink)
218 num += n 219 num += n
219 if hardlink: 220 if hardlink:
220 ui.debug("linked %d files\n" % num) 221 ui.debug("linked %d files\n" % num)
221 else: 222 else:
222 ui.debug("copied %d files\n" % num) 223 ui.debug("copied %d files\n" % num)