[PATCH 2 of 3] patchbomb: support --outgoing and revsets

Matt Harbison matt_harbison at yahoo.com
Sun Jun 24 20:22:45 CDT 2012


Patrick Mezard <patrick <at> mezard.eu> writes:

> 
> # HG changeset patch
> # User Patrick Mezard <patrick <at> mezard.eu>
> # Date 1340552367 -7200
> # Branch stable
> # Node ID f50a558c29dbd087d4943a73b4a5f9dd86984470
> # Parent  01df43616027a869ed4e9e39f8b75cc7392d6e79
> patchbomb: support --outgoing and revsets
> 
> With --outgoing, input revisions were passed to getoutgoing() before
> being resolved.
> 
> diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
> --- a/hgext/patchbomb.py
> +++ b/hgext/patchbomb.py
> @@ -274,7 +274,7 @@
>          dest, branches = hg.parseurl(dest)
>          revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
>          if revs:
> -            revs = [repo.lookup(rev) for rev in revs]
> +            revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]

This is probably well beyond the scope of what you are trying to do, but why not
make addbranchrevs return revs as a revset, and then the 'if revs:' part can go
away?  It would also let several more commands accept revsets in the process.

I my case, I was trying to get hg._outgoing() to handle revsets.  Making the
above change worked for each of outgoing, incoming and push, but died in pull
when it takes the 'if checkout:' branch.  This edit let me take the 'if revs'
conditional out of hg._incoming() completely.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -23,6 +23,9 @@

 def addbranchrevs(lrepo, repo, branches, revs):
     hashbranch, branches = branches
+
+    revs = [repo.lookup(rev) for rev in scmutil.revrange(repo, revs)]
+
     if not hashbranch and not branches:
         return revs or None, revs and revs[0] or None
     revs = revs and list(revs) or []

(I assume outgoing and push would work the same by taking out the same
conditional.)  Since that seemed way too easy, I figured I'd better stop and ask
first in case it was by design, but I didn't get any further than making a table
of all of the use cases of addbranchrevs.  (And probably won't for the
foreseeable future.)  Some of those callers were revset aware by adding the code
you did above, others didn't handle revsets at all.

In any event, switching all of those callers is probably a fairly big project,
and I don't have a problem with how you did this.  It just seemed like an
opportune time to ask.

--Matt



More information about the Mercurial-devel mailing list