[PATCH] commands: Add 'hg log --branch' and deprecate 'hg log --only-branch'
Steve Losh
steve at stevelosh.com
Sun Apr 18 17:19:07 CDT 2010
# HG changeset patch
# User Steve Losh <steve at stevelosh.com>
# Date 1271629099 14400
# Node ID 3e9dee04cab9fc58388ff87c588f37b1fd15d11f
# Parent 5f10634f9e68873eade54bc0a5408ee9e26b55d8
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
@@ -2150,30 +2150,32 @@
count = 0
endrev = None
if opts.get('copies') and opts.get('rev'):
endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
df = False
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()
parents = [p for p in repo.changelog.parentrevs(rev)
if p != nullrev]
if opts.get('no_merges') and len(parents) == 2:
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
if opts['user'] and not [k for k in opts['user'] if k in ctx.user()]:
return
if opts.get('keyword'):
for k in [kw.lower() for kw in opts['keyword']]:
if (k in ctx.user().lower() or
k in ctx.description().lower() or
k in " ".join(ctx.files()).lower()):
@@ -3732,22 +3734,24 @@
' or file history across copies and renames')),
('', 'follow-first', None,
_('only follow the first parent of merge changesets')),
('d', 'date', '', _('show revisions matching date spec')),
('C', 'copies', None, _('show copied files')),
('k', 'keyword', [], _('do case-insensitive search for a keyword')),
('r', 'rev', [], _('show the specified revision or range')),
('', '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,
_('[OPTION]... [FILE]')),
"manifest":
(manifest,
[('r', 'rev', '', _('revision to display'))],
_('[-r REV]')),
"^merge":
(merge,
diff --git a/tests/test-log b/tests/test-log
--- a/tests/test-log
+++ b/tests/test-log
@@ -128,11 +128,41 @@
echo a > a
hg ci -A -m "a" -u "User One <user1 at example.org>"
echo b > b
hg ci -A -m "b" -u "User Two <user2 at example.org>"
hg log -u "User One <user1 at example.org>"
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
@@ -317,10 +317,72 @@
tag: tip
user: User Two <user2 at example.org>
date: Thu Jan 01 00:00:00 1970 +0000
summary: b
changeset: 0:29a4c94f1924
user: User One <user1 at example.org>
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
+adding a
+marked working directory as branch test
+adding b
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding c
+created new head
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding c
+% log -b default
+changeset: 2:c3a4f03cc9a7
+parent: 0:24427303d56f
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on default
+
+changeset: 0:24427303d56f
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on default
+
+% log -b test
+changeset: 3:f5d8de11c2e2
+branch: test
+tag: tip
+parent: 1:d32277701ccb
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on test
+
+changeset: 1:d32277701ccb
+branch: test
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on test
+
+% log -b dummy
+% log -b default -b test
+changeset: 3:f5d8de11c2e2
+branch: test
+tag: tip
+parent: 1:d32277701ccb
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on test
+
+changeset: 2:c3a4f03cc9a7
+parent: 0:24427303d56f
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on default
+
+changeset: 1:d32277701ccb
+branch: test
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on test
+
+changeset: 0:24427303d56f
+user: test
+date: Thu Jan 01 00:00:00 1970 +0000
+summary: commit on default
+
More information about the Mercurial-devel
mailing list