log: add --stat for diffstat output
authorYuya Nishihara <yuya@tcha.org>
Thu, 01 Apr 2010 00:35:12 +0900
changeset 11061 51d0387523c6
parent 11060 e6df01776e08
child 11062 a2a6fd1064df
log: add --stat for diffstat output log --stat shows diffstat in place of patch output.
mercurial/cmdutil.py
mercurial/commands.py
tests/test-debugcomplete.out
tests/test-log
tests/test-log.out
--- a/mercurial/cmdutil.py	Sat Apr 03 11:58:16 2010 +1100
+++ b/mercurial/cmdutil.py	Thu Apr 01 00:35:12 2010 +0900
@@ -803,11 +803,11 @@
 
     def showpatch(self, node):
         if self.patch:
+            stat = self.diffopts.get('stat')
+            diffopts = patch.diffopts(self.ui, self.diffopts)
             prev = self.repo.changelog.parents(node)[0]
-            chunks = patch.diffui(self.repo, prev, node, match=self.patch,
-                                  opts=patch.diffopts(self.ui, self.diffopts))
-            for chunk, label in chunks:
-                self.ui.write(chunk, label=label)
+            diffordiffstat(self.ui, self.repo, diffopts, prev, node,
+                           match=self.patch, stat=stat)
             self.ui.write("\n")
 
     def _meaningful_parentrevs(self, log, rev):
@@ -939,7 +939,7 @@
     """
     # options
     patch = False
-    if opts.get('patch'):
+    if opts.get('patch') or opts.get('stat'):
         patch = matchfn or matchall(repo)
 
     tmpl = opts.get('template')
--- a/mercurial/commands.py	Sat Apr 03 11:58:16 2010 +1100
+++ b/mercurial/commands.py	Thu Apr 01 00:35:12 2010 +0900
@@ -3462,6 +3462,7 @@
     ('g', 'git', None, _('use git extended diff format')),
     ('l', 'limit', '', _('limit number of changes displayed')),
     ('M', 'no-merges', None, _('do not show merges')),
+    ('', 'stat', None, _('output diffstat-style summary of changes')),
 ] + templateopts
 
 diffopts = [
--- a/tests/test-debugcomplete.out	Sat Apr 03 11:58:16 2010 +1100
+++ b/tests/test-debugcomplete.out	Thu Apr 01 00:35:12 2010 +0900
@@ -171,7 +171,7 @@
 export: output, switch-parent, rev, text, git, nodates
 forget: include, exclude
 init: ssh, remotecmd
-log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, style, template, include, exclude
+log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
 merge: force, rev, preview
 pull: update, force, rev, branch, ssh, remotecmd
 push: force, rev, branch, ssh, remotecmd
@@ -210,10 +210,10 @@
 help: 
 identify: rev, num, id, branch, tags
 import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
-incoming: force, newest-first, bundle, rev, branch, patch, git, limit, no-merges, style, template, ssh, remotecmd
+incoming: force, newest-first, bundle, rev, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd
 locate: rev, print0, fullpath, include, exclude
 manifest: rev
-outgoing: force, rev, newest-first, branch, patch, git, limit, no-merges, style, template, ssh, remotecmd
+outgoing: force, rev, newest-first, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd
 parents: rev, style, template
 paths: 
 recover: 
--- a/tests/test-log	Sat Apr 03 11:58:16 2010 +1100
+++ b/tests/test-log	Thu Apr 01 00:35:12 2010 +0900
@@ -121,6 +121,9 @@
 echo '% log -p -l2 --color=always'
 hg --config extensions.color= log -p -l2 --color=always
 
+echo '% log -r tip --stat'
+hg log -r tip --stat
+
 cd ..
 
 hg init usertest
--- a/tests/test-log.out	Sat Apr 03 11:58:16 2010 +1100
+++ b/tests/test-log.out	Thu Apr 01 00:35:12 2010 +0900
@@ -306,6 +306,16 @@
 @@ -0,0 +1,1 @@
 +b2
 
+% log -r tip --stat
+changeset:   6:2404bbcab562
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:01 1970 +0000
+summary:     b1.1
+
+ b1 |  1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
 adding a
 adding b
 changeset:   0:29a4c94f1924