changeset 411:4c1997e41d18

merge
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 02 Aug 2012 18:52:15 +0200
parents 9fcbe7c47939 (current diff) 598ff1df3b92 (diff)
children 7d30d1becfc4
files hgext/obsolete.py
diffstat 2 files changed, 63 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- 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 <node> obsolete (obj)"""