[PATCH 1 of 3] scmutil: factor out transaction name lookup in registersummarycallback()
Denis Laxalde
denis at laxalde.org
Wed Oct 4 16:52:43 UTC 2017
# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1506844364 -7200
# Sun Oct 01 09:52:44 2017 +0200
# Node ID 9fdbf99392971dc9ed2c711718c919397eedcf39
# Parent 2fd06499dc8e6a5a784b1334b925c289d7b54e4e
# Available At http://hg.logilab.org/users/dlaxalde/hg
# hg pull http://hg.logilab.org/users/dlaxalde/hg -r 9fdbf9939297
# EXP-Topic pull-info-transaction
scmutil: factor out transaction name lookup in registersummarycallback()
Add an inner txmatch function in registersummarycallback() factoring out the
logic to determine if the transaction matches a particular sources set. We'll
reuse this function to add some new report logic in the new changeset.
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1128,15 +1128,16 @@ class simplekeyvaluefile(object):
def registersummarycallback(repo, otr, txnname=''):
"""register a callback to issue a summary after the transaction is closed
"""
- for source in _reportobsoletedsource:
- if txnname.startswith(source):
- 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)
- break
+ def txmatch(sources):
+ return any(txnname.startswith(source) for source in sources)
+
+ if txmatch(_reportobsoletedsource):
+ 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)
More information about the Mercurial-devel
mailing list