patchbomb: rewrite getoutgoing() with revsets
authorPatrick Mezard <patrick@mezard.eu>
Sun, 24 Jun 2012 18:11:52 +0200
changeset 17178 8308f6284640
parent 17177 ef507130fc92
child 17179 0849d725e2f9
patchbomb: rewrite getoutgoing() with revsets Another version could have returned a revset expression from getoutgoing(), but we do not know how many times it will be resolved, so better do it once explicitely.
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Sun Jun 24 17:39:27 2012 +0200
+++ b/hgext/patchbomb.py	Sun Jun 24 18:11:52 2012 +0200
@@ -48,7 +48,7 @@
 import os, errno, socket, tempfile, cStringIO
 import email.MIMEMultipart, email.MIMEBase
 import email.Utils, email.Encoders, email.Generator
-from mercurial import cmdutil, commands, hg, mail, patch, util, discovery
+from mercurial import cmdutil, commands, hg, mail, patch, util
 from mercurial import scmutil
 from mercurial.i18n import _
 from mercurial.node import bin
@@ -273,20 +273,18 @@
 
     def getoutgoing(dest, revs):
         '''Return the revisions present locally but not in dest'''
-        dest = ui.expandpath(dest or 'default-push', dest or 'default')
-        dest, branches = hg.parseurl(dest)
-        revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
-        if revs:
-            revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
-        other = hg.peer(repo, opts, dest)
-        ui.status(_('comparing with %s\n') % util.hidepassword(dest))
-        repo.ui.pushbuffer()
-        outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs)
-        repo.ui.popbuffer()
-        if not outgoing.missing:
+        url = ui.expandpath(dest or 'default-push', dest or 'default')
+        url = hg.parseurl(url)[0]
+        ui.status(_('comparing with %s\n') % util.hidepassword(url))
+
+        revs = [r for r in scmutil.revrange(repo, revs) if r >= 0]
+        if not revs:
+            revs = [len(repo) - 1]
+        revs = repo.revs('outgoing(%s) and ::%ld', dest or '', revs)
+        if not revs:
             ui.status(_("no changes found\n"))
             return []
-        return [str(repo.changelog.rev(r)) for r in outgoing.missing]
+        return [str(r) for r in revs]
 
     def getpatches(revs):
         for r in scmutil.revrange(repo, revs):