hgext/obsolete.py
changeset 320 63f267bd2176
parent 311 5eecfda0a5c7
child 321 41ba89f0caa5
--- a/hgext/obsolete.py	Wed Jun 27 03:53:44 2012 +0200
+++ b/hgext/obsolete.py	Wed Jun 27 12:30:16 2012 +0200
@@ -622,9 +622,31 @@
     repo._turn_extinct_secret()
     return orig(repo)
 
+def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs):
+    oldnode = old.node()
+    new = orig(ui, repo, commitfunc, old, *args, **kwargs)
+    if new != oldnode:
+        lock = repo.lock()
+        try:
+            newmarker = {
+                'subjects':  [new],
+                'object': oldnode,
+                'date':  util.makedate(),
+                'user': ui.username(),
+                'reason': 'commit --amend',
+                }
+            repo.obsoletestore.new(newmarker)
+            repo._clearobsoletecache()
+            repo._turn_extinct_secret()
+        finally:
+            lock.release()
+    return new
+
 def uisetup(ui):
     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
+    if util.safehasattr(cmdutil, 'amend'):
+        extensions.wrapfunction(cmdutil, 'amend', wrapcmdutilamend)
     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
     extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
     extensions.wrapfunction(phases, 'visibleheads', noextinctsvisibleheads)