[PATCH STABLE V3] setdiscovery: return anyincoming=False when remote's only head is nullid

Andrew Pritchard andrewp at fogcreek.com
Wed Jul 27 17:36:27 CDT 2011


# HG changeset patch
# User Andrew Pritchard <andrewp at fogcreek.com>
# Date 1311805974 14400
# Branch stable
# Node ID 6b4e3f01d90b799fe72e3a7d6312e5faabed67a9
# Parent  56848e2bb0c5a43b580dd2ca7ce1e781d4e75b2b
setdiscovery: return anyincoming=False when remote's only head is nullid

This fixes (issue2907) a crash when using 'hg incoming --bundle' with an empty
remote repo and a non-empty local repo.

This also fixes an unreported bug that 'hg summary --remote' erroneously
reports incoming changes when the remote repo is empty and the local is not.

Also, add a test to make sure issue2907 stays fixed

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -190,4 +190,5 @@
             ui.warn(_("warning: repository is unrelated\n"))
         return (set([nullid]), True, srvheadhashes,)
 
-    return (dag.externalizeall(result), True, srvheadhashes,)
+    anyincoming = (srvheadhashes != [nullid])
+    return dag.externalizeall(result), anyincoming, srvheadhashes
diff --git a/tests/test-incoming-outgoing.t b/tests/test-incoming-outgoing.t
--- a/tests/test-incoming-outgoing.t
+++ b/tests/test-incoming-outgoing.t
@@ -465,3 +465,16 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     11
   
+
+incoming from empty remote repository
+
+  $ hg init r1
+  $ hg init r2
+  $ echo a > r1/foo
+  $ hg -R r1 ci -Ama
+  adding foo
+  $ hg -R r1 incoming r2 --bundle x.hg
+  comparing with r2
+  searching for changes
+  no changes found
+  [1]


More information about the Mercurial-devel mailing list