--- a/mercurial/scmutil.py Sat Feb 29 12:56:37 2020 +0530
+++ b/mercurial/scmutil.py Sat Feb 29 12:58:13 2020 +0530
@@ -1900,8 +1900,11 @@
_reportstroubledchangesets = True
-def registersummarycallback(repo, otr, txnname=b''):
+def registersummarycallback(repo, otr, txnname=b'', as_validator=False):
"""register a callback to issue a summary after the transaction is closed
+
+ If as_validator is true, then the callbacks are registered as transaction
+ validators instead
"""
def txmatch(sources):
@@ -1927,7 +1930,10 @@
func(repo, tr)
newcat = b'%02i-txnreport' % len(categories)
- otr.addpostclose(newcat, wrapped)
+ if as_validator:
+ otr.addvalidator(newcat, wrapped)
+ else:
+ otr.addpostclose(newcat, wrapped)
categories.append(newcat)
return wrapped
@@ -1942,6 +1948,8 @@
if cgheads:
htext = _(b" (%+d heads)") % cgheads
msg = _(b"added %d changesets with %d changes to %d files%s\n")
+ if as_validator:
+ msg = _(b"adding %d changesets with %d changes to %d files%s\n")
assert repo is not None # help pytype
repo.ui.status(msg % (cgchangesets, cgrevisions, cgfiles, htext))
@@ -1954,7 +1962,10 @@
if newmarkers:
repo.ui.status(_(b'%i new obsolescence markers\n') % newmarkers)
if obsoleted:
- repo.ui.status(_(b'obsoleted %i changesets\n') % len(obsoleted))
+ msg = _(b'obsoleted %i changesets\n')
+ if as_validator:
+ msg = _(b'obsoleting %i changesets\n')
+ repo.ui.status(msg % len(obsoleted))
if obsolete.isenabled(
repo, obsolete.createmarkersopt
@@ -2057,9 +2068,10 @@
]
if not published:
return
- repo.ui.status(
- _(b'%d local changesets published\n') % len(published)
- )
+ msg = _(b'%d local changesets published\n')
+ if as_validator:
+ msg = _(b'%d local changesets will be published\n')
+ repo.ui.status(msg % len(published))
def getinstabilitymessage(delta, instability):