hgext/evolve.py
changeset 444 aedb6b8ace86
parent 443 3f8c11865ed2
child 446 9d47474d2582
--- a/hgext/evolve.py	Tue Aug 07 18:05:41 2012 +0200
+++ b/hgext/evolve.py	Tue Aug 07 18:26:13 2012 +0200
@@ -159,13 +159,14 @@
             repo.ui.write_err(_('/!\\ use "hg up -C . ; hg stabilize --dry-run" /!\\\n'))
             raise
         oldbookmarks = repo.nodebookmarks(nodesrc)
+        obsolete = extensions.find('obsolete')
         if nodenew is not None:
             phases.retractboundary(repo, destphase, [nodenew])
-            repo.addobsolete(nodenew, nodesrc)
+            obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
             for book in oldbookmarks:
                 repo._bookmarks[book] = nodenew
         else:
-            repo.addobsolete(node.nullid, nodesrc)
+            obsolete.createmarkers(repo, [(repo[nodesrc], ())])
             # Behave like rebase, move bookmarks to dest
             for book in oldbookmarks:
                 repo._bookmarks[book] = dest.node()
@@ -355,25 +356,30 @@
     """
     wlock = repo.wlock()
     try:
-        new = set(noderange(repo, opts['new']))
-        targetnodes = set(noderange(repo, revs))
-        if not new:
-            new = [node.nullid]
-        for n in targetnodes:
-            if not repo[n].mutable():
-                ui.warn(_("cannot kill immutable changeset %s\n") % repo[n])
+        lock = repo.lock()
+        try:
+            new = set(noderange(repo, opts['new']))
+            targetnodes = set(noderange(repo, revs))
+            if new:
+                sucs = tuple(repo[n] for n in new)
             else:
-                for ne in new:
-                    repo.addobsolete(ne, n)
-        # update to an unkilled parent
-        wdp = repo['.']
-        newnode = wdp
-        while newnode.obsolete():
-            newnode = newnode.parents()[0]
-        if newnode.node() != wdp.node():
-            commands.update(ui, repo, newnode.rev())
-            ui.status(_('working directory now at %s\n') % newnode)
+                sucs = ()
+            markers = []
+            for n in targetnodes:
+                markers.append((repo[n], sucs))
+            obsolete = extensions.find('obsolete')
+            obsolete.createmarkers(repo, markers)
 
+            # update to an unkilled parent
+            wdp = repo['.']
+            newnode = wdp
+            while newnode.obsolete():
+                newnode = newnode.parents()[0]
+            if newnode.node() != wdp.node():
+                commands.update(ui, repo, newnode.rev())
+                ui.status(_('working directory now at %s\n') % newnode)
+        finally:
+            lock.release()
     finally:
         wlock.release()
 
@@ -465,7 +471,8 @@
                     # the intermediate revision if any. No need to update
                     # phases or parents.
                     if tempid is not None:
-                        repo.addobsolete(node.nullid, tempid)
+                        obsolete = extensions.find('obsolete')
+                        obsolete.createmarkers(repo, [(repo[tempid], ())])
                     # XXX: need another message in collapse case.
                     tr.close()
                     raise error.Abort(_('no updates found'))
@@ -601,7 +608,8 @@
             if newid is None:
                 raise util.Abort(_('nothing to uncommit'))
             # Move local changes on filtered changeset
-            repo.addobsolete(newid, old.node())
+            obsolete = extensions.find('obsolete')
+            obsolete.createmarkers(repo, [(old, (repo[newid],))])
             phases.retractboundary(repo, oldphase, [newid])
             repo.dirstate.setparents(newid, node.nullid)
             _uncommitdirstate(repo, old, match)
@@ -624,9 +632,13 @@
         if not result: # commit successed
             new = repo['-1']
             oldbookmarks = []
+            obsolete = extensions.find('obsolete')
+            markers = []
             for old in obsoleted:
                 oldbookmarks.extend(repo.nodebookmarks(old.node()))
-                repo.addobsolete(new.node(), old.node())
+                markers.append((old, (new,)))
+            if markers:
+                obsolete.createmarkers(repo, markers)
             for book in oldbookmarks:
                 repo._bookmarks[book] = new.node()
             if oldbookmarks: