Submitter | Pierre-Yves David |
---|---|
Date | April 16, 2013, 7:20 p.m. |
Message ID | <137c34957e77b88f3026.1366140037@yamac.lan> |
Download | mbox | patch |
Permalink | /patch/1364/ |
State | Accepted, archived |
Delegated to: | Augie Fackler |
Headers | show |
Comments
Crewed, with extensive English tweaks to commit messages, a rebase, and the revert of one edit in patch 1 as suggested by mg. I pulled from your repo and used histedit for updates before pushing, so hopefully you'll get some obsolete marker goodness and can see what I changed easily. On Apr 16, 2013, at 3:20 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@logilab.fr> > # Date 1366139690 -7200 > # Node ID 137c34957e77b88f3026c406b3abf4f3b5bf7dd6 > # Parent 1315e6aa4ba9eeaf17125269d6218c2b1a21d2e9 > histedit: move outgoing processing in it own function > > Every piece of code extracted from the mail command is a win. We simplify > changeset determination in the process. Parent cease being a list before > becoming a node. We how have a root variable containing a node all the time. > > diff --git a/hgext/histedit.py b/hgext/histedit.py > --- a/hgext/histedit.py > +++ b/hgext/histedit.py > @@ -402,10 +402,33 @@ def message(ui, repo, ctx, ha, opts): > if oldctx.node() != newctx.node(): > return newctx, [(oldctx.node(), (new,))] > # We didn't make an edit, so just indicate no replaced nodes > return newctx, [] > > +def findoutgoing(ui, repo, remote=None, force=False, opts={}): > + """utility function to find the first outgoing changeset > + > + Used by initialisation code""" > + dest = ui.expandpath(remote or 'default-push', remote or 'default') > + dest, revs = hg.parseurl(dest, None)[:2] > + ui.status(_('comparing with %s\n') % util.hidepassword(dest)) > + > + revs, checkout = hg.addbranchrevs(repo, repo, revs, None) > + other = hg.peer(repo, opts, dest) > + > + if revs: > + revs = [repo.lookup(rev) for rev in revs] > + > + # hexlify nodes from outgoing, because we're going to parse > + # parent[0] using revsingle below, and if the binary hash > + # contains special revset characters like ":" the revset > + # parser can choke. > + outgoing = discovery.findcommonoutgoing(repo, other, [], force=force) > + if not outgoing.missing: > + raise util.Abort(_('no outgoing ancestors')) > + return outgoing.missing[0] > + > actiontable = {'p': pick, > 'pick': pick, > 'e': edit, > 'edit': edit, > 'f': fold, > @@ -464,37 +487,15 @@ def histedit(ui, repo, *freeargs, **opts > raise util.Abort(_('no revisions allowed with --outgoing')) > if len(freeargs) > 1: > raise util.Abort( > _('only one repo argument allowed with --outgoing')) > else: > - parent = list(freeargs) + opts.get('rev', []) > - if len(parent) != 1: > + revs.extend(freeargs) > + if len(revs) != 1: > raise util.Abort( > _('histedit requires exactly one parent revision')) > > - if opts.get('outgoing'): > - if freeargs: > - parent = freeargs[0] > - > - dest = ui.expandpath(parent or 'default-push', parent or 'default') > - dest, revs = hg.parseurl(dest, None)[:2] > - ui.status(_('comparing with %s\n') % util.hidepassword(dest)) > - > - revs, checkout = hg.addbranchrevs(repo, repo, revs, None) > - other = hg.peer(repo, opts, dest) > - > - if revs: > - revs = [repo.lookup(rev) for rev in revs] > - > - # hexlify nodes from outgoing, because we're going to parse > - # parent[0] using revsingle below, and if the binary hash > - # contains special revset characters like ":" the revset > - # parser can choke. > - parent = [node.hex(n) for n in discovery.findcommonoutgoing( > - repo, other, [], force=force).missing[0:1]] > - if not parent: > - raise util.Abort(_('no outgoing ancestors')) > > if goal == 'continue': > (parentctxnode, rules, keep, topmost, replacements) = readstate(repo) > currentparent, wantnull = repo.dirstate.parents() > parentctx = repo[parentctxnode] > @@ -511,24 +512,31 @@ def histedit(ui, repo, *freeargs, **opts > return > else: > cmdutil.bailifchanged(repo) > > topmost, empty = repo.dirstate.parents() > - > - parent = scmutil.revsingle(repo, parent[0]).node() > + if outg: > + if freeargs: > + remote = freeargs[0] > + else: > + remote = None > + root = findoutgoing(ui, repo, remote, force, opts) > + else: > + root = revs[0] > + root = scmutil.revsingle(repo, root).node() > > keep = opts.get('keep', False) > - revs = between(repo, parent, topmost, keep) > + revs = between(repo, root, topmost, keep) > if not revs: > raise util.Abort(_('%s is not an ancestor of working directory') % > - node.short(parent)) > + node.short(root)) > > ctxs = [repo[r] for r in revs] > if not rules: > rules = '\n'.join([makedesc(c) for c in ctxs]) > rules += '\n\n' > - rules += editcomment % (node.short(parent), node.short(topmost)) > + rules += editcomment % (node.short(root), node.short(topmost)) > rules = ui.edit(rules, ui.username()) > # Save edit rules in .hg/histedit-last-edit.txt in case > # the user needs to ask for help after something > # surprising happens. > f = open(repo.join('histedit-last-edit.txt'), 'w') > @@ -543,11 +551,11 @@ def histedit(ui, repo, *freeargs, **opts > f.close() > rules = [l for l in (r.strip() for r in rules.splitlines()) > if l and not l[0] == '#'] > rules = verifyrules(rules, repo, ctxs) > > - parentctx = repo[parent].parents()[0] > + parentctx = repo[root].parents()[0] > keep = opts.get('keep', False) > replacements = [] > > > while rules:
On Tue, Apr 16, 2013 at 11:26:25PM -0400, Augie Fackler wrote: > I pulled from your repo and used histedit for updates before pushing, so > hopefully you'll get some obsolete marker goodness and can see what I changed > easily. yoohoo. You save me some minutes of manual obsolescence marking.
On Apr 17, 2013 3:20 AM, "Pierre-Yves David" <pierre-yves.david@logilab.fr> wrote: > > On Tue, Apr 16, 2013 at 11:26:25PM -0400, Augie Fackler wrote: > > I pulled from your repo and used histedit for updates before pushing, so > > hopefully you'll get some obsolete marker goodness and can see what I changed > > easily. > > yoohoo. You save me some minutes of manual obsolescence marking. I kind of regret pushing them. The push to crew was still trickling markers out after 15 minutes and I gave up and slept. > > > -- > Pierre-Yves David > > http://www.logilab.fr/ > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > > iEYEARECAAYFAlFuTUwACgkQElczi7p/bN9P8wCdFE/rmD2sc+aea3c2PZXSCqh4 > IdUAniL6DFtn7g1pACdsSIj2+rsRmBtM > =RlgL > -----END PGP SIGNATURE----- >
Patch
diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -402,10 +402,33 @@ def message(ui, repo, ctx, ha, opts): if oldctx.node() != newctx.node(): return newctx, [(oldctx.node(), (new,))] # We didn't make an edit, so just indicate no replaced nodes return newctx, [] +def findoutgoing(ui, repo, remote=None, force=False, opts={}): + """utility function to find the first outgoing changeset + + Used by initialisation code""" + dest = ui.expandpath(remote or 'default-push', remote or 'default') + dest, revs = hg.parseurl(dest, None)[:2] + ui.status(_('comparing with %s\n') % util.hidepassword(dest)) + + revs, checkout = hg.addbranchrevs(repo, repo, revs, None) + other = hg.peer(repo, opts, dest) + + if revs: + revs = [repo.lookup(rev) for rev in revs] + + # hexlify nodes from outgoing, because we're going to parse + # parent[0] using revsingle below, and if the binary hash + # contains special revset characters like ":" the revset + # parser can choke. + outgoing = discovery.findcommonoutgoing(repo, other, [], force=force) + if not outgoing.missing: + raise util.Abort(_('no outgoing ancestors')) + return outgoing.missing[0] + actiontable = {'p': pick, 'pick': pick, 'e': edit, 'edit': edit, 'f': fold, @@ -464,37 +487,15 @@ def histedit(ui, repo, *freeargs, **opts raise util.Abort(_('no revisions allowed with --outgoing')) if len(freeargs) > 1: raise util.Abort( _('only one repo argument allowed with --outgoing')) else: - parent = list(freeargs) + opts.get('rev', []) - if len(parent) != 1: + revs.extend(freeargs) + if len(revs) != 1: raise util.Abort( _('histedit requires exactly one parent revision')) - if opts.get('outgoing'): - if freeargs: - parent = freeargs[0] - - dest = ui.expandpath(parent or 'default-push', parent or 'default') - dest, revs = hg.parseurl(dest, None)[:2] - ui.status(_('comparing with %s\n') % util.hidepassword(dest)) - - revs, checkout = hg.addbranchrevs(repo, repo, revs, None) - other = hg.peer(repo, opts, dest) - - if revs: - revs = [repo.lookup(rev) for rev in revs] - - # hexlify nodes from outgoing, because we're going to parse - # parent[0] using revsingle below, and if the binary hash - # contains special revset characters like ":" the revset - # parser can choke. - parent = [node.hex(n) for n in discovery.findcommonoutgoing( - repo, other, [], force=force).missing[0:1]] - if not parent: - raise util.Abort(_('no outgoing ancestors')) if goal == 'continue': (parentctxnode, rules, keep, topmost, replacements) = readstate(repo) currentparent, wantnull = repo.dirstate.parents() parentctx = repo[parentctxnode] @@ -511,24 +512,31 @@ def histedit(ui, repo, *freeargs, **opts return else: cmdutil.bailifchanged(repo) topmost, empty = repo.dirstate.parents() - - parent = scmutil.revsingle(repo, parent[0]).node() + if outg: + if freeargs: + remote = freeargs[0] + else: + remote = None + root = findoutgoing(ui, repo, remote, force, opts) + else: + root = revs[0] + root = scmutil.revsingle(repo, root).node() keep = opts.get('keep', False) - revs = between(repo, parent, topmost, keep) + revs = between(repo, root, topmost, keep) if not revs: raise util.Abort(_('%s is not an ancestor of working directory') % - node.short(parent)) + node.short(root)) ctxs = [repo[r] for r in revs] if not rules: rules = '\n'.join([makedesc(c) for c in ctxs]) rules += '\n\n' - rules += editcomment % (node.short(parent), node.short(topmost)) + rules += editcomment % (node.short(root), node.short(topmost)) rules = ui.edit(rules, ui.username()) # Save edit rules in .hg/histedit-last-edit.txt in case # the user needs to ask for help after something # surprising happens. f = open(repo.join('histedit-last-edit.txt'), 'w') @@ -543,11 +551,11 @@ def histedit(ui, repo, *freeargs, **opts f.close() rules = [l for l in (r.strip() for r in rules.splitlines()) if l and not l[0] == '#'] rules = verifyrules(rules, repo, ctxs) - parentctx = repo[parent].parents()[0] + parentctx = repo[root].parents()[0] keep = opts.get('keep', False) replacements = [] while rules: