diff mercurial/sparse.py @ 33355:9087f9997f42

sparse: move printing of sparse config changes function into core As part of the port, all arguments now have default values of 0. Strings are now also given the i18n treatment.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 08 Jul 2017 13:34:19 -0700
parents 4695f1829045
children ccb3e5399921
line wrap: on
line diff
--- a/mercurial/sparse.py	Sat Jul 08 13:19:38 2017 -0700
+++ b/mercurial/sparse.py	Sat Jul 08 13:34:19 2017 -0700
@@ -512,3 +512,26 @@
         oldmatch = matcher(repo)
         writeconfig(repo, set(), set(), profiles)
         refreshwdir(repo, oldstatus, oldmatch, force=force)
+
+def printchanges(ui, opts, profilecount=0, includecount=0, excludecount=0,
+                 added=0, dropped=0, conflicting=0):
+    """Print output summarizing sparse config changes."""
+    with ui.formatter('sparse', opts) as fm:
+        fm.startitem()
+        fm.condwrite(ui.verbose, 'profiles_added', _('Profiles changed: %d\n'),
+                     profilecount)
+        fm.condwrite(ui.verbose, 'include_rules_added',
+                     _('Include rules changed: %d\n'), includecount)
+        fm.condwrite(ui.verbose, 'exclude_rules_added',
+                     _('Exclude rules changed: %d\n'), excludecount)
+
+        # In 'plain' verbose mode, mergemod.applyupdates already outputs what
+        # files are added or removed outside of the templating formatter
+        # framework. No point in repeating ourselves in that case.
+        if not fm.isplain():
+            fm.condwrite(ui.verbose, 'files_added', _('Files added: %d\n'),
+                         added)
+            fm.condwrite(ui.verbose, 'files_dropped', _('Files dropped: %d\n'),
+                         dropped)
+            fm.condwrite(ui.verbose, 'files_conflicting',
+                         _('Files conflicting: %d\n'), conflicting)