Make rebase set-obsolete relation
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 08 Sep 2011 12:08:33 +0200
changeset 42 eb6a06d7eae3
parent 41 99c131e97bb3
child 43 20fca307d9f0
Make rebase set-obsolete relation
obsolete.py
--- a/obsolete.py	Wed Sep 07 18:39:02 2011 +0200
+++ b/obsolete.py	Thu Sep 08 12:08:33 2011 +0200
@@ -10,6 +10,7 @@
 from mercurial import context
 from mercurial import revset
 from mercurial import scmutil
+from mercurial import extensions
 from mercurial.node import hex, bin
 
 # Patch changectx
@@ -45,6 +46,12 @@
 
 def extsetup(ui):
     revset.symbols["obsolete"] = revsetobsolete
+    try:
+        rebase = extensions.find('rebase')
+        if rebase:
+            extensions.wrapfunction(rebase, 'concludenode', concludenode)
+    except KeyError:
+        pass # rebase not found
 
 # New commands
 #############################
@@ -139,3 +146,13 @@
     repo.__class__ = obsoletingrepo
 
 
+### Other Extension compat
+############################
+
+def concludenode(orig, repo, rev, *args, **kwargs):
+    newrev = orig(repo, rev, *args, **kwargs)
+    oldnode = repo[rev].node()
+    newnode = repo[newrev].node()
+    repo.addobsolete(newnode, oldnode)
+    return newrev
+