diff mercurial/scmutil.py @ 38204:eb9835014d20

transaction-summary: show phase changes statistics in pull/unbundle Upon pull or unbundle, we display a message with the number of changesets which phase became public. Noticeably, this new message would appear even if no new changeset were added (below the "no changes found" message), thus indicating that something actually happened to the local repository.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 24 May 2018 12:19:50 +0200
parents 46c2b19a1263
children 1e9c357d3ddf
line wrap: on
line diff
--- a/mercurial/scmutil.py	Mon May 28 01:36:34 2018 -0400
+++ b/mercurial/scmutil.py	Thu May 24 12:19:50 2018 +0200
@@ -1482,6 +1482,24 @@
                 revrange = '%s:%s' % (minrev, maxrev)
             repo.ui.status(_('new changesets %s\n') % revrange)
 
+        @reportsummary
+        def reportphasechanges(repo, tr):
+            """Report statistics of phase changes for changesets pre-existing
+            pull/unbundle.
+            """
+            newrevs = tr.changes.get('revs', xrange(0, 0))
+            phasetracking = tr.changes.get('phases', {})
+            if not phasetracking:
+                return
+            published = [
+                rev for rev, (old, new) in phasetracking.iteritems()
+                if new == phases.public and rev not in newrevs
+            ]
+            if not published:
+                return
+            repo.ui.status(_('%d changesets became public\n')
+                           % len(published))
+
 def nodesummaries(repo, nodes, maxnumnodes=4):
     if len(nodes) <= maxnumnodes or repo.ui.verbose:
         return ' '.join(short(h) for h in nodes)