# HG changeset patch # User Vadim Gelfer # Date 1140462429 28800 # Node ID 23012d48ae91786cfaf258c9f10ab72bd324bbed # Parent f29857aaa053c6ca9500517bf53b07d7fca41729# Parent a8f7791e36800346af1456926882077698b6842b merge with crew. diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -376,6 +376,7 @@ log [-r revision ...] [-p] [files]:: 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1611,7 +1611,19 @@ def log(ui, repo, *pats, **opts): 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) @@ -1647,6 +1659,8 @@ def log(ui, repo, *pats, **opts): 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) @@ -2462,6 +2476,7 @@ table = { ('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')),