Move empty local repo logic for pull into findincoming
authorMatt Mackall <mpm@selenic.com>
Fri, 21 Apr 2006 15:33:51 -0500
changeset 2108 30c7564f6dfc
parent 2107 7ff92c04f8e5
child 2109 1b183976e007
Move empty local repo logic for pull into findincoming This fixes a silly attempt to pull a changegroup from an empty repo.
mercurial/localrepo.py
tests/test-bad-pull.out
tests/test-clone-failure.out
--- a/mercurial/localrepo.py	Fri Apr 21 15:14:27 2006 -0500
+++ b/mercurial/localrepo.py	Fri Apr 21 15:33:51 2006 -0500
@@ -831,13 +831,18 @@
         if base == None:
             base = {}
 
+        if not heads:
+            heads = remote.heads()
+
+        if self.changelog.tip() == nullid:
+            if heads != [nullid]:
+                return [nullid]
+            return []
+
         # assume we're closer to the tip than the root
         # and start by examining the heads
         self.ui.status(_("searching for changes\n"))
 
-        if not heads:
-            heads = remote.heads()
-
         unknown = []
         for h in heads:
             if h not in m:
@@ -998,12 +1003,9 @@
     def pull(self, remote, heads=None, force=False):
         l = self.lock()
 
-        # if we have an empty repo, fetch everything
-        if self.changelog.tip() == nullid:
+        fetch = self.findincoming(remote, force=force)
+        if fetch == [nullid]:
             self.ui.status(_("requesting all changes\n"))
-            fetch = [nullid]
-        else:
-            fetch = self.findincoming(remote, force=force)
 
         if not fetch:
             self.ui.status(_("no changes found\n"))
--- a/tests/test-bad-pull.out	Fri Apr 21 15:14:27 2006 -0500
+++ b/tests/test-bad-pull.out	Fri Apr 21 15:33:51 2006 -0500
@@ -1,7 +1,5 @@
-requesting all changes
 abort: error: Connection refused
 255
 copy: No such file or directory
-requesting all changes
 abort: HTTP Error 404: File not found
 255
--- a/tests/test-clone-failure.out	Fri Apr 21 15:14:27 2006 -0500
+++ b/tests/test-clone-failure.out	Fri Apr 21 15:33:51 2006 -0500
@@ -1,6 +1,5 @@
 abort: repository a not found!
 255
-requesting all changes
 abort: error: Connection refused
 255
 abort: repository a not found!