Introduce templateopts and logopts to reduce duplicate option definitions.
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 29 Feb 2008 02:45:12 +0100
changeset 6192 cd65a67aff31
parent 6191 01594b0c86e2
child 6193 2344da8eb9b4
Introduce templateopts and logopts to reduce duplicate option definitions.
hgext/children.py
hgext/graphlog.py
mercurial/commands.py
--- a/hgext/children.py	Fri Feb 29 02:15:31 2008 +0100
+++ b/hgext/children.py	Fri Feb 29 02:45:12 2008 +0100
@@ -8,6 +8,7 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from mercurial import cmdutil
+from mercurial.commands import templateopts
 from mercurial.i18n import _
 
 
@@ -35,7 +36,6 @@
     "children":
         (children,
          [('r', 'rev', '', _('show children of the specified rev')),
-          ('', 'style', '', _('display using template map file')),
-          ('', 'template', '', _('display with template'))],
+         ] + templateopts,
          _('hg children [-r REV] [FILE]')),
 }
--- a/hgext/graphlog.py	Fri Feb 29 02:15:31 2008 +0100
+++ b/hgext/graphlog.py	Fri Feb 29 02:45:12 2008 +0100
@@ -8,6 +8,7 @@
 import os
 import sys
 from mercurial.cmdutil import revrange, show_changeset
+from mercurial.commands import templateopts
 from mercurial.i18n import _
 from mercurial.node import nullid, nullrev
 from mercurial.util import Abort, canonpath
@@ -320,7 +321,6 @@
          [('l', 'limit', '', _('limit number of changes displayed')),
           ('p', 'patch', False, _('show patch')),
           ('r', 'rev', [], _('show the specified revision or range')),
-          ('', 'style', '', _('display using template map file')),
-          ('', 'template', '', _('display with template'))],
+         ] + templateopts,
          _('hg glog [OPTION]... [FILE]')),
 }
--- a/mercurial/commands.py	Fri Feb 29 02:15:31 2008 +0100
+++ b/mercurial/commands.py	Fri Feb 29 02:45:12 2008 +0100
@@ -2772,6 +2772,17 @@
     ('u', 'user', '', _('record user as committer')),
 ]
 
+templateopts = [
+    ('', 'style', '', _('display using template map file')),
+    ('', 'template', '', _('display with template')),
+]
+
+logopts = [
+    ('p', 'patch', None, _('show patch')),
+    ('l', 'limit', '', _('limit number of changes displayed')),
+    ('M', 'no-merges', None, _('do not show merges')),
+] + templateopts
+
 table = {
     "^add": (add, walkopts + dryrunopts, _('hg add [OPTION]... [FILE]...')),
     "addremove":
@@ -2948,9 +2959,8 @@
          _('hg grep [OPTION]... PATTERN [FILE]...')),
     "heads":
         (heads,
-         [('', 'style', '', _('display using template map file')),
-          ('r', 'rev', '', _('show only heads which are descendants of rev')),
-          ('', 'template', '', _('display with template'))],
+         [('r', 'rev', '', _('show only heads which are descendants of rev')),
+         ] + templateopts,
          _('hg heads [-r REV] [REV]...')),
     "help": (help_, [], _('hg help [COMMAND]')),
     "identify|id":
@@ -2978,17 +2988,12 @@
          _('hg import [OPTION]... PATCH...')),
     "incoming|in":
         (incoming,
-         [('M', 'no-merges', None, _('do not show merges')),
-          ('f', 'force', None,
+         [('f', 'force', None,
            _('run even when remote repository is unrelated')),
-          ('', 'style', '', _('display using template map file')),
           ('n', 'newest-first', None, _('show newest record first')),
           ('', 'bundle', '', _('file to store the bundles into')),
-          ('p', 'patch', None, _('show patch')),
-          ('l', 'limit', '', _('limit number of changes displayed')),
           ('r', 'rev', [], _('a specific revision up to which you would like to pull')),
-          ('', 'template', '', _('display with template')),
-         ] + remoteopts,
+         ] + logopts + remoteopts,
          _('hg incoming [-p] [-n] [-M] [-f] [-r REV]...'
            ' [--bundle FILENAME] [SOURCE]')),
     "^init":
@@ -3013,18 +3018,13 @@
           ('d', 'date', '', _('show revs matching date spec')),
           ('C', 'copies', None, _('show copied files')),
           ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
-          ('l', 'limit', '', _('limit number of changes displayed')),
           ('r', 'rev', [], _('show the specified revision or range')),
           ('', 'removed', None, _('include revs where files were removed')),
-          ('M', 'no-merges', None, _('do not show merges')),
-          ('', 'style', '', _('display using template map file')),
           ('m', 'only-merges', None, _('show only merges')),
           ('b', 'only-branch', [],
             _('show only changesets within the given named branch')),
-          ('p', 'patch', None, _('show patch')),
           ('P', 'prune', [], _('do not display revision or any of its ancestors')),
-          ('', 'template', '', _('display with template')),
-         ] + walkopts,
+         ] + logopts + walkopts,
          _('hg log [OPTION]... [FILE]')),
     "manifest":
         (manifest,
@@ -3038,22 +3038,16 @@
          _('hg merge [-f] [[-r] REV]')),
     "outgoing|out":
         (outgoing,
-         [('M', 'no-merges', None, _('do not show merges')),
-          ('f', 'force', None,
+         [('f', 'force', None,
            _('run even when remote repository is unrelated')),
-          ('p', 'patch', None, _('show patch')),
-          ('', 'style', '', _('display using template map file')),
-          ('l', 'limit', '', _('limit number of changes displayed')),
           ('r', 'rev', [], _('a specific revision you would like to push')),
           ('n', 'newest-first', None, _('show newest record first')),
-          ('', 'template', '', _('display with template')),
-         ] + remoteopts,
+         ] + logopts + remoteopts,
          _('hg outgoing [-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
     "^parents":
         (parents,
          [('r', 'rev', '', _('show parents from the specified rev')),
-          ('', 'style', '', _('display using template map file')),
-          ('', 'template', '', _('display with template'))],
+         ] + templateopts,
          _('hg parents [-r REV] [FILE]')),
     "paths": (paths, [], _('hg paths [NAME]')),
     "^pull":
@@ -3150,9 +3144,8 @@
     "tags": (tags, [], _('hg tags')),
     "tip":
         (tip,
-         [('', 'style', '', _('display using template map file')),
-          ('p', 'patch', None, _('show patch')),
-          ('', 'template', '', _('display with template'))],
+         [('p', 'patch', None, _('show patch')),
+         ] + templateopts,
          _('hg tip [-p]')),
     "unbundle":
         (unbundle,