diff --git a/hgext/journal.py b/hgext/journal.py --- a/hgext/journal.py +++ b/hgext/journal.py @@ -485,7 +485,7 @@ displayname = "'%s'" % name ui.status(_("previous locations of %s:\n") % displayname) - limit = logcmdutil.getlimit(opts) + limit = logcmdutil.getlimit(ui, opts) entry = None ui.pager('journal') for count, entry in enumerate(repo.journal.filtered(name=name)): diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -190,6 +190,9 @@ coreconfigitem('commands', 'grep.all-files', default=False, ) +coreconfigitem('commands', 'log.limit', + default=None, +) coreconfigitem('commands', 'resolve.confirm', default=False, ) diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -438,6 +438,10 @@ ``commands`` ------------ +``log.limit`` + Limit the number of changesets to be displayed by log. + (default: None) + ``resolve.confirm`` Confirm before performing action if no filename is passed. (default: False) diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -966,7 +966,7 @@ return ret def display(other, chlist, displayer): - limit = logcmdutil.getlimit(opts) + limit = logcmdutil.getlimit(ui, opts) if opts.get('newest_first'): chlist.reverse() count = 0 @@ -1011,7 +1011,7 @@ ret = min(ret, sub.outgoing(ui, dest, opts)) return ret - limit = logcmdutil.getlimit(opts) + limit = logcmdutil.getlimit(ui, opts) o, other = _outgoing(ui, repo, dest, opts) if not o: cmdutil.outgoinghooks(ui, repo, other, opts, o) diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -38,9 +38,11 @@ stringutil, ) -def getlimit(opts): +def getlimit(ui, opts): """get the log limit according to option -l/--limit""" limit = opts.get('limit') + if not limit: + limit = ui.config('commands', 'log.limit') if limit: try: limit = int(limit) @@ -698,7 +700,7 @@ """ follow = opts.get('follow') or opts.get('follow_first') followfirst = opts.get('follow_first') - limit = getlimit(opts) + limit = getlimit(repo.ui, opts) revs = _initialrevs(repo, opts) if not revs: return smartset.baseset(), None @@ -905,7 +907,7 @@ % op.replace("_", "-")) def graphrevs(repo, nodes, opts): - limit = getlimit(opts) + limit = getlimit(repo.ui, opts) nodes.reverse() if limit is not None: nodes = nodes[:limit] diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -1826,6 +1826,54 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: add foo, related +Testing the `commands.log.limit` config option + + $ hg log --config commands.log.limit=4 + changeset: 10:4dae8563d2c5 + tag: tip + parent: 9:7b35701b003e + parent: 4:88176d361b69 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: Last merge, related + + changeset: 9:7b35701b003e + parent: 8:e5416ad8a855 + parent: 7:87fe3144dcfa + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: First merge, related + + changeset: 8:e5416ad8a855 + parent: 6:dc6c325fe5ee + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: change foo in branch, related + + changeset: 7:87fe3144dcfa + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: change foo, related + + $ hg log --config commands.log.limit=-2 + abort: limit must be positive + [255] + $ hg log --config commands.log.limit=0 + abort: limit must be positive + [255] + $ hg log --config commands.log.limit='abc' + abort: limit must be a positive integer + [255] + $ hg log --config commands.log.limit=1 + changeset: 10:4dae8563d2c5 + tag: tip + parent: 9:7b35701b003e + parent: 4:88176d361b69 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: Last merge, related + + $ cd .. Issue2383: hg log showing _less_ differences than hg diff