changeset 17178:8308f6284640

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.
author Patrick Mezard <patrick@mezard.eu>
date Sun, 24 Jun 2012 18:11:52 +0200
parents ef507130fc92
children 0849d725e2f9
files hgext/patchbomb.py
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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):