Move finding/checking the log limit to cmdutil
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 29 Feb 2008 01:51:23 +0100
changeset 6190 a79d9408806f
parent 6189 81cbb5dfdec0
child 6191 01594b0c86e2
Move finding/checking the log limit to cmdutil
mercurial/cmdutil.py
mercurial/commands.py
--- a/mercurial/cmdutil.py	Fri Feb 29 01:25:31 2008 +0100
+++ b/mercurial/cmdutil.py	Fri Feb 29 01:51:23 2008 +0100
@@ -89,6 +89,19 @@
                              (logfile, inst.strerror))
     return message
 
+def loglimit(opts):
+    """get the log limit according to option -l/--limit"""
+    limit = opts.get('limit')
+    if limit:
+        try:
+            limit = int(limit)
+        except ValueError:
+            raise util.Abort(_('limit must be a positive integer'))
+        if limit <= 0: raise util.Abort(_('limit must be positive'))
+    else:
+        limit = sys.maxint
+    return limit
+
 def setremoteconfig(ui, opts):
     "copy remote options to ui tree"
     if opts.get('ssh'):
--- a/mercurial/commands.py	Fri Feb 29 01:25:31 2008 +0100
+++ b/mercurial/commands.py	Fri Feb 29 01:51:23 2008 +0100
@@ -1699,14 +1699,7 @@
     get = util.cachefunc(lambda r: repo.changectx(r).changeset())
     changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
 
-    if opts['limit']:
-        try:
-            limit = int(opts['limit'])
-        except ValueError:
-            raise util.Abort(_('limit must be a positive integer'))
-        if limit <= 0: raise util.Abort(_('limit must be positive'))
-    else:
-        limit = sys.maxint
+    limit = cmdutil.loglimit(opts)
     count = 0
 
     if opts['copies'] and opts['rev']: