##// END OF EJS Templates
log: add bookmark option to "hg log"...
Sebastien Boisvert -
r46512:0aa118f1 default
parent child Browse files
Show More
@@ -0,0 +1,127 b''
1 Test 'hg log' with a bookmark
2
3
4 Create the repository
5
6 $ hg init Test-D8973
7 $ cd Test-D8973
8 $ echo "bar" > foo.txt
9 $ hg add foo.txt
10 $ hg commit -m "Add foo in 'default'"
11
12
13 Add a bookmark for topic X
14
15 $ hg branch -f sebhtml
16 marked working directory as branch sebhtml
17 (branches are permanent and global, did you want a bookmark?)
18
19 $ hg bookmark sebhtml/99991-topic-X
20 $ hg up sebhtml/99991-topic-X
21 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
22
23 $ echo "X" > x.txt
24 $ hg add x.txt
25 $ hg commit -m "Add x.txt in 'sebhtml/99991-topic-X'"
26
27 $ hg log -B sebhtml/99991-topic-X
28 changeset: 1:29f39dea9bf9
29 branch: sebhtml
30 bookmark: sebhtml/99991-topic-X
31 tag: tip
32 user: test
33 date: Thu Jan 01 00:00:00 1970 +0000
34 summary: Add x.txt in 'sebhtml/99991-topic-X'
35
36
37 Add a bookmark for topic Y
38
39 $ hg update default
40 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
41 (leaving bookmark sebhtml/99991-topic-X)
42
43 $ echo "Y" > y.txt
44 $ hg add y.txt
45 $ hg branch -f sebhtml
46 marked working directory as branch sebhtml
47 $ hg bookmark sebhtml/99992-topic-Y
48 $ hg up sebhtml/99992-topic-Y
49 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 $ hg commit -m "Add y.txt in 'sebhtml/99992-topic-Y'"
51 created new head
52
53 $ hg log -B sebhtml/99992-topic-Y
54 changeset: 2:11df7969cf8d
55 branch: sebhtml
56 bookmark: sebhtml/99992-topic-Y
57 tag: tip
58 parent: 0:eaea25376a59
59 user: test
60 date: Thu Jan 01 00:00:00 1970 +0000
61 summary: Add y.txt in 'sebhtml/99992-topic-Y'
62
63
64 The log of topic Y does not interfere with the log of topic X
65
66 $ hg log -B sebhtml/99991-topic-X
67 changeset: 1:29f39dea9bf9
68 branch: sebhtml
69 bookmark: sebhtml/99991-topic-X
70 user: test
71 date: Thu Jan 01 00:00:00 1970 +0000
72 summary: Add x.txt in 'sebhtml/99991-topic-X'
73
74
75 Merge topics Y and X in the default branch
76
77 $ hg update default
78 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
79 (leaving bookmark sebhtml/99992-topic-Y)
80
81 $ hg bookmark
82 sebhtml/99991-topic-X 1:29f39dea9bf9
83 sebhtml/99992-topic-Y 2:11df7969cf8d
84
85 $ hg merge sebhtml/99992-topic-Y
86 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 (branch merge, don't forget to commit)
88
89 $ hg commit -m "Merge branch 'sebhtml/99992-topic-Y' into 'default'"
90
91 $ hg update default
92 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
93
94 $ hg merge sebhtml/99991-topic-X
95 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
96 (branch merge, don't forget to commit)
97
98 $ hg commit -m "Merge branch 'sebhtml/99991-topic-X' into 'default'"
99
100
101 Check the log of topic X, topic Y, and default branch
102
103 $ hg log -B sebhtml/99992-topic-Y
104
105 $ hg log -B sebhtml/99991-topic-X
106
107 $ hg log -b default
108 changeset: 4:c26ba8c1e1cb
109 tag: tip
110 parent: 3:2189f3fb90d6
111 parent: 1:29f39dea9bf9
112 user: test
113 date: Thu Jan 01 00:00:00 1970 +0000
114 summary: Merge branch 'sebhtml/99991-topic-X' into 'default'
115
116 changeset: 3:2189f3fb90d6
117 parent: 0:eaea25376a59
118 parent: 2:11df7969cf8d
119 user: test
120 date: Thu Jan 01 00:00:00 1970 +0000
121 summary: Merge branch 'sebhtml/99992-topic-Y' into 'default'
122
123 changeset: 0:eaea25376a59
124 user: test
125 date: Thu Jan 01 00:00:00 1970 +0000
126 summary: Add foo in 'default'
127
@@ -4456,6 +4456,13 b' def locate(ui, repo, *pats, **opts):'
4456 4456 _(b'BRANCH'),
4457 4457 ),
4458 4458 (
4459 b'B',
4460 b'bookmark',
4461 [],
4462 _(b"show changesets within the given bookmark"),
4463 _(b'BOOKMARK'),
4464 ),
4465 (
4459 4466 b'P',
4460 4467 b'prune',
4461 4468 [],
@@ -4613,14 +4620,19 b' def log(ui, repo, *pats, **opts):'
4613 4620 )
4614 4621
4615 4622 repo = scmutil.unhidehashlikerevs(repo, opts.get(b'rev'), b'nowarn')
4616 revs, differ = logcmdutil.getrevs(
4617 repo, logcmdutil.parseopts(ui, pats, opts)
4618 )
4623 walk_opts = logcmdutil.parseopts(ui, pats, opts)
4624 revs, differ = logcmdutil.getrevs(repo, walk_opts)
4619 4625 if linerange:
4620 4626 # TODO: should follow file history from logcmdutil._initialrevs(),
4621 4627 # then filter the result by logcmdutil._makerevset() and --limit
4622 4628 revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
4623 4629
4630 if opts.get(b'bookmark'):
4631 cmdutil.check_at_most_one_arg(opts, b'rev', b'bookmark')
4632 bookmarks = opts.get(b'bookmark')
4633 bookmark = bookmarks[0]
4634 revs, differ = logcmdutil.get_bookmark_revs(repo, bookmark, walk_opts)
4635
4624 4636 getcopies = None
4625 4637 if opts.get(b'copies'):
4626 4638 endrev = None
@@ -1024,6 +1024,26 b' def getrevs(repo, wopts):'
1024 1024 return revs, differ
1025 1025
1026 1026
1027 def get_bookmark_revs(repo, bookmark, walk_opts):
1028 # type: (Any, bookmark, walk_opts) -> Tuple[smartset.abstractsmartset, Optional[changesetdiffer]]
1029 """Return (revs, differ) where revs is a smartset
1030
1031 differ is a changesetdiffer with pre-configured file matcher.
1032 """
1033 revs, filematcher = makewalker(repo, walk_opts)
1034 if not revs:
1035 return revs, None
1036 differ = changesetdiffer()
1037 differ._makefilematcher = filematcher
1038
1039 if bookmark:
1040 if bookmark not in repo._bookmarks:
1041 raise error.Abort(_(b"bookmark '%s' not found") % bookmark)
1042 revs = scmutil.bookmarkrevs(repo, bookmark)
1043
1044 return revs, differ
1045
1046
1027 1047 def _parselinerangeopt(repo, opts):
1028 1048 """Parse --line-range log option and return a list of tuples (filename,
1029 1049 (fromline, toline)).
@@ -346,7 +346,7 b' Show all commands + options'
346 346 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
347 347 init: ssh, remotecmd, insecure
348 348 locate: rev, print0, fullpath, include, exclude
349 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
349 log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, bookmark, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
350 350 manifest: rev, all, template
351 351 merge: force, rev, preview, abort, tool
352 352 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
General Comments 0
You need to be logged in to leave comments. Login now