comparison mercurial/hg.py @ 11255:e4dbaa40096d stable

clone: save hardlink state of util.copyfiles() When trying to do hardlink-cloning, the os_link() call of the first file tried already fails on Windows, if the source is on a UNC path. This change avoids calling os_link() for the rest of files, leaving us with a *single* failed os_link() call per clone operation, if the source can't do hardlinks.
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 28 May 2010 17:28:34 +0200
parents 17031fea4e95
children 94b7b3a1ae1b 05ac42e56452
comparison
equal deleted inserted replaced
11254:640d419725d0 11255:e4dbaa40096d
275 dir_cleanup.close() 275 dir_cleanup.close()
276 raise util.Abort(_("destination '%s' already exists") 276 raise util.Abort(_("destination '%s' already exists")
277 % dest) 277 % dest)
278 raise 278 raise
279 279
280 hardlink = None
280 for f in src_repo.store.copylist(): 281 for f in src_repo.store.copylist():
281 src = os.path.join(src_repo.sharedpath, f) 282 src = os.path.join(src_repo.sharedpath, f)
282 dst = os.path.join(dest_path, f) 283 dst = os.path.join(dest_path, f)
283 dstbase = os.path.dirname(dst) 284 dstbase = os.path.dirname(dst)
284 if dstbase and not os.path.exists(dstbase): 285 if dstbase and not os.path.exists(dstbase):
285 os.mkdir(dstbase) 286 os.mkdir(dstbase)
286 if os.path.exists(src): 287 if os.path.exists(src):
287 if dst.endswith('data'): 288 if dst.endswith('data'):
288 # lock to avoid premature writing to the target 289 # lock to avoid premature writing to the target
289 dest_lock = lock.lock(os.path.join(dstbase, "lock")) 290 dest_lock = lock.lock(os.path.join(dstbase, "lock"))
290 util.copyfiles(src, dst) 291 hardlink = util.copyfiles(src, dst, hardlink)
291 292
292 # we need to re-init the repo after manually copying the data 293 # we need to re-init the repo after manually copying the data
293 # into it 294 # into it
294 dest_repo = repository(ui, dest) 295 dest_repo = repository(ui, dest)
295 src_repo.hook('outgoing', source='clone', node='0'*40) 296 src_repo.hook('outgoing', source='clone', node='0'*40)