# HG changeset patch # User mpm@selenic.com # Date 1120083017 28800 # Node ID 337163e4d4b9c6a0df1ee6fa2083d3bcae419cd4 # Parent 230676d0df6fbfb189ef1d9339188d465b01c0d4 [PATCH] Perform clone in place -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Perform clone in place From: Bryan O'Sullivan This is a rewrite of one of my earlier clone cleanup patches. This patch only does one thing - make clone operate in place. It depends on safe-clone.patch. Don't have clone use os.chdir. Instead, do everything in place. manifest hash: cf7cf24f8fa1120b609b0beee4281bc236e484c0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwxxJywK+sNU5EO8RAjnlAJ44B1jhFvuYF3uNDH6qWDKaqgURuwCdFeFo Y9tjLx6TLCBWT146h21YEGA= =E1n/ -----END PGP SIGNATURE----- diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -269,7 +269,7 @@ def clone(ui, source, dest = None, **opt """make a copy of an existing repository""" source = ui.expandpath(source) - success = created = False + success = False if dest is None: dest = os.path.basename(source) @@ -280,28 +280,23 @@ def clone(ui, source, dest = None, **opt os.mkdir(dest) try: - dest = os.path.realpath(dest) - link = 0 if not source.startswith("http://"): - source = os.path.realpath(source) d1 = os.stat(dest).st_dev d2 = os.stat(source).st_dev if d1 == d2: link = 1 - os.chdir(dest) - if link: ui.debug("copying by hardlink\n") - util.system("cp -al %s/.hg .hg" % source) + util.system("cp -al '%s'/.hg '%s'/.hg" % (source, dest)) try: - os.remove(".hg/dirstate") + os.remove(os.path.join(dest, ".hg", "dirstate")) except: pass - repo = hg.repository(ui, ".") + repo = hg.repository(ui, dest) else: - repo = hg.repository(ui, ".", create=1) + repo = hg.repository(ui, dest, create=1) other = hg.repository(ui, source) fetch = repo.findincoming(other) if fetch: @@ -318,7 +313,7 @@ def clone(ui, source, dest = None, **opt success = True finally: - if created and not success: + if not success: import shutil shutil.rmtree(dest, True)