Mercurial > hg
comparison hgext/patchbomb.py @ 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 | d38d90ad5bbf |
comparison
equal
deleted
inserted
replaced
17177:ef507130fc92 | 17178:8308f6284640 |
---|---|
46 ''' | 46 ''' |
47 | 47 |
48 import os, errno, socket, tempfile, cStringIO | 48 import os, errno, socket, tempfile, cStringIO |
49 import email.MIMEMultipart, email.MIMEBase | 49 import email.MIMEMultipart, email.MIMEBase |
50 import email.Utils, email.Encoders, email.Generator | 50 import email.Utils, email.Encoders, email.Generator |
51 from mercurial import cmdutil, commands, hg, mail, patch, util, discovery | 51 from mercurial import cmdutil, commands, hg, mail, patch, util |
52 from mercurial import scmutil | 52 from mercurial import scmutil |
53 from mercurial.i18n import _ | 53 from mercurial.i18n import _ |
54 from mercurial.node import bin | 54 from mercurial.node import bin |
55 | 55 |
56 cmdtable = {} | 56 cmdtable = {} |
271 # internal option used by pbranches | 271 # internal option used by pbranches |
272 patches = opts.get('patches') | 272 patches = opts.get('patches') |
273 | 273 |
274 def getoutgoing(dest, revs): | 274 def getoutgoing(dest, revs): |
275 '''Return the revisions present locally but not in dest''' | 275 '''Return the revisions present locally but not in dest''' |
276 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 276 url = ui.expandpath(dest or 'default-push', dest or 'default') |
277 dest, branches = hg.parseurl(dest) | 277 url = hg.parseurl(url)[0] |
278 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) | 278 ui.status(_('comparing with %s\n') % util.hidepassword(url)) |
279 if revs: | 279 |
280 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] | 280 revs = [r for r in scmutil.revrange(repo, revs) if r >= 0] |
281 other = hg.peer(repo, opts, dest) | 281 if not revs: |
282 ui.status(_('comparing with %s\n') % util.hidepassword(dest)) | 282 revs = [len(repo) - 1] |
283 repo.ui.pushbuffer() | 283 revs = repo.revs('outgoing(%s) and ::%ld', dest or '', revs) |
284 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) | 284 if not revs: |
285 repo.ui.popbuffer() | |
286 if not outgoing.missing: | |
287 ui.status(_("no changes found\n")) | 285 ui.status(_("no changes found\n")) |
288 return [] | 286 return [] |
289 return [str(repo.changelog.rev(r)) for r in outgoing.missing] | 287 return [str(r) for r in revs] |
290 | 288 |
291 def getpatches(revs): | 289 def getpatches(revs): |
292 for r in scmutil.revrange(repo, revs): | 290 for r in scmutil.revrange(repo, revs): |
293 output = cStringIO.StringIO() | 291 output = cStringIO.StringIO() |
294 cmdutil.export(repo, [r], fp=output, | 292 cmdutil.export(repo, [r], fp=output, |