Mercurial > hg
diff mercurial/commands.py @ 525:337163e4d4b9
[PATCH] Perform clone in place
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Perform clone in place
From: Bryan O'Sullivan <bos@serpentine.com>
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-----
author | mpm@selenic.com |
---|---|
date | Wed, 29 Jun 2005 14:10:17 -0800 |
parents | 003df62ae39f |
children | 55af04e26bad |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jun 29 14:09:33 2005 -0800 +++ b/mercurial/commands.py Wed Jun 29 14:10:17 2005 -0800 @@ -269,7 +269,7 @@ """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 @@ 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 @@ success = True finally: - if created and not success: + if not success: import shutil shutil.rmtree(dest, True)