[PATCH 3 of 3] patchbomb: rewrite getoutgoing() with revsets

Patrick Mezard patrick at mezard.eu
Sun Jun 24 11:34:31 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1340554312 -7200
# Branch stable
# Node ID 45a78418e234a9759733fb68dc1b7299587d9e1f
# Parent  f50a558c29dbd087d4943a73b4a5f9dd86984470
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.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -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
@@ -270,20 +270,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):


More information about the Mercurial-devel mailing list