# HG changeset patch # User Thomas Arendsen Hein # Date 1204247731 -3600 # Node ID 01594b0c86e20845372527897b507073b50c995a # Parent a79d9408806fd4e3b771c9d47c91149bd14c93dc Add option -l/--limit to hg incoming and hg outgoing. diff -r a79d9408806f -r 01594b0c86e2 mercurial/commands.py --- a/mercurial/commands.py Fri Feb 29 01:51:23 2008 +0100 +++ b/mercurial/commands.py Fri Feb 29 02:15:31 2008 +0100 @@ -1561,6 +1561,7 @@ See pull for valid source format details. """ + limit = cmdutil.loglimit(opts) source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev']) cmdutil.setremoteconfig(ui, opts) @@ -1599,10 +1600,14 @@ if opts['newest_first']: o.reverse() displayer = cmdutil.show_changeset(ui, other, opts) + count = 0 for n in o: + if count >= limit: + break parents = [p for p in other.changelog.parents(n) if p != nullid] if opts['no_merges'] and len(parents) == 2: continue + count += 1 displayer.show(changenode=n) finally: if hasattr(other, 'close'): @@ -1869,6 +1874,7 @@ See pull for valid destination format details. """ + limit = cmdutil.loglimit(opts) dest, revs, checkout = hg.parseurl( ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev']) cmdutil.setremoteconfig(ui, opts) @@ -1885,10 +1891,14 @@ if opts['newest_first']: o.reverse() displayer = cmdutil.show_changeset(ui, repo, opts) + count = 0 for n in o: + if count >= limit: + break parents = [p for p in repo.changelog.parents(n) if p != nullid] if opts['no_merges'] and len(parents) == 2: continue + count += 1 displayer.show(changenode=n) def parents(ui, repo, file_=None, **opts): @@ -2975,6 +2985,7 @@ ('n', 'newest-first', None, _('show newest record first')), ('', 'bundle', '', _('file to store the bundles into')), ('p', 'patch', None, _('show patch')), + ('l', 'limit', '', _('limit number of changes displayed')), ('r', 'rev', [], _('a specific revision up to which you would like to pull')), ('', 'template', '', _('display with template')), ] + remoteopts, @@ -3032,6 +3043,7 @@ _('run even when remote repository is unrelated')), ('p', 'patch', None, _('show patch')), ('', 'style', '', _('display using template map file')), + ('l', 'limit', '', _('limit number of changes displayed')), ('r', 'rev', [], _('a specific revision you would like to push')), ('n', 'newest-first', None, _('show newest record first')), ('', 'template', '', _('display with template')), diff -r a79d9408806f -r 01594b0c86e2 tests/test-incoming-outgoing --- a/tests/test-incoming-outgoing Fri Feb 29 01:51:23 2008 +0100 +++ b/tests/test-incoming-outgoing Fri Feb 29 02:15:31 2008 +0100 @@ -19,6 +19,8 @@ # local incoming hg -R new incoming test hg -R new incoming -r 4 test +echo "% limit to 2 changesets" +hg -R new incoming -l 2 test # test with --bundle http_proxy= hg -R new incoming --bundle test.hg http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,' @@ -44,5 +46,7 @@ hg verify cd .. hg -R test-dev outgoing test +echo "% limit to 3 changesets" +hg -R test-dev outgoing -l 3 test http_proxy= hg -R test-dev outgoing http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,' http_proxy= hg -R test-dev outgoing -r 11 http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,' diff -r a79d9408806f -r 01594b0c86e2 tests/test-incoming-outgoing.out --- a/tests/test-incoming-outgoing.out Fri Feb 29 01:51:23 2008 +0100 +++ b/tests/test-incoming-outgoing.out Fri Feb 29 02:15:31 2008 +0100 @@ -151,6 +151,18 @@ date: Mon Jan 12 13:46:40 1970 +0000 summary: 4 +% limit to 2 changesets +comparing with test +changeset: 0:9cb21d99fe27 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 0 + +changeset: 1:d717f5dfad6a +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 1 + comparing with http://localhost/ changeset: 0:9cb21d99fe27 user: test @@ -301,6 +313,24 @@ date: Mon Jan 12 13:46:40 1970 +0000 summary: 13 +% limit to 3 changesets +comparing with test +searching for changes +changeset: 9:3741c3ad1096 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 9 + +changeset: 10:de4143c8d9a5 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 10 + +changeset: 11:0e1c188b9a7a +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 11 + comparing with http://localhost/ searching for changes changeset: 9:3741c3ad1096