##// END OF EJS Templates
bookmarks: add a warning for non empty malformed line
Pierre-Yves David -
r14846:5097d8b5 default
parent child Browse files
Show More
@@ -1,211 +1,214 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()
29 line = line.strip()
30 if ' ' not in line:
30 if ' ' not in line:
31 if line:
32 msg = _('malformed line in .hg/bookmarks: %r\n')
33 repo.ui.warn( msg % line)
31 continue
34 continue
32 sha, refspec = line.strip().split(' ', 1)
35 sha, refspec = line.strip().split(' ', 1)
33 refspec = encoding.tolocal(refspec)
36 refspec = encoding.tolocal(refspec)
34 try:
37 try:
35 bookmarks[refspec] = repo.changelog.lookup(sha)
38 bookmarks[refspec] = repo.changelog.lookup(sha)
36 except error.RepoLookupError:
39 except error.RepoLookupError:
37 pass
40 pass
38 except IOError, inst:
41 except IOError, inst:
39 if inst.errno != errno.ENOENT:
42 if inst.errno != errno.ENOENT:
40 raise
43 raise
41 return bookmarks
44 return bookmarks
42
45
43 def readcurrent(repo):
46 def readcurrent(repo):
44 '''Get the current bookmark
47 '''Get the current bookmark
45
48
46 If we use gittishsh branches we have a current bookmark that
49 If we use gittishsh branches we have a current bookmark that
47 we are on. This function returns the name of the bookmark. It
50 we are on. This function returns the name of the bookmark. It
48 is stored in .hg/bookmarks.current
51 is stored in .hg/bookmarks.current
49 '''
52 '''
50 mark = None
53 mark = None
51 try:
54 try:
52 file = repo.opener('bookmarks.current')
55 file = repo.opener('bookmarks.current')
53 except IOError, inst:
56 except IOError, inst:
54 if inst.errno != errno.ENOENT:
57 if inst.errno != errno.ENOENT:
55 raise
58 raise
56 return None
59 return None
57 try:
60 try:
58 # No readline() in posixfile_nt, reading everything is cheap
61 # No readline() in posixfile_nt, reading everything is cheap
59 mark = encoding.tolocal((file.readlines() or [''])[0])
62 mark = encoding.tolocal((file.readlines() or [''])[0])
60 if mark == '' or mark not in repo._bookmarks:
63 if mark == '' or mark not in repo._bookmarks:
61 mark = None
64 mark = None
62 finally:
65 finally:
63 file.close()
66 file.close()
64 return mark
67 return mark
65
68
66 def write(repo):
69 def write(repo):
67 '''Write bookmarks
70 '''Write bookmarks
68
71
69 Write the given bookmark => hash dictionary to the .hg/bookmarks file
72 Write the given bookmark => hash dictionary to the .hg/bookmarks file
70 in a format equal to those of localtags.
73 in a format equal to those of localtags.
71
74
72 We also store a backup of the previous state in undo.bookmarks that
75 We also store a backup of the previous state in undo.bookmarks that
73 can be copied back on rollback.
76 can be copied back on rollback.
74 '''
77 '''
75 refs = repo._bookmarks
78 refs = repo._bookmarks
76
79
77 if repo._bookmarkcurrent not in refs:
80 if repo._bookmarkcurrent not in refs:
78 setcurrent(repo, None)
81 setcurrent(repo, None)
79 for mark in refs.keys():
82 for mark in refs.keys():
80 if not valid(mark):
83 if not valid(mark):
81 raise util.Abort(_("bookmark '%s' contains illegal "
84 raise util.Abort(_("bookmark '%s' contains illegal "
82 "character" % mark))
85 "character" % mark))
83
86
84 wlock = repo.wlock()
87 wlock = repo.wlock()
85 try:
88 try:
86
89
87 file = repo.opener('bookmarks', 'w', atomictemp=True)
90 file = repo.opener('bookmarks', 'w', atomictemp=True)
88 for refspec, node in refs.iteritems():
91 for refspec, node in refs.iteritems():
89 file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec)))
92 file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec)))
90 file.rename()
93 file.rename()
91
94
92 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed)
95 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed)
93 try:
96 try:
94 os.utime(repo.sjoin('00changelog.i'), None)
97 os.utime(repo.sjoin('00changelog.i'), None)
95 except OSError:
98 except OSError:
96 pass
99 pass
97
100
98 finally:
101 finally:
99 wlock.release()
102 wlock.release()
100
103
101 def setcurrent(repo, mark):
104 def setcurrent(repo, mark):
102 '''Set the name of the bookmark that we are currently on
105 '''Set the name of the bookmark that we are currently on
103
106
104 Set the name of the bookmark that we are on (hg update <bookmark>).
107 Set the name of the bookmark that we are on (hg update <bookmark>).
105 The name is recorded in .hg/bookmarks.current
108 The name is recorded in .hg/bookmarks.current
106 '''
109 '''
107 current = repo._bookmarkcurrent
110 current = repo._bookmarkcurrent
108 if current == mark:
111 if current == mark:
109 return
112 return
110
113
111 if mark not in repo._bookmarks:
114 if mark not in repo._bookmarks:
112 mark = ''
115 mark = ''
113 if not valid(mark):
116 if not valid(mark):
114 raise util.Abort(_("bookmark '%s' contains illegal "
117 raise util.Abort(_("bookmark '%s' contains illegal "
115 "character" % mark))
118 "character" % mark))
116
119
117 wlock = repo.wlock()
120 wlock = repo.wlock()
118 try:
121 try:
119 file = repo.opener('bookmarks.current', 'w', atomictemp=True)
122 file = repo.opener('bookmarks.current', 'w', atomictemp=True)
120 file.write(encoding.fromlocal(mark))
123 file.write(encoding.fromlocal(mark))
121 file.rename()
124 file.rename()
122 finally:
125 finally:
123 wlock.release()
126 wlock.release()
124 repo._bookmarkcurrent = mark
127 repo._bookmarkcurrent = mark
125
128
126 def updatecurrentbookmark(repo, oldnode, curbranch):
129 def updatecurrentbookmark(repo, oldnode, curbranch):
127 try:
130 try:
128 update(repo, oldnode, repo.branchtags()[curbranch])
131 update(repo, oldnode, repo.branchtags()[curbranch])
129 except KeyError:
132 except KeyError:
130 if curbranch == "default": # no default branch!
133 if curbranch == "default": # no default branch!
131 update(repo, oldnode, repo.lookup("tip"))
134 update(repo, oldnode, repo.lookup("tip"))
132 else:
135 else:
133 raise util.Abort(_("branch %s not found") % curbranch)
136 raise util.Abort(_("branch %s not found") % curbranch)
134
137
135 def update(repo, parents, node):
138 def update(repo, parents, node):
136 marks = repo._bookmarks
139 marks = repo._bookmarks
137 update = False
140 update = False
138 mark = repo._bookmarkcurrent
141 mark = repo._bookmarkcurrent
139 if mark and marks[mark] in parents:
142 if mark and marks[mark] in parents:
140 old = repo[marks[mark]]
143 old = repo[marks[mark]]
141 new = repo[node]
144 new = repo[node]
142 if new in old.descendants():
145 if new in old.descendants():
143 marks[mark] = new.node()
146 marks[mark] = new.node()
144 update = True
147 update = True
145 if update:
148 if update:
146 write(repo)
149 write(repo)
147
150
148 def listbookmarks(repo):
151 def listbookmarks(repo):
149 # We may try to list bookmarks on a repo type that does not
152 # We may try to list bookmarks on a repo type that does not
150 # support it (e.g., statichttprepository).
153 # support it (e.g., statichttprepository).
151 if not hasattr(repo, '_bookmarks'):
154 if not hasattr(repo, '_bookmarks'):
152 return {}
155 return {}
153
156
154 d = {}
157 d = {}
155 for k, v in repo._bookmarks.iteritems():
158 for k, v in repo._bookmarks.iteritems():
156 d[k] = hex(v)
159 d[k] = hex(v)
157 return d
160 return d
158
161
159 def pushbookmark(repo, key, old, new):
162 def pushbookmark(repo, key, old, new):
160 w = repo.wlock()
163 w = repo.wlock()
161 try:
164 try:
162 marks = repo._bookmarks
165 marks = repo._bookmarks
163 if hex(marks.get(key, '')) != old:
166 if hex(marks.get(key, '')) != old:
164 return False
167 return False
165 if new == '':
168 if new == '':
166 del marks[key]
169 del marks[key]
167 else:
170 else:
168 if new not in repo:
171 if new not in repo:
169 return False
172 return False
170 marks[key] = repo[new].node()
173 marks[key] = repo[new].node()
171 write(repo)
174 write(repo)
172 return True
175 return True
173 finally:
176 finally:
174 w.release()
177 w.release()
175
178
176 def updatefromremote(ui, repo, remote):
179 def updatefromremote(ui, repo, remote):
177 ui.debug("checking for updated bookmarks\n")
180 ui.debug("checking for updated bookmarks\n")
178 rb = remote.listkeys('bookmarks')
181 rb = remote.listkeys('bookmarks')
179 changed = False
182 changed = False
180 for k in rb.keys():
183 for k in rb.keys():
181 if k in repo._bookmarks:
184 if k in repo._bookmarks:
182 nr, nl = rb[k], repo._bookmarks[k]
185 nr, nl = rb[k], repo._bookmarks[k]
183 if nr in repo:
186 if nr in repo:
184 cr = repo[nr]
187 cr = repo[nr]
185 cl = repo[nl]
188 cl = repo[nl]
186 if cl.rev() >= cr.rev():
189 if cl.rev() >= cr.rev():
187 continue
190 continue
188 if cr in cl.descendants():
191 if cr in cl.descendants():
189 repo._bookmarks[k] = cr.node()
192 repo._bookmarks[k] = cr.node()
190 changed = True
193 changed = True
191 ui.status(_("updating bookmark %s\n") % k)
194 ui.status(_("updating bookmark %s\n") % k)
192 else:
195 else:
193 ui.warn(_("not updating divergent"
196 ui.warn(_("not updating divergent"
194 " bookmark %s\n") % k)
197 " bookmark %s\n") % k)
195 if changed:
198 if changed:
196 write(repo)
199 write(repo)
197
200
198 def diff(ui, repo, remote):
201 def diff(ui, repo, remote):
199 ui.status(_("searching for changed bookmarks\n"))
202 ui.status(_("searching for changed bookmarks\n"))
200
203
201 lmarks = repo.listkeys('bookmarks')
204 lmarks = repo.listkeys('bookmarks')
202 rmarks = remote.listkeys('bookmarks')
205 rmarks = remote.listkeys('bookmarks')
203
206
204 diff = sorted(set(rmarks) - set(lmarks))
207 diff = sorted(set(rmarks) - set(lmarks))
205 for k in diff:
208 for k in diff:
206 ui.write(" %-25s %s\n" % (k, rmarks[k][:12]))
209 ui.write(" %-25s %s\n" % (k, rmarks[k][:12]))
207
210
208 if len(diff) <= 0:
211 if len(diff) <= 0:
209 ui.status(_("no changed bookmarks found\n"))
212 ui.status(_("no changed bookmarks found\n"))
210 return 1
213 return 1
211 return 0
214 return 0
@@ -1,352 +1,360 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
345 test wrongly formated bookmark
346
346
347 $ echo '' >> .hg/bookmarks
347 $ echo '' >> .hg/bookmarks
348 $ hg bookmarks
348 $ hg bookmarks
349 X2 1:925d80f479bb
349 X2 1:925d80f479bb
350 Y 2:db815d6d32e6
350 Y 2:db815d6d32e6
351 * Z 3:125c9a1d6df6
351 * Z 3:125c9a1d6df6
352 x y 2:db815d6d32e6
352 x y 2:db815d6d32e6
353 $ echo "Ican'thasformatedlines" >> .hg/bookmarks
354 $ hg bookmarks
355 malformed line in .hg/bookmarks: "Ican'thasformatedlines"
356 X2 1:925d80f479bb
357 Y 2:db815d6d32e6
358 * Z 3:125c9a1d6df6
359 x y 2:db815d6d32e6
360
General Comments 0
You need to be logged in to leave comments. Login now