mercurial/scmutil.py
changeset 33252 53b3a1968aa6
parent 33246 4d9458e06ef0
child 33330 ba43e5ee9c6d
--- a/mercurial/scmutil.py	Tue Jun 27 02:45:09 2017 +0200
+++ b/mercurial/scmutil.py	Wed Jun 28 03:54:19 2017 +0200
@@ -13,6 +13,7 @@
 import os
 import re
 import socket
+import weakref
 
 from .i18n import _
 from .node import (
@@ -22,11 +23,13 @@
     wdirrev,
 )
 
+from .i18n import _
 from . import (
     encoding,
     error,
     match as matchmod,
     obsolete,
+    obsutil,
     pathutil,
     phases,
     pycompat,
@@ -1059,3 +1062,15 @@
             lines.append("%s=%s\n" % (k, v))
         with self.vfs(self.path, mode='wb', atomictemp=True) as fp:
             fp.write(''.join(lines))
+
+def registersummarycallback(repo, otr):
+    """register a callback to issue a summary after the transaction is closed
+    """
+    reporef = weakref.ref(repo)
+    def reportsummary(tr):
+        """the actual callback reporting the summary"""
+        repo = reporef()
+        obsoleted = obsutil.getobsoleted(repo, tr)
+        if obsoleted:
+            repo.ui.status(_('obsoleted %i changesets\n') % len(obsoleted))
+    otr.addpostclose('00-txnreport', reportsummary)