# HG changeset patch # User Thomas Arendsen Hein # Date 2008-02-29 00:51:23 # Node ID a79d9408806fd4e3b771c9d47c91149bd14c93dc # Parent 81cbb5dfdec0b455ef82c6e3b18df5094f795809 Move finding/checking the log limit to cmdutil diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -89,6 +89,19 @@ def logmessage(opts): (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'): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1699,14 +1699,7 @@ def log(ui, repo, *pats, **opts): 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']: