diff hgext3rd/topic/__init__.py @ 6146:74665d83fb3b

branching: merge stable into default
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 21 Feb 2022 18:26:25 +0300
parents 5d1bfde39b95
children 453302ef7f79
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Tue Feb 22 19:42:55 2022 +0300
+++ b/hgext3rd/topic/__init__.py	Mon Feb 21 18:26:25 2022 +0300
@@ -440,6 +440,15 @@
         except (KeyError, AttributeError):
             pass
 
+    try:
+        histedit = extensions.find(b'histedit')
+    except KeyError:
+        pass
+    else:
+        # Make histedit preserve topics of edited commits
+        extensions.wrapfunction(histedit.histeditaction, 'applychange',
+                                applychangewrap)
+
     server.setupserver(ui)
 
 def reposetup(ui, repo):
@@ -732,6 +741,17 @@
     return orig(cl, manifest, files, desc, transaction, p1, p2, user,
                 date=date, extra=extra, **kwargs)
 
+def applychangewrap(orig, self):
+    orig(self)
+    repo = self.repo
+    rulectx = repo[self.node]
+
+    topic = None
+    if util.safehasattr(rulectx, 'topic'):
+        topic = rulectx.topic()
+    _changecurrenttopic(repo, topic)
+
+
 # revset predicates are automatically registered at loading via this symbol
 revsetpredicate = topicrevset.revsetpredicate