Mercurial > hg > mercurial-crew
comparison mercurial/util.py @ 11254:640d419725d0 stable
util.copyfiles: don't try os_link() again if it failed before
If the os_link() call on the first file in the directory fails [1],
we switch mode to using shutil.copy() for all remaining files.
[1] happens for example on Windows for every file when cloning from a UNC
path without specifying --pull.
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Fri, 28 May 2010 17:28:34 +0200 |
parents | 18e81d42ee5c |
children | 94b7b3a1ae1b |
comparison
equal
deleted
inserted
replaced
11249:0bb67503ad4b | 11254:640d419725d0 |
---|---|
449 if os.path.isdir(src): | 449 if os.path.isdir(src): |
450 os.mkdir(dst) | 450 os.mkdir(dst) |
451 for name, kind in osutil.listdir(src): | 451 for name, kind in osutil.listdir(src): |
452 srcname = os.path.join(src, name) | 452 srcname = os.path.join(src, name) |
453 dstname = os.path.join(dst, name) | 453 dstname = os.path.join(dst, name) |
454 copyfiles(srcname, dstname, hardlink) | 454 hardlink = copyfiles(srcname, dstname, hardlink) |
455 else: | 455 else: |
456 if hardlink: | 456 if hardlink: |
457 try: | 457 try: |
458 os_link(src, dst) | 458 os_link(src, dst) |
459 except (IOError, OSError): | 459 except (IOError, OSError): |
460 hardlink = False | 460 hardlink = False |
461 shutil.copy(src, dst) | 461 shutil.copy(src, dst) |
462 else: | 462 else: |
463 shutil.copy(src, dst) | 463 shutil.copy(src, dst) |
464 | |
465 return hardlink | |
464 | 466 |
465 class path_auditor(object): | 467 class path_auditor(object): |
466 '''ensure that a filesystem path contains no banned components. | 468 '''ensure that a filesystem path contains no banned components. |
467 the following properties of a path are checked: | 469 the following properties of a path are checked: |
468 | 470 |