# HG changeset patch # User Simon Sapin # Date 1641574354 -3600 # Node ID a27bdd1167613be20699e3b392e0b3f23e61d244 # Parent b0443b54160c4338f15d7986590422423d62d9f7 topic: wrap applychange from histedit to preserve topics This should fix https://bz.mercurial-scm.org/show_bug.cgi?id=6550 diff -r b0443b54160c -r a27bdd116761 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Jan 07 17:18:47 2022 +0100 +++ b/hgext3rd/topic/__init__.py Fri Jan 07 17:52:34 2022 +0100 @@ -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,19 @@ 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() + + if topic: + _changecurrenttopic(repo, topic) + + # revset predicates are automatically registered at loading via this symbol revsetpredicate = topicrevset.revsetpredicate diff -r b0443b54160c -r a27bdd116761 tests/test-issue6550.t --- a/tests/test-issue6550.t Fri Jan 07 17:18:47 2022 +0100 +++ b/tests/test-issue6550.t Fri Jan 07 17:52:34 2022 +0100 @@ -37,12 +37,12 @@ > pick 8a25a1549e46 B > EOF -Topics of B and C have incorrectly be set to topic1: +Topic of B and C is preserved $ hg glog - @ 4:3bf79df9dd38 [topic1] B (known-bad-output !) + @ 4:065a99df807b [topic2] B | - o 3:c51ea384abdd [topic1] C (known-bad-output !) + o 3:43dddca3e1d1 [topic2] C | o 0:c051488dac25 [topic1] A