Make "hg incoming -r revision_number" work for remote repos (issue566)
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 01 Jun 2007 19:45:05 +0200
changeset 4451 671158f060cc
parent 4441 2d3379c598c1
child 4474 08ae451148b2
child 4479 afa1f57ae484
Make "hg incoming -r revision_number" work for remote repos (issue566) Uses the remote repository's lookup method as pull does and only transfers what is needed to calculate incoming changesets. One minor problem: As only the needed changesets are transfered and stored in a local bundle repository, the tip tag of this bundle is shows despite not being the tip changeset of the remote repository. (see "+tag: tip" in tests/test-incoming-outgoing.out in this patch)
mercurial/commands.py
tests/test-incoming-outgoing.out
--- a/mercurial/commands.py	Sun May 20 19:27:14 2007 +0200
+++ b/mercurial/commands.py	Fri Jun 01 19:45:05 2007 +0200
@@ -1554,7 +1554,14 @@
     setremoteconfig(ui, opts)
 
     other = hg.repository(ui, source)
-    incoming = repo.findincoming(other, force=opts["force"])
+    revs = None
+    if opts['rev']:
+        if 'lookup' in other.capabilities:
+            revs = [other.lookup(rev) for rev in opts['rev']]
+        else:
+            error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
+            raise util.Abort(error)
+    incoming = repo.findincoming(other, heads=revs, force=opts["force"])
     if not incoming:
         ui.status(_("no changes found\n"))
         return
@@ -1564,7 +1571,12 @@
         fname = opts["bundle"]
         if fname or not other.local():
             # create a bundle (uncompressed if other repo is not local)
-            cg = other.changegroup(incoming, "incoming")
+            if revs is None:
+                cg = other.changegroup(incoming, "incoming")
+            else:
+                if 'changegroupsubset' not in other.capabilities:
+                    raise util.Abort(_("Partial incoming cannot be done because other repository doesn't support changegroupsubset."))
+                cg = other.changegroupsubset(incoming, revs, 'incoming')
             bundletype = other.local() and "HG10BZ" or "HG10UN"
             fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
             # keep written bundle?
@@ -1574,9 +1586,6 @@
                 # use the created uncompressed bundlerepo
                 other = bundlerepo.bundlerepository(ui, repo.root, fname)
 
-        revs = None
-        if opts['rev']:
-            revs = [other.lookup(rev) for rev in opts['rev']]
         o = other.changelog.nodesbetween(incoming, revs)[0]
         if opts['newest_first']:
             o.reverse()
--- a/tests/test-incoming-outgoing.out	Sun May 20 19:27:14 2007 +0200
+++ b/tests/test-incoming-outgoing.out	Fri Jun 01 19:45:05 2007 +0200
@@ -71,6 +71,7 @@
 summary:     3
 
 changeset:   4:1f3a964b6022
+tag:         tip
 user:        test
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     4