Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 698:df78d8ccac4c
Use python function instead of external 'cp' command when cloning repos.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Use python function instead of external 'cp' command when cloning repos.
Inspired by a patch from Stephen Darnell.
manifest hash: b525b0bf40f349b362db7c46d62be41572ef65cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFC1ncZW7P1GVgWeRoRAiJmAJ9GaCPaG6yOKb72I+SpDDdcdXTISACePD0H
GR/F+qqzi2imdgIV77ziLcQ=
=YVd2
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 14 Jul 2005 15:30:49 +0100 |
parents | 31a9aa890016 |
children | 5ca319a641e1 |
comparison
equal
deleted
inserted
replaced
697:cb1be2327220 | 698:df78d8ccac4c |
---|---|
43 try: | 43 try: |
44 os.rename(src, dst) | 44 os.rename(src, dst) |
45 except: | 45 except: |
46 os.unlink(dst) | 46 os.unlink(dst) |
47 os.rename(src, dst) | 47 os.rename(src, dst) |
48 | |
49 def copytree(src, dst, copyfile): | |
50 """Copy a directory tree, files are copied using 'copyfile'.""" | |
51 names = os.listdir(src) | |
52 os.mkdir(dst) | |
53 | |
54 for name in names: | |
55 srcname = os.path.join(src, name) | |
56 dstname = os.path.join(dst, name) | |
57 if os.path.isdir(srcname): | |
58 copytree(srcname, dstname, copyfile) | |
59 elif os.path.isfile(srcname): | |
60 copyfile(srcname, dstname) | |
61 else: | |
62 raise IOError("Not a regular file: %r" % srcname) | |
48 | 63 |
49 # Platfor specific varients | 64 # Platfor specific varients |
50 if os.name == 'nt': | 65 if os.name == 'nt': |
51 nulldev = 'NUL:' | 66 nulldev = 'NUL:' |
52 | 67 |