[PATCH V2] churn: deprecate -t option in favour of -T

Jordi Gutiérrez Hermoso jordigh at octave.org
Tue Feb 24 20:25:05 UTC 2015


# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1424795827 18000
#      Tue Feb 24 11:37:07 2015 -0500
# Node ID f15891e7f658fbc0351589887760548cab2c41f8
# Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
churn: deprecate -t option in favour of -T

We use -T consistently elsewhere to refer to the --template option.
The old -t option is now renamed to --oldtemplate so that -t still
works. This has the benign side effect of introducing and immediately
deprecating a new long option.

We also test with both -t and -T options.

diff --git a/hgext/churn.py b/hgext/churn.py
--- a/hgext/churn.py
+++ b/hgext/churn.py
@@ -46,7 +46,7 @@ def countrate(ui, repo, amap, *pats, **o
             date = datetime.datetime(*time.gmtime(float(t) - tz)[:6])
             return date.strftime(opts['dateformat'])
     else:
-        tmpl = opts.get('template', '{author|email}')
+        tmpl = opts.get('oldtemplate') or opts.get('template')
         tmpl = maketemplater(ui, repo, tmpl)
         def getkey(ctx):
             ui.pushbuffer()
@@ -95,7 +95,9 @@ def countrate(ui, repo, amap, *pats, **o
      _('count rate for the specified revision or revset'), _('REV')),
     ('d', 'date', '',
      _('count rate for revisions matching date spec'), _('DATE')),
-    ('t', 'template', '{author|email}',
+    ('t', 'oldtemplate', '',
+     _('template to group changesets (DEPRECATED)'), _('TEMPLATE')),
+    ('T', 'template', '{author|email}',
      _('template to group changesets'), _('TEMPLATE')),
     ('f', 'dateformat', '',
      _('strftime-compatible format for grouping by date'), _('FORMAT')),
diff --git a/tests/test-churn.t b/tests/test-churn.t
--- a/tests/test-churn.t
+++ b/tests/test-churn.t
@@ -171,4 +171,27 @@ Test multibyte sequences in names
   El Ni\xc3\xb1o         1 *************** (esc)
   with space      1 ***************
 
+Test --template argument, with backwards compatiblity
+
+  $ hg churn -t '{author|user}'
+  user1      4 ***************************************************************
+  user3      3 ***********************************************
+  user2      2 ********************************
+  nino       1 ****************
+  with       1 ****************
+             0 
+  user4      0 
+  $ hg churn -T '{author|user}'
+  user1      4 ***************************************************************
+  user3      3 ***********************************************
+  user2      2 ********************************
+  nino       1 ****************
+  with       1 ****************
+             0 
+  user4      0 
+  $ hg churn -t 'alltogether'
+  alltogether     11 *********************************************************
+  $ hg churn -T 'alltogether'
+  alltogether     11 *********************************************************
+
   $ cd ..


More information about the Mercurial-devel mailing list