Show More
@@ -6,7 +6,7 | |||
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | from demandload import demandload |
|
9 | demandload(globals(), "os re sys signal") | |
|
9 | demandload(globals(), "os re sys signal shutil") | |
|
10 | 10 | demandload(globals(), "fancyopts ui hg util") |
|
11 | 11 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
|
12 | 12 | demandload(globals(), "errno socket version struct") |
@@ -384,7 +384,6 def clone(ui, source, dest = None, **opt | |||
|
384 | 384 | |
|
385 | 385 | class Dircleanup: |
|
386 | 386 | def __init__(self, dir_): |
|
387 | import shutil | |
|
388 | 387 | self.rmtree = shutil.rmtree |
|
389 | 388 | self.dir_ = dir_ |
|
390 | 389 | os.mkdir(dir_) |
@@ -401,10 +400,12 def clone(ui, source, dest = None, **opt | |||
|
401 | 400 | |
|
402 | 401 | if other.dev() != -1: |
|
403 | 402 | abspath = os.path.abspath(source) |
|
404 | ||
|
405 | if other.dev() != -1 and os.stat(dest).st_dev == other.dev(): | |
|
403 | copyfile = (os.stat(dest).st_dev == other.dev() | |
|
404 | and getattr(os, 'link', None) or shutil.copy2) | |
|
405 | if copyfile is not shutil.copy2: | |
|
406 | 406 | ui.note("cloning by hardlink\n") |
|
407 | util.system("cp -al '%s'/.hg '%s'/.hg" % (source, dest)) | |
|
407 | util.copytree(os.path.join(source, ".hg"), os.path.join(dest, ".hg"), | |
|
408 | copyfile) | |
|
408 | 409 | try: |
|
409 | 410 | os.unlink(os.path.join(dest, ".hg", "dirstate")) |
|
410 | 411 | except IOError: |
@@ -46,6 +46,21 def rename(src, dst): | |||
|
46 | 46 | os.unlink(dst) |
|
47 | 47 | os.rename(src, dst) |
|
48 | 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) | |
|
63 | ||
|
49 | 64 | # Platfor specific varients |
|
50 | 65 | if os.name == 'nt': |
|
51 | 66 | nulldev = 'NUL:' |
General Comments 0
You need to be logged in to leave comments.
Login now