# HG changeset patch # User Pierre-Yves David # Date 1343926335 -7200 # Node ID 4c1997e41d18893695364e4a157d173f7e096950 # Parent 9fcbe7c47939984e7829559655c1ca7ce18ab680# Parent 598ff1df3b928bc0fd7e259ffd00f30cac4a44f5 merge diff -r 9fcbe7c47939 -r 4c1997e41d18 hgext/evolve.py --- a/hgext/evolve.py Tue Jul 31 12:47:56 2012 +0200 +++ b/hgext/evolve.py Thu Aug 02 18:52:15 2012 +0200 @@ -413,57 +413,63 @@ try: wlock = repo.wlock() try: - if old.phase() == phases.public: - raise util.Abort(_("can not rewrite immutable changeset %s") - % old) - oldphase = old.phase() - # commit current changes as update - # code copied from commands.commit to avoid noisy messages - ciopts = dict(opts) - ciopts.pop('message', None) - ciopts.pop('logfile', None) - ciopts['message'] = opts.get('note') or ('amends %s' % old.hex()) - e = cmdutil.commiteditor - def commitfunc(ui, repo, message, match, opts): - return repo.commit(message, opts.get('user'), opts.get('date'), - match, editor=e) - revcount = len(repo) - tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts) - if len(repo) == revcount: - # No revision created - tempid = None + tr = repo.transaction('amend') + try: + if old.phase() == phases.public: + raise util.Abort(_("can not rewrite immutable changeset %s") + % old) + oldphase = old.phase() + # commit current changes as update + # code copied from commands.commit to avoid noisy messages + ciopts = dict(opts) + ciopts.pop('message', None) + ciopts.pop('logfile', None) + ciopts['message'] = opts.get('note') or ('amends %s' % old.hex()) + e = cmdutil.commiteditor + def commitfunc(ui, repo, message, match, opts): + return repo.commit(message, opts.get('user'), opts.get('date'), + match, editor=e) + revcount = len(repo) + tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts) + if len(repo) == revcount: + # No revision created + tempid = None - # find all changesets to be considered updates - head = repo['.'] - updatenodes = set(repo.changelog.nodesbetween( - roots=[old.node()], heads=[head.node()])[0]) - updatenodes.remove(old.node()) - okoptions = ['message', 'logfile', 'edit', 'user'] - if not updatenodes: - for o in okoptions: - if opts.get(o): - break - else: - raise error.Abort(_('no updates found')) - updates = [repo[n] for n in updatenodes] + # find all changesets to be considered updates + head = repo['.'] + updatenodes = set(repo.changelog.nodesbetween( + roots=[old.node()], heads=[head.node()])[0]) + updatenodes.remove(old.node()) + okoptions = ['message', 'logfile', 'edit', 'user'] + if not updatenodes: + for o in okoptions: + if opts.get(o): + break + else: + raise error.Abort(_('no updates found')) + updates = [repo[n] for n in updatenodes] - # perform amend - if opts.get('edit'): - opts['force_editor'] = True - newid, created = rewrite(repo, old, updates, head, - [old.p1().node(), old.p2().node()], opts) - if created: - # reroute the working copy parent to the new changeset - phases.retractboundary(repo, oldphase, [newid]) - repo.dirstate.setparents(newid, node.nullid) - else: - # rewrite() recreated an existing revision, discard - # the intermediate revision if any. No need to update - # phases or parents. - if tempid is not None: - repo.addobsolete(node.nullid, tempid) - # XXX: need another message in collapse case. - raise error.Abort(_('no updates found')) + # perform amend + if opts.get('edit'): + opts['force_editor'] = True + newid, created = rewrite(repo, old, updates, head, + [old.p1().node(), old.p2().node()], opts) + if created: + # reroute the working copy parent to the new changeset + phases.retractboundary(repo, oldphase, [newid]) + repo.dirstate.setparents(newid, node.nullid) + else: + # rewrite() recreated an existing revision, discard + # the intermediate revision if any. No need to update + # phases or parents. + if tempid is not None: + repo.addobsolete(node.nullid, tempid) + # XXX: need another message in collapse case. + tr.close() + raise error.Abort(_('no updates found')) + tr.close() + finally: + tr.release() finally: wlock.release() finally: diff -r 9fcbe7c47939 -r 4c1997e41d18 hgext/obsolete.py --- a/hgext/obsolete.py Tue Jul 31 12:47:56 2012 +0200 +++ b/hgext/obsolete.py Thu Aug 02 18:52:15 2012 +0200 @@ -693,10 +693,18 @@ if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 o_journalfiles = repo._journalfiles o_writejournal = repo._writejournal + o_hook = repo.hook class obsoletingrepo(repo.__class__): + # workaround + def hook(self, name, throw=False, **args): + if 'pushkey' in name: + args.pop('new') + args.pop('old') + return o_hook(name, throw=False, **args) + ### Public method def obsoletedby(self, node): """return the set of node that make obsolete (obj)"""