changeset 13631:29c800ee54cf stable

graphlog: give meaningful error if more than one file is given
author Klaus Koch <kuk42@gmx.net>
date Sun, 13 Mar 2011 15:04:13 +0100
parents 71a96f6c205d
children 33a33f19aad2
files hgext/graphlog.py tests/test-glog.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/graphlog.py	Sun Mar 13 14:36:47 2011 +0100
+++ b/hgext/graphlog.py	Sun Mar 13 15:04:13 2011 +0100
@@ -319,7 +319,11 @@
     '''wrap the command'''
     def graph(orig, *args, **kwargs):
         if kwargs['graph']:
-            return wrapfn(*args, **kwargs)
+            try:
+                return wrapfn(*args, **kwargs)
+            except TypeError, e:
+                if len(args) > wrapfn.func_code.co_argcount:
+                    raise util.Abort(_('--graph option allows at most one file'))
         return orig(*args, **kwargs)
     entry = extensions.wrapcommand(table, cmd, graph)
     entry[1].append(('G', 'graph', None, _("show the revision DAG")))
--- a/tests/test-glog.t	Sun Mar 13 14:36:47 2011 +0100
+++ b/tests/test-glog.t	Sun Mar 13 15:04:13 2011 +0100
@@ -686,6 +686,11 @@
   show revision history alongside an ASCII revision graph
   [255]
 
+Only one file is allowed:
+  $ hg log -G foo bar
+  abort: --graph option allows at most one file
+  [255]
+
 Empty revision range - display nothing:
   $ hg glog -r 1..0