Show More
@@ -1,208 +1,211 b'' | |||||
1 | # Mercurial bookmark support code |
|
1 | # Mercurial bookmark support code | |
2 | # |
|
2 | # | |
3 | # Copyright 2008 David Soria Parra <dsp@php.net> |
|
3 | # Copyright 2008 David Soria Parra <dsp@php.net> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from mercurial.i18n import _ |
|
8 | from mercurial.i18n import _ | |
9 | from mercurial.node import hex |
|
9 | from mercurial.node import hex | |
10 | from mercurial import encoding, error, util |
|
10 | from mercurial import encoding, error, util | |
11 | import errno, os |
|
11 | import errno, os | |
12 |
|
12 | |||
13 | def valid(mark): |
|
13 | def valid(mark): | |
14 | for c in (':', '\0', '\n', '\r'): |
|
14 | for c in (':', '\0', '\n', '\r'): | |
15 | if c in mark: |
|
15 | if c in mark: | |
16 | return False |
|
16 | return False | |
17 | return True |
|
17 | return True | |
18 |
|
18 | |||
19 | def read(repo): |
|
19 | def read(repo): | |
20 | '''Parse .hg/bookmarks file and return a dictionary |
|
20 | '''Parse .hg/bookmarks file and return a dictionary | |
21 |
|
21 | |||
22 | Bookmarks are stored as {HASH}\\s{NAME}\\n (localtags format) values |
|
22 | Bookmarks are stored as {HASH}\\s{NAME}\\n (localtags format) values | |
23 | in the .hg/bookmarks file. |
|
23 | in the .hg/bookmarks file. | |
24 | Read the file and return a (name=>nodeid) dictionary |
|
24 | Read the file and return a (name=>nodeid) dictionary | |
25 | ''' |
|
25 | ''' | |
26 | bookmarks = {} |
|
26 | bookmarks = {} | |
27 | try: |
|
27 | try: | |
28 | for line in repo.opener('bookmarks'): |
|
28 | for line in repo.opener('bookmarks'): | |
|
29 | line = line.strip() | |||
|
30 | if ' ' not in line: | |||
|
31 | continue | |||
29 | sha, refspec = line.strip().split(' ', 1) |
|
32 | sha, refspec = line.strip().split(' ', 1) | |
30 | refspec = encoding.tolocal(refspec) |
|
33 | refspec = encoding.tolocal(refspec) | |
31 | try: |
|
34 | try: | |
32 | bookmarks[refspec] = repo.changelog.lookup(sha) |
|
35 | bookmarks[refspec] = repo.changelog.lookup(sha) | |
33 | except error.RepoLookupError: |
|
36 | except error.RepoLookupError: | |
34 | pass |
|
37 | pass | |
35 | except IOError, inst: |
|
38 | except IOError, inst: | |
36 | if inst.errno != errno.ENOENT: |
|
39 | if inst.errno != errno.ENOENT: | |
37 | raise |
|
40 | raise | |
38 | return bookmarks |
|
41 | return bookmarks | |
39 |
|
42 | |||
40 | def readcurrent(repo): |
|
43 | def readcurrent(repo): | |
41 | '''Get the current bookmark |
|
44 | '''Get the current bookmark | |
42 |
|
45 | |||
43 | If we use gittishsh branches we have a current bookmark that |
|
46 | If we use gittishsh branches we have a current bookmark that | |
44 | we are on. This function returns the name of the bookmark. It |
|
47 | we are on. This function returns the name of the bookmark. It | |
45 | is stored in .hg/bookmarks.current |
|
48 | is stored in .hg/bookmarks.current | |
46 | ''' |
|
49 | ''' | |
47 | mark = None |
|
50 | mark = None | |
48 | try: |
|
51 | try: | |
49 | file = repo.opener('bookmarks.current') |
|
52 | file = repo.opener('bookmarks.current') | |
50 | except IOError, inst: |
|
53 | except IOError, inst: | |
51 | if inst.errno != errno.ENOENT: |
|
54 | if inst.errno != errno.ENOENT: | |
52 | raise |
|
55 | raise | |
53 | return None |
|
56 | return None | |
54 | try: |
|
57 | try: | |
55 | # No readline() in posixfile_nt, reading everything is cheap |
|
58 | # No readline() in posixfile_nt, reading everything is cheap | |
56 | mark = encoding.tolocal((file.readlines() or [''])[0]) |
|
59 | mark = encoding.tolocal((file.readlines() or [''])[0]) | |
57 | if mark == '' or mark not in repo._bookmarks: |
|
60 | if mark == '' or mark not in repo._bookmarks: | |
58 | mark = None |
|
61 | mark = None | |
59 | finally: |
|
62 | finally: | |
60 | file.close() |
|
63 | file.close() | |
61 | return mark |
|
64 | return mark | |
62 |
|
65 | |||
63 | def write(repo): |
|
66 | def write(repo): | |
64 | '''Write bookmarks |
|
67 | '''Write bookmarks | |
65 |
|
68 | |||
66 | Write the given bookmark => hash dictionary to the .hg/bookmarks file |
|
69 | Write the given bookmark => hash dictionary to the .hg/bookmarks file | |
67 | in a format equal to those of localtags. |
|
70 | in a format equal to those of localtags. | |
68 |
|
71 | |||
69 | We also store a backup of the previous state in undo.bookmarks that |
|
72 | We also store a backup of the previous state in undo.bookmarks that | |
70 | can be copied back on rollback. |
|
73 | can be copied back on rollback. | |
71 | ''' |
|
74 | ''' | |
72 | refs = repo._bookmarks |
|
75 | refs = repo._bookmarks | |
73 |
|
76 | |||
74 | if repo._bookmarkcurrent not in refs: |
|
77 | if repo._bookmarkcurrent not in refs: | |
75 | setcurrent(repo, None) |
|
78 | setcurrent(repo, None) | |
76 | for mark in refs.keys(): |
|
79 | for mark in refs.keys(): | |
77 | if not valid(mark): |
|
80 | if not valid(mark): | |
78 | raise util.Abort(_("bookmark '%s' contains illegal " |
|
81 | raise util.Abort(_("bookmark '%s' contains illegal " | |
79 | "character" % mark)) |
|
82 | "character" % mark)) | |
80 |
|
83 | |||
81 | wlock = repo.wlock() |
|
84 | wlock = repo.wlock() | |
82 | try: |
|
85 | try: | |
83 |
|
86 | |||
84 | file = repo.opener('bookmarks', 'w', atomictemp=True) |
|
87 | file = repo.opener('bookmarks', 'w', atomictemp=True) | |
85 | for refspec, node in refs.iteritems(): |
|
88 | for refspec, node in refs.iteritems(): | |
86 | file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec))) |
|
89 | file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec))) | |
87 | file.rename() |
|
90 | file.rename() | |
88 |
|
91 | |||
89 | # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) |
|
92 | # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) | |
90 | try: |
|
93 | try: | |
91 | os.utime(repo.sjoin('00changelog.i'), None) |
|
94 | os.utime(repo.sjoin('00changelog.i'), None) | |
92 | except OSError: |
|
95 | except OSError: | |
93 | pass |
|
96 | pass | |
94 |
|
97 | |||
95 | finally: |
|
98 | finally: | |
96 | wlock.release() |
|
99 | wlock.release() | |
97 |
|
100 | |||
98 | def setcurrent(repo, mark): |
|
101 | def setcurrent(repo, mark): | |
99 | '''Set the name of the bookmark that we are currently on |
|
102 | '''Set the name of the bookmark that we are currently on | |
100 |
|
103 | |||
101 | Set the name of the bookmark that we are on (hg update <bookmark>). |
|
104 | Set the name of the bookmark that we are on (hg update <bookmark>). | |
102 | The name is recorded in .hg/bookmarks.current |
|
105 | The name is recorded in .hg/bookmarks.current | |
103 | ''' |
|
106 | ''' | |
104 | current = repo._bookmarkcurrent |
|
107 | current = repo._bookmarkcurrent | |
105 | if current == mark: |
|
108 | if current == mark: | |
106 | return |
|
109 | return | |
107 |
|
110 | |||
108 | if mark not in repo._bookmarks: |
|
111 | if mark not in repo._bookmarks: | |
109 | mark = '' |
|
112 | mark = '' | |
110 | if not valid(mark): |
|
113 | if not valid(mark): | |
111 | raise util.Abort(_("bookmark '%s' contains illegal " |
|
114 | raise util.Abort(_("bookmark '%s' contains illegal " | |
112 | "character" % mark)) |
|
115 | "character" % mark)) | |
113 |
|
116 | |||
114 | wlock = repo.wlock() |
|
117 | wlock = repo.wlock() | |
115 | try: |
|
118 | try: | |
116 | file = repo.opener('bookmarks.current', 'w', atomictemp=True) |
|
119 | file = repo.opener('bookmarks.current', 'w', atomictemp=True) | |
117 | file.write(encoding.fromlocal(mark)) |
|
120 | file.write(encoding.fromlocal(mark)) | |
118 | file.rename() |
|
121 | file.rename() | |
119 | finally: |
|
122 | finally: | |
120 | wlock.release() |
|
123 | wlock.release() | |
121 | repo._bookmarkcurrent = mark |
|
124 | repo._bookmarkcurrent = mark | |
122 |
|
125 | |||
123 | def updatecurrentbookmark(repo, oldnode, curbranch): |
|
126 | def updatecurrentbookmark(repo, oldnode, curbranch): | |
124 | try: |
|
127 | try: | |
125 | update(repo, oldnode, repo.branchtags()[curbranch]) |
|
128 | update(repo, oldnode, repo.branchtags()[curbranch]) | |
126 | except KeyError: |
|
129 | except KeyError: | |
127 | if curbranch == "default": # no default branch! |
|
130 | if curbranch == "default": # no default branch! | |
128 | update(repo, oldnode, repo.lookup("tip")) |
|
131 | update(repo, oldnode, repo.lookup("tip")) | |
129 | else: |
|
132 | else: | |
130 | raise util.Abort(_("branch %s not found") % curbranch) |
|
133 | raise util.Abort(_("branch %s not found") % curbranch) | |
131 |
|
134 | |||
132 | def update(repo, parents, node): |
|
135 | def update(repo, parents, node): | |
133 | marks = repo._bookmarks |
|
136 | marks = repo._bookmarks | |
134 | update = False |
|
137 | update = False | |
135 | mark = repo._bookmarkcurrent |
|
138 | mark = repo._bookmarkcurrent | |
136 | if mark and marks[mark] in parents: |
|
139 | if mark and marks[mark] in parents: | |
137 | old = repo[marks[mark]] |
|
140 | old = repo[marks[mark]] | |
138 | new = repo[node] |
|
141 | new = repo[node] | |
139 | if new in old.descendants(): |
|
142 | if new in old.descendants(): | |
140 | marks[mark] = new.node() |
|
143 | marks[mark] = new.node() | |
141 | update = True |
|
144 | update = True | |
142 | if update: |
|
145 | if update: | |
143 | write(repo) |
|
146 | write(repo) | |
144 |
|
147 | |||
145 | def listbookmarks(repo): |
|
148 | def listbookmarks(repo): | |
146 | # We may try to list bookmarks on a repo type that does not |
|
149 | # We may try to list bookmarks on a repo type that does not | |
147 | # support it (e.g., statichttprepository). |
|
150 | # support it (e.g., statichttprepository). | |
148 | if not hasattr(repo, '_bookmarks'): |
|
151 | if not hasattr(repo, '_bookmarks'): | |
149 | return {} |
|
152 | return {} | |
150 |
|
153 | |||
151 | d = {} |
|
154 | d = {} | |
152 | for k, v in repo._bookmarks.iteritems(): |
|
155 | for k, v in repo._bookmarks.iteritems(): | |
153 | d[k] = hex(v) |
|
156 | d[k] = hex(v) | |
154 | return d |
|
157 | return d | |
155 |
|
158 | |||
156 | def pushbookmark(repo, key, old, new): |
|
159 | def pushbookmark(repo, key, old, new): | |
157 | w = repo.wlock() |
|
160 | w = repo.wlock() | |
158 | try: |
|
161 | try: | |
159 | marks = repo._bookmarks |
|
162 | marks = repo._bookmarks | |
160 | if hex(marks.get(key, '')) != old: |
|
163 | if hex(marks.get(key, '')) != old: | |
161 | return False |
|
164 | return False | |
162 | if new == '': |
|
165 | if new == '': | |
163 | del marks[key] |
|
166 | del marks[key] | |
164 | else: |
|
167 | else: | |
165 | if new not in repo: |
|
168 | if new not in repo: | |
166 | return False |
|
169 | return False | |
167 | marks[key] = repo[new].node() |
|
170 | marks[key] = repo[new].node() | |
168 | write(repo) |
|
171 | write(repo) | |
169 | return True |
|
172 | return True | |
170 | finally: |
|
173 | finally: | |
171 | w.release() |
|
174 | w.release() | |
172 |
|
175 | |||
173 | def updatefromremote(ui, repo, remote): |
|
176 | def updatefromremote(ui, repo, remote): | |
174 | ui.debug("checking for updated bookmarks\n") |
|
177 | ui.debug("checking for updated bookmarks\n") | |
175 | rb = remote.listkeys('bookmarks') |
|
178 | rb = remote.listkeys('bookmarks') | |
176 | changed = False |
|
179 | changed = False | |
177 | for k in rb.keys(): |
|
180 | for k in rb.keys(): | |
178 | if k in repo._bookmarks: |
|
181 | if k in repo._bookmarks: | |
179 | nr, nl = rb[k], repo._bookmarks[k] |
|
182 | nr, nl = rb[k], repo._bookmarks[k] | |
180 | if nr in repo: |
|
183 | if nr in repo: | |
181 | cr = repo[nr] |
|
184 | cr = repo[nr] | |
182 | cl = repo[nl] |
|
185 | cl = repo[nl] | |
183 | if cl.rev() >= cr.rev(): |
|
186 | if cl.rev() >= cr.rev(): | |
184 | continue |
|
187 | continue | |
185 | if cr in cl.descendants(): |
|
188 | if cr in cl.descendants(): | |
186 | repo._bookmarks[k] = cr.node() |
|
189 | repo._bookmarks[k] = cr.node() | |
187 | changed = True |
|
190 | changed = True | |
188 | ui.status(_("updating bookmark %s\n") % k) |
|
191 | ui.status(_("updating bookmark %s\n") % k) | |
189 | else: |
|
192 | else: | |
190 | ui.warn(_("not updating divergent" |
|
193 | ui.warn(_("not updating divergent" | |
191 | " bookmark %s\n") % k) |
|
194 | " bookmark %s\n") % k) | |
192 | if changed: |
|
195 | if changed: | |
193 | write(repo) |
|
196 | write(repo) | |
194 |
|
197 | |||
195 | def diff(ui, repo, remote): |
|
198 | def diff(ui, repo, remote): | |
196 | ui.status(_("searching for changed bookmarks\n")) |
|
199 | ui.status(_("searching for changed bookmarks\n")) | |
197 |
|
200 | |||
198 | lmarks = repo.listkeys('bookmarks') |
|
201 | lmarks = repo.listkeys('bookmarks') | |
199 | rmarks = remote.listkeys('bookmarks') |
|
202 | rmarks = remote.listkeys('bookmarks') | |
200 |
|
203 | |||
201 | diff = sorted(set(rmarks) - set(lmarks)) |
|
204 | diff = sorted(set(rmarks) - set(lmarks)) | |
202 | for k in diff: |
|
205 | for k in diff: | |
203 | ui.write(" %-25s %s\n" % (k, rmarks[k][:12])) |
|
206 | ui.write(" %-25s %s\n" % (k, rmarks[k][:12])) | |
204 |
|
207 | |||
205 | if len(diff) <= 0: |
|
208 | if len(diff) <= 0: | |
206 | ui.status(_("no changed bookmarks found\n")) |
|
209 | ui.status(_("no changed bookmarks found\n")) | |
207 | return 1 |
|
210 | return 1 | |
208 | return 0 |
|
211 | return 0 |
@@ -1,344 +1,352 b'' | |||||
1 | $ hg init |
|
1 | $ hg init | |
2 |
|
2 | |||
3 | no bookmarks |
|
3 | no bookmarks | |
4 |
|
4 | |||
5 | $ hg bookmarks |
|
5 | $ hg bookmarks | |
6 | no bookmarks set |
|
6 | no bookmarks set | |
7 |
|
7 | |||
8 | bookmark rev -1 |
|
8 | bookmark rev -1 | |
9 |
|
9 | |||
10 | $ hg bookmark X |
|
10 | $ hg bookmark X | |
11 |
|
11 | |||
12 | list bookmarks |
|
12 | list bookmarks | |
13 |
|
13 | |||
14 | $ hg bookmarks |
|
14 | $ hg bookmarks | |
15 | * X -1:000000000000 |
|
15 | * X -1:000000000000 | |
16 |
|
16 | |||
17 | list bookmarks with color |
|
17 | list bookmarks with color | |
18 |
|
18 | |||
19 | $ hg --config extensions.color= --config color.mode=ansi \ |
|
19 | $ hg --config extensions.color= --config color.mode=ansi \ | |
20 | > bookmarks --color=always |
|
20 | > bookmarks --color=always | |
21 | \x1b[0;32m * X -1:000000000000\x1b[0m (esc) |
|
21 | \x1b[0;32m * X -1:000000000000\x1b[0m (esc) | |
22 |
|
22 | |||
23 | $ echo a > a |
|
23 | $ echo a > a | |
24 | $ hg add a |
|
24 | $ hg add a | |
25 | $ hg commit -m 0 |
|
25 | $ hg commit -m 0 | |
26 |
|
26 | |||
27 | bookmark X moved to rev 0 |
|
27 | bookmark X moved to rev 0 | |
28 |
|
28 | |||
29 | $ hg bookmarks |
|
29 | $ hg bookmarks | |
30 | * X 0:f7b1eb17ad24 |
|
30 | * X 0:f7b1eb17ad24 | |
31 |
|
31 | |||
32 | look up bookmark |
|
32 | look up bookmark | |
33 |
|
33 | |||
34 | $ hg log -r X |
|
34 | $ hg log -r X | |
35 | changeset: 0:f7b1eb17ad24 |
|
35 | changeset: 0:f7b1eb17ad24 | |
36 | bookmark: X |
|
36 | bookmark: X | |
37 | tag: tip |
|
37 | tag: tip | |
38 | user: test |
|
38 | user: test | |
39 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
39 | date: Thu Jan 01 00:00:00 1970 +0000 | |
40 | summary: 0 |
|
40 | summary: 0 | |
41 |
|
41 | |||
42 |
|
42 | |||
43 | second bookmark for rev 0 |
|
43 | second bookmark for rev 0 | |
44 |
|
44 | |||
45 | $ hg bookmark X2 |
|
45 | $ hg bookmark X2 | |
46 |
|
46 | |||
47 | bookmark rev -1 again |
|
47 | bookmark rev -1 again | |
48 |
|
48 | |||
49 | $ hg bookmark -r null Y |
|
49 | $ hg bookmark -r null Y | |
50 |
|
50 | |||
51 | list bookmarks |
|
51 | list bookmarks | |
52 |
|
52 | |||
53 | $ hg bookmarks |
|
53 | $ hg bookmarks | |
54 | X 0:f7b1eb17ad24 |
|
54 | X 0:f7b1eb17ad24 | |
55 | * X2 0:f7b1eb17ad24 |
|
55 | * X2 0:f7b1eb17ad24 | |
56 | Y -1:000000000000 |
|
56 | Y -1:000000000000 | |
57 |
|
57 | |||
58 | $ echo b > b |
|
58 | $ echo b > b | |
59 | $ hg add b |
|
59 | $ hg add b | |
60 | $ hg commit -m 1 |
|
60 | $ hg commit -m 1 | |
61 |
|
61 | |||
62 | bookmarks revset |
|
62 | bookmarks revset | |
63 |
|
63 | |||
64 | $ hg log -r 'bookmark()' |
|
64 | $ hg log -r 'bookmark()' | |
65 | changeset: 0:f7b1eb17ad24 |
|
65 | changeset: 0:f7b1eb17ad24 | |
66 | bookmark: X |
|
66 | bookmark: X | |
67 | user: test |
|
67 | user: test | |
68 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
68 | date: Thu Jan 01 00:00:00 1970 +0000 | |
69 | summary: 0 |
|
69 | summary: 0 | |
70 |
|
70 | |||
71 | changeset: 1:925d80f479bb |
|
71 | changeset: 1:925d80f479bb | |
72 | bookmark: X2 |
|
72 | bookmark: X2 | |
73 | tag: tip |
|
73 | tag: tip | |
74 | user: test |
|
74 | user: test | |
75 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
75 | date: Thu Jan 01 00:00:00 1970 +0000 | |
76 | summary: 1 |
|
76 | summary: 1 | |
77 |
|
77 | |||
78 | $ hg log -r 'bookmark(Y)' |
|
78 | $ hg log -r 'bookmark(Y)' | |
79 | $ hg log -r 'bookmark(X2)' |
|
79 | $ hg log -r 'bookmark(X2)' | |
80 | changeset: 1:925d80f479bb |
|
80 | changeset: 1:925d80f479bb | |
81 | bookmark: X2 |
|
81 | bookmark: X2 | |
82 | tag: tip |
|
82 | tag: tip | |
83 | user: test |
|
83 | user: test | |
84 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
84 | date: Thu Jan 01 00:00:00 1970 +0000 | |
85 | summary: 1 |
|
85 | summary: 1 | |
86 |
|
86 | |||
87 | $ hg log -r 'bookmark(unknown)' |
|
87 | $ hg log -r 'bookmark(unknown)' | |
88 | abort: bookmark 'unknown' does not exist |
|
88 | abort: bookmark 'unknown' does not exist | |
89 | [255] |
|
89 | [255] | |
90 |
|
90 | |||
91 | $ hg help revsets | grep 'bookmark(' |
|
91 | $ hg help revsets | grep 'bookmark(' | |
92 | "bookmark([name])" |
|
92 | "bookmark([name])" | |
93 |
|
93 | |||
94 | bookmarks X and X2 moved to rev 1, Y at rev -1 |
|
94 | bookmarks X and X2 moved to rev 1, Y at rev -1 | |
95 |
|
95 | |||
96 | $ hg bookmarks |
|
96 | $ hg bookmarks | |
97 | X 0:f7b1eb17ad24 |
|
97 | X 0:f7b1eb17ad24 | |
98 | * X2 1:925d80f479bb |
|
98 | * X2 1:925d80f479bb | |
99 | Y -1:000000000000 |
|
99 | Y -1:000000000000 | |
100 |
|
100 | |||
101 | bookmark rev 0 again |
|
101 | bookmark rev 0 again | |
102 |
|
102 | |||
103 | $ hg bookmark -r 0 Z |
|
103 | $ hg bookmark -r 0 Z | |
104 |
|
104 | |||
105 | $ hg update X |
|
105 | $ hg update X | |
106 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
106 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
107 | $ echo c > c |
|
107 | $ echo c > c | |
108 | $ hg add c |
|
108 | $ hg add c | |
109 | $ hg commit -m 2 |
|
109 | $ hg commit -m 2 | |
110 | created new head |
|
110 | created new head | |
111 |
|
111 | |||
112 | bookmarks X moved to rev 2, Y at rev -1, Z at rev 0 |
|
112 | bookmarks X moved to rev 2, Y at rev -1, Z at rev 0 | |
113 |
|
113 | |||
114 | $ hg bookmarks |
|
114 | $ hg bookmarks | |
115 | * X 2:db815d6d32e6 |
|
115 | * X 2:db815d6d32e6 | |
116 | X2 1:925d80f479bb |
|
116 | X2 1:925d80f479bb | |
117 | Y -1:000000000000 |
|
117 | Y -1:000000000000 | |
118 | Z 0:f7b1eb17ad24 |
|
118 | Z 0:f7b1eb17ad24 | |
119 |
|
119 | |||
120 | rename nonexistent bookmark |
|
120 | rename nonexistent bookmark | |
121 |
|
121 | |||
122 | $ hg bookmark -m A B |
|
122 | $ hg bookmark -m A B | |
123 | abort: bookmark 'A' does not exist |
|
123 | abort: bookmark 'A' does not exist | |
124 | [255] |
|
124 | [255] | |
125 |
|
125 | |||
126 | rename to existent bookmark |
|
126 | rename to existent bookmark | |
127 |
|
127 | |||
128 | $ hg bookmark -m X Y |
|
128 | $ hg bookmark -m X Y | |
129 | abort: bookmark 'Y' already exists (use -f to force) |
|
129 | abort: bookmark 'Y' already exists (use -f to force) | |
130 | [255] |
|
130 | [255] | |
131 |
|
131 | |||
132 | force rename to existent bookmark |
|
132 | force rename to existent bookmark | |
133 |
|
133 | |||
134 | $ hg bookmark -f -m X Y |
|
134 | $ hg bookmark -f -m X Y | |
135 |
|
135 | |||
136 | list bookmarks |
|
136 | list bookmarks | |
137 |
|
137 | |||
138 | $ hg bookmark |
|
138 | $ hg bookmark | |
139 | X2 1:925d80f479bb |
|
139 | X2 1:925d80f479bb | |
140 | * Y 2:db815d6d32e6 |
|
140 | * Y 2:db815d6d32e6 | |
141 | Z 0:f7b1eb17ad24 |
|
141 | Z 0:f7b1eb17ad24 | |
142 |
|
142 | |||
143 | rename without new name |
|
143 | rename without new name | |
144 |
|
144 | |||
145 | $ hg bookmark -m Y |
|
145 | $ hg bookmark -m Y | |
146 | abort: new bookmark name required |
|
146 | abort: new bookmark name required | |
147 | [255] |
|
147 | [255] | |
148 |
|
148 | |||
149 | delete without name |
|
149 | delete without name | |
150 |
|
150 | |||
151 | $ hg bookmark -d |
|
151 | $ hg bookmark -d | |
152 | abort: bookmark name required |
|
152 | abort: bookmark name required | |
153 | [255] |
|
153 | [255] | |
154 |
|
154 | |||
155 | delete nonexistent bookmark |
|
155 | delete nonexistent bookmark | |
156 |
|
156 | |||
157 | $ hg bookmark -d A |
|
157 | $ hg bookmark -d A | |
158 | abort: bookmark 'A' does not exist |
|
158 | abort: bookmark 'A' does not exist | |
159 | [255] |
|
159 | [255] | |
160 |
|
160 | |||
161 | bookmark name with spaces should be stripped |
|
161 | bookmark name with spaces should be stripped | |
162 |
|
162 | |||
163 | $ hg bookmark ' x y ' |
|
163 | $ hg bookmark ' x y ' | |
164 |
|
164 | |||
165 | list bookmarks |
|
165 | list bookmarks | |
166 |
|
166 | |||
167 | $ hg bookmarks |
|
167 | $ hg bookmarks | |
168 | X2 1:925d80f479bb |
|
168 | X2 1:925d80f479bb | |
169 | Y 2:db815d6d32e6 |
|
169 | Y 2:db815d6d32e6 | |
170 | Z 0:f7b1eb17ad24 |
|
170 | Z 0:f7b1eb17ad24 | |
171 | * x y 2:db815d6d32e6 |
|
171 | * x y 2:db815d6d32e6 | |
172 |
|
172 | |||
173 | look up stripped bookmark name |
|
173 | look up stripped bookmark name | |
174 |
|
174 | |||
175 | $ hg log -r '"x y"' |
|
175 | $ hg log -r '"x y"' | |
176 | changeset: 2:db815d6d32e6 |
|
176 | changeset: 2:db815d6d32e6 | |
177 | bookmark: Y |
|
177 | bookmark: Y | |
178 | bookmark: x y |
|
178 | bookmark: x y | |
179 | tag: tip |
|
179 | tag: tip | |
180 | parent: 0:f7b1eb17ad24 |
|
180 | parent: 0:f7b1eb17ad24 | |
181 | user: test |
|
181 | user: test | |
182 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
182 | date: Thu Jan 01 00:00:00 1970 +0000 | |
183 | summary: 2 |
|
183 | summary: 2 | |
184 |
|
184 | |||
185 |
|
185 | |||
186 | reject bookmark name with newline |
|
186 | reject bookmark name with newline | |
187 |
|
187 | |||
188 | $ hg bookmark ' |
|
188 | $ hg bookmark ' | |
189 | > ' |
|
189 | > ' | |
190 | abort: bookmark name cannot contain newlines |
|
190 | abort: bookmark name cannot contain newlines | |
191 | [255] |
|
191 | [255] | |
192 |
|
192 | |||
193 | bookmark with existing name |
|
193 | bookmark with existing name | |
194 |
|
194 | |||
195 | $ hg bookmark Z |
|
195 | $ hg bookmark Z | |
196 | abort: bookmark 'Z' already exists (use -f to force) |
|
196 | abort: bookmark 'Z' already exists (use -f to force) | |
197 | [255] |
|
197 | [255] | |
198 |
|
198 | |||
199 | force bookmark with existing name |
|
199 | force bookmark with existing name | |
200 |
|
200 | |||
201 | $ hg bookmark -f Z |
|
201 | $ hg bookmark -f Z | |
202 |
|
202 | |||
203 | list bookmarks |
|
203 | list bookmarks | |
204 |
|
204 | |||
205 | $ hg bookmark |
|
205 | $ hg bookmark | |
206 | X2 1:925d80f479bb |
|
206 | X2 1:925d80f479bb | |
207 | Y 2:db815d6d32e6 |
|
207 | Y 2:db815d6d32e6 | |
208 | * Z 2:db815d6d32e6 |
|
208 | * Z 2:db815d6d32e6 | |
209 | x y 2:db815d6d32e6 |
|
209 | x y 2:db815d6d32e6 | |
210 |
|
210 | |||
211 | revision but no bookmark name |
|
211 | revision but no bookmark name | |
212 |
|
212 | |||
213 | $ hg bookmark -r . |
|
213 | $ hg bookmark -r . | |
214 | abort: bookmark name required |
|
214 | abort: bookmark name required | |
215 | [255] |
|
215 | [255] | |
216 |
|
216 | |||
217 | bookmark name with whitespace only |
|
217 | bookmark name with whitespace only | |
218 |
|
218 | |||
219 | $ hg bookmark ' ' |
|
219 | $ hg bookmark ' ' | |
220 | abort: bookmark names cannot consist entirely of whitespace |
|
220 | abort: bookmark names cannot consist entirely of whitespace | |
221 | [255] |
|
221 | [255] | |
222 |
|
222 | |||
223 | invalid bookmark |
|
223 | invalid bookmark | |
224 |
|
224 | |||
225 | $ hg bookmark 'foo:bar' |
|
225 | $ hg bookmark 'foo:bar' | |
226 | abort: bookmark 'foo:bar' contains illegal character |
|
226 | abort: bookmark 'foo:bar' contains illegal character | |
227 | [255] |
|
227 | [255] | |
228 |
|
228 | |||
229 | the bookmark extension should be ignored now that it is part of core |
|
229 | the bookmark extension should be ignored now that it is part of core | |
230 |
|
230 | |||
231 | $ echo "[extensions]" >> $HGRCPATH |
|
231 | $ echo "[extensions]" >> $HGRCPATH | |
232 | $ echo "bookmarks=" >> $HGRCPATH |
|
232 | $ echo "bookmarks=" >> $HGRCPATH | |
233 | $ hg bookmarks |
|
233 | $ hg bookmarks | |
234 | X2 1:925d80f479bb |
|
234 | X2 1:925d80f479bb | |
235 | Y 2:db815d6d32e6 |
|
235 | Y 2:db815d6d32e6 | |
236 | * Z 2:db815d6d32e6 |
|
236 | * Z 2:db815d6d32e6 | |
237 | x y 2:db815d6d32e6 |
|
237 | x y 2:db815d6d32e6 | |
238 |
|
238 | |||
239 | test summary |
|
239 | test summary | |
240 |
|
240 | |||
241 | $ hg summary |
|
241 | $ hg summary | |
242 | parent: 2:db815d6d32e6 tip Y Z x y |
|
242 | parent: 2:db815d6d32e6 tip Y Z x y | |
243 | 2 |
|
243 | 2 | |
244 | branch: default |
|
244 | branch: default | |
245 | commit: (clean) |
|
245 | commit: (clean) | |
246 | update: 1 new changesets, 2 branch heads (merge) |
|
246 | update: 1 new changesets, 2 branch heads (merge) | |
247 |
|
247 | |||
248 | test id |
|
248 | test id | |
249 |
|
249 | |||
250 | $ hg id |
|
250 | $ hg id | |
251 | db815d6d32e6 tip Y/Z/x y |
|
251 | db815d6d32e6 tip Y/Z/x y | |
252 |
|
252 | |||
253 | test rollback |
|
253 | test rollback | |
254 |
|
254 | |||
255 | $ echo foo > f1 |
|
255 | $ echo foo > f1 | |
256 | $ hg ci -Amr |
|
256 | $ hg ci -Amr | |
257 | adding f1 |
|
257 | adding f1 | |
258 | $ hg bookmark -f Y -r 1 |
|
258 | $ hg bookmark -f Y -r 1 | |
259 | $ hg bookmark -f Z -r 1 |
|
259 | $ hg bookmark -f Z -r 1 | |
260 | $ hg rollback |
|
260 | $ hg rollback | |
261 | repository tip rolled back to revision 2 (undo commit) |
|
261 | repository tip rolled back to revision 2 (undo commit) | |
262 | working directory now based on revision 2 |
|
262 | working directory now based on revision 2 | |
263 | $ hg bookmarks |
|
263 | $ hg bookmarks | |
264 | X2 1:925d80f479bb |
|
264 | X2 1:925d80f479bb | |
265 | Y 2:db815d6d32e6 |
|
265 | Y 2:db815d6d32e6 | |
266 | * Z 2:db815d6d32e6 |
|
266 | * Z 2:db815d6d32e6 | |
267 | x y 2:db815d6d32e6 |
|
267 | x y 2:db815d6d32e6 | |
268 |
|
268 | |||
269 | test clone |
|
269 | test clone | |
270 |
|
270 | |||
271 | $ hg bookmarks |
|
271 | $ hg bookmarks | |
272 | X2 1:925d80f479bb |
|
272 | X2 1:925d80f479bb | |
273 | Y 2:db815d6d32e6 |
|
273 | Y 2:db815d6d32e6 | |
274 | * Z 2:db815d6d32e6 |
|
274 | * Z 2:db815d6d32e6 | |
275 | x y 2:db815d6d32e6 |
|
275 | x y 2:db815d6d32e6 | |
276 | $ hg clone . cloned-bookmarks |
|
276 | $ hg clone . cloned-bookmarks | |
277 | updating to branch default |
|
277 | updating to branch default | |
278 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
278 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
279 | $ hg -R cloned-bookmarks bookmarks |
|
279 | $ hg -R cloned-bookmarks bookmarks | |
280 | X2 1:925d80f479bb |
|
280 | X2 1:925d80f479bb | |
281 | Y 2:db815d6d32e6 |
|
281 | Y 2:db815d6d32e6 | |
282 | Z 2:db815d6d32e6 |
|
282 | Z 2:db815d6d32e6 | |
283 | x y 2:db815d6d32e6 |
|
283 | x y 2:db815d6d32e6 | |
284 |
|
284 | |||
285 | test clone with pull protocol |
|
285 | test clone with pull protocol | |
286 |
|
286 | |||
287 | $ hg clone --pull . cloned-bookmarks-pull |
|
287 | $ hg clone --pull . cloned-bookmarks-pull | |
288 | requesting all changes |
|
288 | requesting all changes | |
289 | adding changesets |
|
289 | adding changesets | |
290 | adding manifests |
|
290 | adding manifests | |
291 | adding file changes |
|
291 | adding file changes | |
292 | added 3 changesets with 3 changes to 3 files (+1 heads) |
|
292 | added 3 changesets with 3 changes to 3 files (+1 heads) | |
293 | updating to branch default |
|
293 | updating to branch default | |
294 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
294 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
295 | $ hg -R cloned-bookmarks-pull bookmarks |
|
295 | $ hg -R cloned-bookmarks-pull bookmarks | |
296 | X2 1:925d80f479bb |
|
296 | X2 1:925d80f479bb | |
297 | Y 2:db815d6d32e6 |
|
297 | Y 2:db815d6d32e6 | |
298 | Z 2:db815d6d32e6 |
|
298 | Z 2:db815d6d32e6 | |
299 | x y 2:db815d6d32e6 |
|
299 | x y 2:db815d6d32e6 | |
300 |
|
300 | |||
301 | test clone with a specific revision |
|
301 | test clone with a specific revision | |
302 |
|
302 | |||
303 | $ hg clone -r 925d80 . cloned-bookmarks-rev |
|
303 | $ hg clone -r 925d80 . cloned-bookmarks-rev | |
304 | adding changesets |
|
304 | adding changesets | |
305 | adding manifests |
|
305 | adding manifests | |
306 | adding file changes |
|
306 | adding file changes | |
307 | added 2 changesets with 2 changes to 2 files |
|
307 | added 2 changesets with 2 changes to 2 files | |
308 | updating to branch default |
|
308 | updating to branch default | |
309 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
309 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
310 | $ hg -R cloned-bookmarks-rev bookmarks |
|
310 | $ hg -R cloned-bookmarks-rev bookmarks | |
311 | X2 1:925d80f479bb |
|
311 | X2 1:925d80f479bb | |
312 |
|
312 | |||
313 | create bundle with two heads |
|
313 | create bundle with two heads | |
314 |
|
314 | |||
315 | $ hg clone . tobundle |
|
315 | $ hg clone . tobundle | |
316 | updating to branch default |
|
316 | updating to branch default | |
317 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
317 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
318 | $ echo x > tobundle/x |
|
318 | $ echo x > tobundle/x | |
319 | $ hg -R tobundle add tobundle/x |
|
319 | $ hg -R tobundle add tobundle/x | |
320 | $ hg -R tobundle commit -m'x' |
|
320 | $ hg -R tobundle commit -m'x' | |
321 | $ hg -R tobundle update -r -2 |
|
321 | $ hg -R tobundle update -r -2 | |
322 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
322 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
323 | $ echo y > tobundle/y |
|
323 | $ echo y > tobundle/y | |
324 | $ hg -R tobundle branch test |
|
324 | $ hg -R tobundle branch test | |
325 | marked working directory as branch test |
|
325 | marked working directory as branch test | |
326 | $ hg -R tobundle add tobundle/y |
|
326 | $ hg -R tobundle add tobundle/y | |
327 | $ hg -R tobundle commit -m'y' |
|
327 | $ hg -R tobundle commit -m'y' | |
328 | $ hg -R tobundle bundle tobundle.hg |
|
328 | $ hg -R tobundle bundle tobundle.hg | |
329 | searching for changes |
|
329 | searching for changes | |
330 | 2 changesets found |
|
330 | 2 changesets found | |
331 | $ hg unbundle tobundle.hg |
|
331 | $ hg unbundle tobundle.hg | |
332 | adding changesets |
|
332 | adding changesets | |
333 | adding manifests |
|
333 | adding manifests | |
334 | adding file changes |
|
334 | adding file changes | |
335 | added 2 changesets with 2 changes to 2 files (+1 heads) |
|
335 | added 2 changesets with 2 changes to 2 files (+1 heads) | |
336 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
336 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
337 | $ hg update |
|
337 | $ hg update | |
338 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
338 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
339 | $ hg bookmarks |
|
339 | $ hg bookmarks | |
340 | X2 1:925d80f479bb |
|
340 | X2 1:925d80f479bb | |
341 | Y 2:db815d6d32e6 |
|
341 | Y 2:db815d6d32e6 | |
342 | * Z 3:125c9a1d6df6 |
|
342 | * Z 3:125c9a1d6df6 | |
343 | x y 2:db815d6d32e6 |
|
343 | x y 2:db815d6d32e6 | |
344 |
|
344 | |||
|
345 | test wrongly formated bookmark | |||
|
346 | ||||
|
347 | $ echo '' >> .hg/bookmarks | |||
|
348 | $ hg bookmarks | |||
|
349 | X2 1:925d80f479bb | |||
|
350 | Y 2:db815d6d32e6 | |||
|
351 | * Z 3:125c9a1d6df6 | |||
|
352 | x y 2:db815d6d32e6 |
General Comments 0
You need to be logged in to leave comments.
Login now