hgext3rd/topic/__init__.py
changeset 2986 4746b92cc1f8
parent 2985 f63c97c01f92
child 2987 d59d6413bb68
child 2989 53246d237373
--- a/hgext3rd/topic/__init__.py	Tue Sep 26 12:29:15 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Sep 22 16:41:37 2017 +0200
@@ -54,6 +54,7 @@
 
 import re
 import time
+import weakref
 
 from mercurial.i18n import _
 from mercurial import (
@@ -311,6 +312,24 @@
                 peer.__class__ = topicpeer
             return peer
 
+        def transaction(self, *a, **k):
+            tr = super(topicrepo, self).transaction(*a, **k)
+
+            reporef = weakref.ref(self)
+
+            def currenttopicempty(tr):
+                # check active topic emptyness
+                ct = self.currenttopic
+                if not ct:
+                    return
+                repo = reporef()
+                empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
+                if empty:
+                    ui.status('active topic %r is now empty\n' % ct)
+
+            tr.addpostclose('signalcurrenttopicempty', currenttopicempty)
+            return tr
+
     repo.__class__ = topicrepo
     repo._topics = None
     if util.safehasattr(repo, 'names'):