# HG changeset patch # User Vadim Gelfer # Date 1140462401 28800 # Node ID f29857aaa053c6ca9500517bf53b07d7fca41729 # Parent 91c56c427171638597aaf8680884c30debc8b545 add -l,--limit to log command. diff -r 91c56c427171 -r f29857aaa053 doc/hg.1.txt --- a/doc/hg.1.txt Sat Feb 18 07:37:59 2006 -0800 +++ b/doc/hg.1.txt Mon Feb 20 11:06:41 2006 -0800 @@ -376,6 +376,7 @@ options: -I, --include include names matching the given patterns -X, --exclude exclude names matching the given patterns + -l, --limit print no more than this many changes -r, --rev show the specified revision or range -p, --patch show patch diff -r 91c56c427171 -r f29857aaa053 mercurial/commands.py --- a/mercurial/commands.py Sat Feb 18 07:37:59 2006 -0800 +++ b/mercurial/commands.py Mon Feb 20 11:06:41 2006 -0800 @@ -1599,7 +1599,19 @@ self.write(*args) def __getattr__(self, key): return getattr(self.ui, key) + changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, 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 + count = 0 + for st, rev, fns in changeiter: if st == 'window': du = dui(ui) @@ -1635,6 +1647,8 @@ dodiff(du, du, repo, prev, changenode, match=matchfn) du.write("\n\n") elif st == 'iter': + if count == limit: break + count += 1 for args in du.hunk[rev]: ui.write(*args) @@ -2446,6 +2460,7 @@ ('X', 'exclude', [], _('exclude names matching the given patterns')), ('b', 'branch', None, _('show branches')), ('k', 'keyword', [], _('search for a keyword')), + ('l', 'limit', '', _('limit number of changes displayed')), ('r', 'rev', [], _('show the specified revision or range')), ('M', 'no-merges', None, _('do not show merges')), ('m', 'only-merges', None, _('show only merges')),