[PATCH 3 of 3] clone: Allow clone into an empty directory
Marti Raudsepp
marti at juffo.org
Sat Mar 14 07:39:34 CDT 2009
# HG changeset patch
# User Marti Raudsepp <marti at juffo.org>
# Date 1235986682 0
# Node ID b968edbf2471d265eab8b99da874a68b8deaa8e5
# Parent 500b4fd352a9194c2a52b90e922f5110cdabeda9
clone: Allow clone into an empty directory.
Users of SVN often create the destination directory in advance.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -130,8 +130,8 @@
dest = localpath(dest)
source = localpath(source)
- if os.path.exists(dest):
- raise util.Abort(_("destination '%s' already exists") % dest)
+ if os.path.exists(dest) and len(os.listdir(dest)) > 0:
+ raise util.Abort(_("destination '%s' is not empty") % dest)
class DirCleanup(object):
def __init__(self, dir_):
diff --git a/tests/test-clone-failure b/tests/test-clone-failure
--- a/tests/test-clone-failure
+++ b/tests/test-clone-failure
@@ -22,7 +22,19 @@
hg clone . ../a
echo $?
cd ..
+
+# Non-empty destination
chmod 700 a
+touch a/dummy
+hg clone b a
+echo $?
+
+# Non-directory destination
+rm -r a
+touch a
+hg clone b a
+echo $?
+
rm -r a b
# Source of wrong type
diff --git a/tests/test-clone-failure.out b/tests/test-clone-failure.out
--- a/tests/test-clone-failure.out
+++ b/tests/test-clone-failure.out
@@ -4,9 +4,13 @@
255
abort: repository a not found!
255
-abort: destination '../a' already exists
+abort: Permission denied: ../a
+255
+abort: destination 'a' is not empty
+255
+abort: Not a directory: a
255
abort: repository a not found!
255
destination directory: q
-abort: destination 'q' already exists
+abort: destination 'q' is not empty
More information about the Mercurial-devel
mailing list