clone: simplifying dest repo creation
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 02 Sep 2006 23:26:10 +0200
changeset 3037 3acb76f0124d
parent 3036 adf7f3421c55
child 3038 1efd5a6df5a3
clone: simplifying dest repo creation since creating a repo raises an exception if the repo already exists, there's no need to try to create one. add some test for repo creation when the destination exists
mercurial/hg.py
tests/test-init
tests/test-init.out
--- a/mercurial/hg.py	Sat Sep 02 23:14:35 2006 +0200
+++ b/mercurial/hg.py	Sat Sep 02 23:26:10 2006 +0200
@@ -127,12 +127,7 @@
             if self.dir_:
                 self.rmtree(self.dir_, True)
 
-    dest_repo = None
-    try:
-        dest_repo = repository(ui, dest)
-        raise util.Abort(_("destination '%s' already exists." % dest))
-    except RepoError:
-        dest_repo = repository(ui, dest, create=True)
+    dest_repo = repository(ui, dest, create=True)
 
     dest_path = None
     dir_cleanup = None
--- a/tests/test-init	Sat Sep 02 23:14:35 2006 +0200
+++ b/tests/test-init	Sat Sep 02 23:26:10 2006 +0200
@@ -27,6 +27,9 @@
 echo this > local/foo
 hg ci --cwd local -A -m "init" -d "1000000 0"
 
+echo "#test failure"
+hg init local
+
 echo "# init+push to remote2"
 hg init -e ./dummyssh ssh://user@dummy/remote2
 hg incoming -R remote2 local
@@ -35,6 +38,12 @@
 echo "# clone to remote1"
 hg clone -e ./dummyssh local ssh://user@dummy/remote1
 
+echo "# init to existing repo"
+hg init -e ./dummyssh ssh://user@dummy/remote1
+
+echo "# clone to existing repo"
+hg clone -e ./dummyssh local ssh://user@dummy/remote1
+
 echo "# output of dummyssh"
 cat dummylog
 
--- a/tests/test-init.out	Sat Sep 02 23:14:35 2006 +0200
+++ b/tests/test-init.out	Sat Sep 02 23:26:10 2006 +0200
@@ -1,5 +1,7 @@
 # creating 'local'
 adding foo
+#test failure
+abort: repository local already exists!
 # init+push to remote2
 remote: abort: repository remote2 not found!
 changeset:   0:c4e059d443be
@@ -17,19 +19,23 @@
 # clone to remote1
 remote: abort: repository remote1 not found!
 searching for changes
-remote: abort: repository remote1 not found!
 remote: adding changesets
 remote: adding manifests
 remote: adding file changes
 remote: added 1 changesets with 1 changes to 1 files
+# init to existing repo
+abort: repository ssh://user@dummy/remote1 already exists!
+# clone to existing repo
+abort: repository ssh://user@dummy/remote1 already exists!
 # output of dummyssh
 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5:
 Got arguments 1:user@dummy 2:hg init remote2 3: 4: 5:
 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5:
 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5:
 Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5:
+Got arguments 1:user@dummy 2:hg init remote1 3: 4: 5:
 Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5:
-Got arguments 1:user@dummy 2:hg init remote1 3: 4: 5:
+Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5:
 Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5:
 # comparing repositories
 0:c4e059d443be