[PATCH] Issue1910: --base does not work reliably

Jesse Glick typrase at gmail.com
Tue Nov 17 11:23:13 CST 2009


# HG changeset patch
# User Jesse Glick <jesse.glick at sun.com>
# Date 1258478568 18000
# Node ID b0b177231a6330a7da8a503d3e74164c86bc60ba
# Parent  57949bfec718c467f02bd4e9c2bfb8e24d001a5b
Issue1910: --base does not work reliably.

Documentation for --base says that this revision is assumed to be in the
postulated remote repository and so does not need to be in the changegroup.
Actual behavior was to include it nonetheless in case it was a head (or one of
the --rev arguments, if some were given, contrary to a suggestion in Issue76).
Patch fixes calculation to always exclude --base, as well as its ancestors as
was already done. Also fixes localrepo.changegroupsubset to treat bases==[]
consistently by producing an empty result, rather than treating it like
[nullid] (but issues a warning if bundle is doing this).

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -527,7 +527,8 @@
             n = visit.pop(0)
             parents = [p for p in repo.changelog.parents(n) if p not in has]
             if len(parents) == 0:
-                o.insert(0, n)
+                if n not in has:
+                    o.insert(0, n)
             else:
                 for p in parents:
                     if p not in seen:
@@ -539,6 +540,9 @@
         other = hg.repository(cmdutil.remoteui(repo, opts), dest)
         o = repo.findoutgoing(other, force=opts.get('force'))
 
+    if not o:
+        ui.warn(_('no changesets found; creating empty bundle\n'))
+
     if revs:
         cg = repo.changegroupsubset(o, revs, 'bundle')
     else:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1628,7 +1628,7 @@
         cl = self.changelog
         # msng is short for missing - compute the list of changesets in this
         # changegroup.
-        if not bases:
+        if bases is None:
             bases = [nullid]
         msng_cl_lst, bases, heads = cl.nodesbetween(bases, heads)
 
diff --git a/tests/test-bundle-r b/tests/test-bundle-r
--- a/tests/test-bundle-r
+++ b/tests/test-bundle-r
@@ -73,7 +73,7 @@
 hg -R test bundle --base 2 test-bundle-all.hg
 hg -R test bundle --base 3 -r tip test-bundle-should-fail.hg
 
-# issue76 msg2163
+# issue76 msg2163 vs. issue1910 msg10989
 hg -R test bundle --base 3 -r 3 -r 3 test-bundle-cset-3.hg
 
 hg clone test-2 test-9
diff --git a/tests/test-bundle-r.out b/tests/test-bundle-r.out
--- a/tests/test-bundle-r.out
+++ b/tests/test-bundle-r.out
@@ -162,7 +162,8 @@
 4 changesets found
 6 changesets found
 1 changesets found
-1 changesets found
+no changesets found; creating empty bundle
+0 changesets found
 updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % 2


More information about the Mercurial-devel mailing list