Mercurial > hg
comparison mercurial/util.py @ 11232:97f6d2a02c1f
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 | 4d8db9676171 |
children | c61442f6d106 |
comparison
equal
deleted
inserted
replaced
11231:1107888a1ad1 | 11232:97f6d2a02c1f |
---|---|
456 if os.path.isdir(src): | 456 if os.path.isdir(src): |
457 os.mkdir(dst) | 457 os.mkdir(dst) |
458 for name, kind in osutil.listdir(src): | 458 for name, kind in osutil.listdir(src): |
459 srcname = os.path.join(src, name) | 459 srcname = os.path.join(src, name) |
460 dstname = os.path.join(dst, name) | 460 dstname = os.path.join(dst, name) |
461 copyfiles(srcname, dstname, hardlink) | 461 hardlink = copyfiles(srcname, dstname, hardlink) |
462 else: | 462 else: |
463 if hardlink: | 463 if hardlink: |
464 try: | 464 try: |
465 os_link(src, dst) | 465 os_link(src, dst) |
466 except (IOError, OSError): | 466 except (IOError, OSError): |
467 hardlink = False | 467 hardlink = False |
468 shutil.copy(src, dst) | 468 shutil.copy(src, dst) |
469 else: | 469 else: |
470 shutil.copy(src, dst) | 470 shutil.copy(src, dst) |
471 | |
472 return hardlink | |
471 | 473 |
472 class path_auditor(object): | 474 class path_auditor(object): |
473 '''ensure that a filesystem path contains no banned components. | 475 '''ensure that a filesystem path contains no banned components. |
474 the following properties of a path are checked: | 476 the following properties of a path are checked: |
475 | 477 |