# HG changeset patch # User Steve Losh # Date 2010-04-18 22:18:19 # Node ID 0d5f139b23c1bdac16399663f006c9dc147b6391 # Parent a156ce543a5b3a0f7f20a12af517da68b76c320b commands: Add 'hg log --branch' and deprecate 'hg log --only-branch' Switching to --branch makes log consistent with push/pull and make more sense given the actual behavior of the option (you can specify -b multiple times to include multiple branches). This change also adds some tests for 'hg log -b'. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2157,6 +2157,8 @@ def log(ui, repo, *pats, **opts): if opts["date"]: df = util.matchdate(opts["date"]) + opts['branch'] += opts.get('only_branch') + displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) def prep(ctx, fns): rev = ctx.rev() @@ -2166,7 +2168,7 @@ def log(ui, repo, *pats, **opts): return if opts.get('only_merges') and len(parents) != 2: return - if opts.get('only_branch') and ctx.branch() not in opts['only_branch']: + if opts.get('branch') and ctx.branch() not in opts['branch']: return if df and not df(ctx.date()[0]): return @@ -3739,8 +3741,10 @@ table = { ('', 'removed', None, _('include revisions where files were removed')), ('m', 'only-merges', None, _('show only merges')), ('u', 'user', [], _('revisions committed by user')), - ('b', 'only-branch', [], - _('show only changesets within the given named branch')), + ('', 'only-branch', [], + _('show only changesets within the given named branch (DEPRECATED)')), + ('b', 'branch', [], + _('show changesets within the given named branch')), ('P', 'prune', [], _('do not display revision or any of its ancestors')), ] + logopts + walkopts, diff --git a/tests/test-debugcomplete.out b/tests/test-debugcomplete.out --- a/tests/test-debugcomplete.out +++ b/tests/test-debugcomplete.out @@ -171,7 +171,7 @@ diff: rev, change, text, git, nodates, s export: output, switch-parent, rev, text, git, nodates forget: include, exclude init: ssh, remotecmd -log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, prune, patch, git, limit, no-merges, style, template, include, exclude +log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, style, template, include, exclude merge: force, rev, preview pull: update, force, rev, branch, ssh, remotecmd push: force, rev, branch, ssh, remotecmd diff --git a/tests/test-log b/tests/test-log --- a/tests/test-log +++ b/tests/test-log @@ -135,4 +135,34 @@ hg log -u "User One " hg log -u "user1" -u "user2" hg log -u "user3" +cd .. + +hg init branches +cd branches + +echo a > a +hg ci -A -m "commit on default" +hg branch test +echo b > b +hg ci -A -m "commit on test" + +hg up default +echo c > c +hg ci -A -m "commit on default" +hg up test +echo c > c +hg ci -A -m "commit on test" + +echo '% log -b default' +hg log -b default + +echo '% log -b test' +hg log -b test + +echo '% log -b dummy' +hg log -b dummy + +echo '% log -b default -b test' +hg log -b default -b test + exit 0 diff --git a/tests/test-log.out b/tests/test-log.out --- a/tests/test-log.out +++ b/tests/test-log.out @@ -324,3 +324,65 @@ user: User One