##// END OF EJS Templates
bookmark: read pending data when appropriate...
Pierre-Yves David -
r23360:e06daad6 default
parent child Browse files
Show More
@@ -1,442 +1,452
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 import os
8 from mercurial.i18n import _
9 from mercurial.i18n import _
9 from mercurial.node import hex, bin
10 from mercurial.node import hex, bin
10 from mercurial import encoding, error, util, obsolete, lock as lockmod
11 from mercurial import encoding, error, util, obsolete, lock as lockmod
11 import errno
12 import errno
12
13
13 class bmstore(dict):
14 class bmstore(dict):
14 """Storage for bookmarks.
15 """Storage for bookmarks.
15
16
16 This object should do all bookmark reads and writes, so that it's
17 This object should do all bookmark reads and writes, so that it's
17 fairly simple to replace the storage underlying bookmarks without
18 fairly simple to replace the storage underlying bookmarks without
18 having to clone the logic surrounding bookmarks.
19 having to clone the logic surrounding bookmarks.
19
20
20 This particular bmstore implementation stores bookmarks as
21 This particular bmstore implementation stores bookmarks as
21 {hash}\s{name}\n (the same format as localtags) in
22 {hash}\s{name}\n (the same format as localtags) in
22 .hg/bookmarks. The mapping is stored as {name: nodeid}.
23 .hg/bookmarks. The mapping is stored as {name: nodeid}.
23
24
24 This class does NOT handle the "current" bookmark state at this
25 This class does NOT handle the "current" bookmark state at this
25 time.
26 time.
26 """
27 """
27
28
28 def __init__(self, repo):
29 def __init__(self, repo):
29 dict.__init__(self)
30 dict.__init__(self)
30 self._repo = repo
31 self._repo = repo
31 try:
32 try:
32 for line in repo.vfs('bookmarks'):
33 bkfile = None
34 if 'HG_PENDING' in os.environ:
35 try:
36 bkfile = repo.vfs('bookmarks.pending')
37 except IOError, inst:
38 if inst.errno != errno.ENOENT:
39 raise
40 if bkfile is None:
41 bkfile = repo.vfs('bookmarks')
42 for line in bkfile:
33 line = line.strip()
43 line = line.strip()
34 if not line:
44 if not line:
35 continue
45 continue
36 if ' ' not in line:
46 if ' ' not in line:
37 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
47 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
38 % line)
48 % line)
39 continue
49 continue
40 sha, refspec = line.split(' ', 1)
50 sha, refspec = line.split(' ', 1)
41 refspec = encoding.tolocal(refspec)
51 refspec = encoding.tolocal(refspec)
42 try:
52 try:
43 self[refspec] = repo.changelog.lookup(sha)
53 self[refspec] = repo.changelog.lookup(sha)
44 except LookupError:
54 except LookupError:
45 pass
55 pass
46 except IOError, inst:
56 except IOError, inst:
47 if inst.errno != errno.ENOENT:
57 if inst.errno != errno.ENOENT:
48 raise
58 raise
49
59
50 def recordchange(self, tr):
60 def recordchange(self, tr):
51 """record that bookmarks have been changed in a transaction
61 """record that bookmarks have been changed in a transaction
52
62
53 The transaction is then responsible for updating the file content."""
63 The transaction is then responsible for updating the file content."""
54 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
64 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
55 location='plain')
65 location='plain')
56 tr.hookargs['bookmark_moved'] = '1'
66 tr.hookargs['bookmark_moved'] = '1'
57
67
58 def write(self):
68 def write(self):
59 '''Write bookmarks
69 '''Write bookmarks
60
70
61 Write the given bookmark => hash dictionary to the .hg/bookmarks file
71 Write the given bookmark => hash dictionary to the .hg/bookmarks file
62 in a format equal to those of localtags.
72 in a format equal to those of localtags.
63
73
64 We also store a backup of the previous state in undo.bookmarks that
74 We also store a backup of the previous state in undo.bookmarks that
65 can be copied back on rollback.
75 can be copied back on rollback.
66 '''
76 '''
67 repo = self._repo
77 repo = self._repo
68 if repo._bookmarkcurrent not in self:
78 if repo._bookmarkcurrent not in self:
69 unsetcurrent(repo)
79 unsetcurrent(repo)
70
80
71 wlock = repo.wlock()
81 wlock = repo.wlock()
72 try:
82 try:
73
83
74 file = repo.vfs('bookmarks', 'w', atomictemp=True)
84 file = repo.vfs('bookmarks', 'w', atomictemp=True)
75 self._write(file)
85 self._write(file)
76 file.close()
86 file.close()
77
87
78 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed)
88 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed)
79 try:
89 try:
80 repo.svfs.utime('00changelog.i', None)
90 repo.svfs.utime('00changelog.i', None)
81 except OSError:
91 except OSError:
82 pass
92 pass
83
93
84 finally:
94 finally:
85 wlock.release()
95 wlock.release()
86
96
87 def _write(self, fp):
97 def _write(self, fp):
88 for name, node in self.iteritems():
98 for name, node in self.iteritems():
89 fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name)))
99 fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name)))
90
100
91 def readcurrent(repo):
101 def readcurrent(repo):
92 '''Get the current bookmark
102 '''Get the current bookmark
93
103
94 If we use gittish branches we have a current bookmark that
104 If we use gittish branches we have a current bookmark that
95 we are on. This function returns the name of the bookmark. It
105 we are on. This function returns the name of the bookmark. It
96 is stored in .hg/bookmarks.current
106 is stored in .hg/bookmarks.current
97 '''
107 '''
98 mark = None
108 mark = None
99 try:
109 try:
100 file = repo.opener('bookmarks.current')
110 file = repo.opener('bookmarks.current')
101 except IOError, inst:
111 except IOError, inst:
102 if inst.errno != errno.ENOENT:
112 if inst.errno != errno.ENOENT:
103 raise
113 raise
104 return None
114 return None
105 try:
115 try:
106 # No readline() in osutil.posixfile, reading everything is cheap
116 # No readline() in osutil.posixfile, reading everything is cheap
107 mark = encoding.tolocal((file.readlines() or [''])[0])
117 mark = encoding.tolocal((file.readlines() or [''])[0])
108 if mark == '' or mark not in repo._bookmarks:
118 if mark == '' or mark not in repo._bookmarks:
109 mark = None
119 mark = None
110 finally:
120 finally:
111 file.close()
121 file.close()
112 return mark
122 return mark
113
123
114 def setcurrent(repo, mark):
124 def setcurrent(repo, mark):
115 '''Set the name of the bookmark that we are currently on
125 '''Set the name of the bookmark that we are currently on
116
126
117 Set the name of the bookmark that we are on (hg update <bookmark>).
127 Set the name of the bookmark that we are on (hg update <bookmark>).
118 The name is recorded in .hg/bookmarks.current
128 The name is recorded in .hg/bookmarks.current
119 '''
129 '''
120 if mark not in repo._bookmarks:
130 if mark not in repo._bookmarks:
121 raise AssertionError('bookmark %s does not exist!' % mark)
131 raise AssertionError('bookmark %s does not exist!' % mark)
122
132
123 current = repo._bookmarkcurrent
133 current = repo._bookmarkcurrent
124 if current == mark:
134 if current == mark:
125 return
135 return
126
136
127 wlock = repo.wlock()
137 wlock = repo.wlock()
128 try:
138 try:
129 file = repo.opener('bookmarks.current', 'w', atomictemp=True)
139 file = repo.opener('bookmarks.current', 'w', atomictemp=True)
130 file.write(encoding.fromlocal(mark))
140 file.write(encoding.fromlocal(mark))
131 file.close()
141 file.close()
132 finally:
142 finally:
133 wlock.release()
143 wlock.release()
134 repo._bookmarkcurrent = mark
144 repo._bookmarkcurrent = mark
135
145
136 def unsetcurrent(repo):
146 def unsetcurrent(repo):
137 wlock = repo.wlock()
147 wlock = repo.wlock()
138 try:
148 try:
139 try:
149 try:
140 repo.vfs.unlink('bookmarks.current')
150 repo.vfs.unlink('bookmarks.current')
141 repo._bookmarkcurrent = None
151 repo._bookmarkcurrent = None
142 except OSError, inst:
152 except OSError, inst:
143 if inst.errno != errno.ENOENT:
153 if inst.errno != errno.ENOENT:
144 raise
154 raise
145 finally:
155 finally:
146 wlock.release()
156 wlock.release()
147
157
148 def iscurrent(repo, mark=None, parents=None):
158 def iscurrent(repo, mark=None, parents=None):
149 '''Tell whether the current bookmark is also active
159 '''Tell whether the current bookmark is also active
150
160
151 I.e., the bookmark listed in .hg/bookmarks.current also points to a
161 I.e., the bookmark listed in .hg/bookmarks.current also points to a
152 parent of the working directory.
162 parent of the working directory.
153 '''
163 '''
154 if not mark:
164 if not mark:
155 mark = repo._bookmarkcurrent
165 mark = repo._bookmarkcurrent
156 if not parents:
166 if not parents:
157 parents = [p.node() for p in repo[None].parents()]
167 parents = [p.node() for p in repo[None].parents()]
158 marks = repo._bookmarks
168 marks = repo._bookmarks
159 return (mark in marks and marks[mark] in parents)
169 return (mark in marks and marks[mark] in parents)
160
170
161 def updatecurrentbookmark(repo, oldnode, curbranch):
171 def updatecurrentbookmark(repo, oldnode, curbranch):
162 try:
172 try:
163 return update(repo, oldnode, repo.branchtip(curbranch))
173 return update(repo, oldnode, repo.branchtip(curbranch))
164 except error.RepoLookupError:
174 except error.RepoLookupError:
165 if curbranch == "default": # no default branch!
175 if curbranch == "default": # no default branch!
166 return update(repo, oldnode, repo.lookup("tip"))
176 return update(repo, oldnode, repo.lookup("tip"))
167 else:
177 else:
168 raise util.Abort(_("branch %s not found") % curbranch)
178 raise util.Abort(_("branch %s not found") % curbranch)
169
179
170 def deletedivergent(repo, deletefrom, bm):
180 def deletedivergent(repo, deletefrom, bm):
171 '''Delete divergent versions of bm on nodes in deletefrom.
181 '''Delete divergent versions of bm on nodes in deletefrom.
172
182
173 Return True if at least one bookmark was deleted, False otherwise.'''
183 Return True if at least one bookmark was deleted, False otherwise.'''
174 deleted = False
184 deleted = False
175 marks = repo._bookmarks
185 marks = repo._bookmarks
176 divergent = [b for b in marks if b.split('@', 1)[0] == bm.split('@', 1)[0]]
186 divergent = [b for b in marks if b.split('@', 1)[0] == bm.split('@', 1)[0]]
177 for mark in divergent:
187 for mark in divergent:
178 if mark == '@' or '@' not in mark:
188 if mark == '@' or '@' not in mark:
179 # can't be divergent by definition
189 # can't be divergent by definition
180 continue
190 continue
181 if mark and marks[mark] in deletefrom:
191 if mark and marks[mark] in deletefrom:
182 if mark != bm:
192 if mark != bm:
183 del marks[mark]
193 del marks[mark]
184 deleted = True
194 deleted = True
185 return deleted
195 return deleted
186
196
187 def calculateupdate(ui, repo, checkout):
197 def calculateupdate(ui, repo, checkout):
188 '''Return a tuple (targetrev, movemarkfrom) indicating the rev to
198 '''Return a tuple (targetrev, movemarkfrom) indicating the rev to
189 check out and where to move the active bookmark from, if needed.'''
199 check out and where to move the active bookmark from, if needed.'''
190 movemarkfrom = None
200 movemarkfrom = None
191 if checkout is None:
201 if checkout is None:
192 curmark = repo._bookmarkcurrent
202 curmark = repo._bookmarkcurrent
193 if iscurrent(repo):
203 if iscurrent(repo):
194 movemarkfrom = repo['.'].node()
204 movemarkfrom = repo['.'].node()
195 elif curmark:
205 elif curmark:
196 ui.status(_("updating to active bookmark %s\n") % curmark)
206 ui.status(_("updating to active bookmark %s\n") % curmark)
197 checkout = curmark
207 checkout = curmark
198 return (checkout, movemarkfrom)
208 return (checkout, movemarkfrom)
199
209
200 def update(repo, parents, node):
210 def update(repo, parents, node):
201 deletefrom = parents
211 deletefrom = parents
202 marks = repo._bookmarks
212 marks = repo._bookmarks
203 update = False
213 update = False
204 cur = repo._bookmarkcurrent
214 cur = repo._bookmarkcurrent
205 if not cur:
215 if not cur:
206 return False
216 return False
207
217
208 if marks[cur] in parents:
218 if marks[cur] in parents:
209 new = repo[node]
219 new = repo[node]
210 divs = [repo[b] for b in marks
220 divs = [repo[b] for b in marks
211 if b.split('@', 1)[0] == cur.split('@', 1)[0]]
221 if b.split('@', 1)[0] == cur.split('@', 1)[0]]
212 anc = repo.changelog.ancestors([new.rev()])
222 anc = repo.changelog.ancestors([new.rev()])
213 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
223 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
214 if validdest(repo, repo[marks[cur]], new):
224 if validdest(repo, repo[marks[cur]], new):
215 marks[cur] = new.node()
225 marks[cur] = new.node()
216 update = True
226 update = True
217
227
218 if deletedivergent(repo, deletefrom, cur):
228 if deletedivergent(repo, deletefrom, cur):
219 update = True
229 update = True
220
230
221 if update:
231 if update:
222 marks.write()
232 marks.write()
223 return update
233 return update
224
234
225 def listbookmarks(repo):
235 def listbookmarks(repo):
226 # We may try to list bookmarks on a repo type that does not
236 # We may try to list bookmarks on a repo type that does not
227 # support it (e.g., statichttprepository).
237 # support it (e.g., statichttprepository).
228 marks = getattr(repo, '_bookmarks', {})
238 marks = getattr(repo, '_bookmarks', {})
229
239
230 d = {}
240 d = {}
231 hasnode = repo.changelog.hasnode
241 hasnode = repo.changelog.hasnode
232 for k, v in marks.iteritems():
242 for k, v in marks.iteritems():
233 # don't expose local divergent bookmarks
243 # don't expose local divergent bookmarks
234 if hasnode(v) and ('@' not in k or k.endswith('@')):
244 if hasnode(v) and ('@' not in k or k.endswith('@')):
235 d[k] = hex(v)
245 d[k] = hex(v)
236 return d
246 return d
237
247
238 def pushbookmark(repo, key, old, new):
248 def pushbookmark(repo, key, old, new):
239 w = l = tr = None
249 w = l = tr = None
240 try:
250 try:
241 w = repo.wlock()
251 w = repo.wlock()
242 l = repo.lock()
252 l = repo.lock()
243 tr = repo.transaction('bookmarks')
253 tr = repo.transaction('bookmarks')
244 marks = repo._bookmarks
254 marks = repo._bookmarks
245 existing = hex(marks.get(key, ''))
255 existing = hex(marks.get(key, ''))
246 if existing != old and existing != new:
256 if existing != old and existing != new:
247 return False
257 return False
248 if new == '':
258 if new == '':
249 del marks[key]
259 del marks[key]
250 else:
260 else:
251 if new not in repo:
261 if new not in repo:
252 return False
262 return False
253 marks[key] = repo[new].node()
263 marks[key] = repo[new].node()
254 marks.recordchange(tr)
264 marks.recordchange(tr)
255 tr.close()
265 tr.close()
256 return True
266 return True
257 finally:
267 finally:
258 lockmod.release(tr, l, w)
268 lockmod.release(tr, l, w)
259
269
260 def compare(repo, srcmarks, dstmarks,
270 def compare(repo, srcmarks, dstmarks,
261 srchex=None, dsthex=None, targets=None):
271 srchex=None, dsthex=None, targets=None):
262 '''Compare bookmarks between srcmarks and dstmarks
272 '''Compare bookmarks between srcmarks and dstmarks
263
273
264 This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
274 This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
265 differ, invalid)", each are list of bookmarks below:
275 differ, invalid)", each are list of bookmarks below:
266
276
267 :addsrc: added on src side (removed on dst side, perhaps)
277 :addsrc: added on src side (removed on dst side, perhaps)
268 :adddst: added on dst side (removed on src side, perhaps)
278 :adddst: added on dst side (removed on src side, perhaps)
269 :advsrc: advanced on src side
279 :advsrc: advanced on src side
270 :advdst: advanced on dst side
280 :advdst: advanced on dst side
271 :diverge: diverge
281 :diverge: diverge
272 :differ: changed, but changeset referred on src is unknown on dst
282 :differ: changed, but changeset referred on src is unknown on dst
273 :invalid: unknown on both side
283 :invalid: unknown on both side
274 :same: same on both side
284 :same: same on both side
275
285
276 Each elements of lists in result tuple is tuple "(bookmark name,
286 Each elements of lists in result tuple is tuple "(bookmark name,
277 changeset ID on source side, changeset ID on destination
287 changeset ID on source side, changeset ID on destination
278 side)". Each changeset IDs are 40 hexadecimal digit string or
288 side)". Each changeset IDs are 40 hexadecimal digit string or
279 None.
289 None.
280
290
281 Changeset IDs of tuples in "addsrc", "adddst", "differ" or
291 Changeset IDs of tuples in "addsrc", "adddst", "differ" or
282 "invalid" list may be unknown for repo.
292 "invalid" list may be unknown for repo.
283
293
284 This function expects that "srcmarks" and "dstmarks" return
294 This function expects that "srcmarks" and "dstmarks" return
285 changeset ID in 40 hexadecimal digit string for specified
295 changeset ID in 40 hexadecimal digit string for specified
286 bookmark. If not so (e.g. bmstore "repo._bookmarks" returning
296 bookmark. If not so (e.g. bmstore "repo._bookmarks" returning
287 binary value), "srchex" or "dsthex" should be specified to convert
297 binary value), "srchex" or "dsthex" should be specified to convert
288 into such form.
298 into such form.
289
299
290 If "targets" is specified, only bookmarks listed in it are
300 If "targets" is specified, only bookmarks listed in it are
291 examined.
301 examined.
292 '''
302 '''
293 if not srchex:
303 if not srchex:
294 srchex = lambda x: x
304 srchex = lambda x: x
295 if not dsthex:
305 if not dsthex:
296 dsthex = lambda x: x
306 dsthex = lambda x: x
297
307
298 if targets:
308 if targets:
299 bset = set(targets)
309 bset = set(targets)
300 else:
310 else:
301 srcmarkset = set(srcmarks)
311 srcmarkset = set(srcmarks)
302 dstmarkset = set(dstmarks)
312 dstmarkset = set(dstmarks)
303 bset = srcmarkset | dstmarkset
313 bset = srcmarkset | dstmarkset
304
314
305 results = ([], [], [], [], [], [], [], [])
315 results = ([], [], [], [], [], [], [], [])
306 addsrc = results[0].append
316 addsrc = results[0].append
307 adddst = results[1].append
317 adddst = results[1].append
308 advsrc = results[2].append
318 advsrc = results[2].append
309 advdst = results[3].append
319 advdst = results[3].append
310 diverge = results[4].append
320 diverge = results[4].append
311 differ = results[5].append
321 differ = results[5].append
312 invalid = results[6].append
322 invalid = results[6].append
313 same = results[7].append
323 same = results[7].append
314
324
315 for b in sorted(bset):
325 for b in sorted(bset):
316 if b not in srcmarks:
326 if b not in srcmarks:
317 if b in dstmarks:
327 if b in dstmarks:
318 adddst((b, None, dsthex(dstmarks[b])))
328 adddst((b, None, dsthex(dstmarks[b])))
319 else:
329 else:
320 invalid((b, None, None))
330 invalid((b, None, None))
321 elif b not in dstmarks:
331 elif b not in dstmarks:
322 addsrc((b, srchex(srcmarks[b]), None))
332 addsrc((b, srchex(srcmarks[b]), None))
323 else:
333 else:
324 scid = srchex(srcmarks[b])
334 scid = srchex(srcmarks[b])
325 dcid = dsthex(dstmarks[b])
335 dcid = dsthex(dstmarks[b])
326 if scid == dcid:
336 if scid == dcid:
327 same((b, scid, dcid))
337 same((b, scid, dcid))
328 elif scid in repo and dcid in repo:
338 elif scid in repo and dcid in repo:
329 sctx = repo[scid]
339 sctx = repo[scid]
330 dctx = repo[dcid]
340 dctx = repo[dcid]
331 if sctx.rev() < dctx.rev():
341 if sctx.rev() < dctx.rev():
332 if validdest(repo, sctx, dctx):
342 if validdest(repo, sctx, dctx):
333 advdst((b, scid, dcid))
343 advdst((b, scid, dcid))
334 else:
344 else:
335 diverge((b, scid, dcid))
345 diverge((b, scid, dcid))
336 else:
346 else:
337 if validdest(repo, dctx, sctx):
347 if validdest(repo, dctx, sctx):
338 advsrc((b, scid, dcid))
348 advsrc((b, scid, dcid))
339 else:
349 else:
340 diverge((b, scid, dcid))
350 diverge((b, scid, dcid))
341 else:
351 else:
342 # it is too expensive to examine in detail, in this case
352 # it is too expensive to examine in detail, in this case
343 differ((b, scid, dcid))
353 differ((b, scid, dcid))
344
354
345 return results
355 return results
346
356
347 def _diverge(ui, b, path, localmarks):
357 def _diverge(ui, b, path, localmarks):
348 if b == '@':
358 if b == '@':
349 b = ''
359 b = ''
350 # find a unique @ suffix
360 # find a unique @ suffix
351 for x in range(1, 100):
361 for x in range(1, 100):
352 n = '%s@%d' % (b, x)
362 n = '%s@%d' % (b, x)
353 if n not in localmarks:
363 if n not in localmarks:
354 break
364 break
355 # try to use an @pathalias suffix
365 # try to use an @pathalias suffix
356 # if an @pathalias already exists, we overwrite (update) it
366 # if an @pathalias already exists, we overwrite (update) it
357 if path.startswith("file:"):
367 if path.startswith("file:"):
358 path = util.url(path).path
368 path = util.url(path).path
359 for p, u in ui.configitems("paths"):
369 for p, u in ui.configitems("paths"):
360 if u.startswith("file:"):
370 if u.startswith("file:"):
361 u = util.url(u).path
371 u = util.url(u).path
362 if path == u:
372 if path == u:
363 n = '%s@%s' % (b, p)
373 n = '%s@%s' % (b, p)
364 return n
374 return n
365
375
366 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
376 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
367 ui.debug("checking for updated bookmarks\n")
377 ui.debug("checking for updated bookmarks\n")
368 localmarks = repo._bookmarks
378 localmarks = repo._bookmarks
369 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
379 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
370 ) = compare(repo, remotemarks, localmarks, dsthex=hex)
380 ) = compare(repo, remotemarks, localmarks, dsthex=hex)
371
381
372 status = ui.status
382 status = ui.status
373 warn = ui.warn
383 warn = ui.warn
374 if ui.configbool('ui', 'quietbookmarkmove', False):
384 if ui.configbool('ui', 'quietbookmarkmove', False):
375 status = warn = ui.debug
385 status = warn = ui.debug
376
386
377 explicit = set(explicit)
387 explicit = set(explicit)
378 changed = []
388 changed = []
379 for b, scid, dcid in addsrc:
389 for b, scid, dcid in addsrc:
380 if scid in repo: # add remote bookmarks for changes we already have
390 if scid in repo: # add remote bookmarks for changes we already have
381 changed.append((b, bin(scid), status,
391 changed.append((b, bin(scid), status,
382 _("adding remote bookmark %s\n") % (b)))
392 _("adding remote bookmark %s\n") % (b)))
383 for b, scid, dcid in advsrc:
393 for b, scid, dcid in advsrc:
384 changed.append((b, bin(scid), status,
394 changed.append((b, bin(scid), status,
385 _("updating bookmark %s\n") % (b)))
395 _("updating bookmark %s\n") % (b)))
386 # remove normal movement from explicit set
396 # remove normal movement from explicit set
387 explicit.difference_update(d[0] for d in changed)
397 explicit.difference_update(d[0] for d in changed)
388
398
389 for b, scid, dcid in diverge:
399 for b, scid, dcid in diverge:
390 if b in explicit:
400 if b in explicit:
391 explicit.discard(b)
401 explicit.discard(b)
392 changed.append((b, bin(scid), status,
402 changed.append((b, bin(scid), status,
393 _("importing bookmark %s\n") % (b)))
403 _("importing bookmark %s\n") % (b)))
394 else:
404 else:
395 db = _diverge(ui, b, path, localmarks)
405 db = _diverge(ui, b, path, localmarks)
396 changed.append((db, bin(scid), warn,
406 changed.append((db, bin(scid), warn,
397 _("divergent bookmark %s stored as %s\n")
407 _("divergent bookmark %s stored as %s\n")
398 % (b, db)))
408 % (b, db)))
399 for b, scid, dcid in adddst + advdst:
409 for b, scid, dcid in adddst + advdst:
400 if b in explicit:
410 if b in explicit:
401 explicit.discard(b)
411 explicit.discard(b)
402 changed.append((b, bin(scid), status,
412 changed.append((b, bin(scid), status,
403 _("importing bookmark %s\n") % (b)))
413 _("importing bookmark %s\n") % (b)))
404
414
405 if changed:
415 if changed:
406 tr = trfunc()
416 tr = trfunc()
407 for b, node, writer, msg in sorted(changed):
417 for b, node, writer, msg in sorted(changed):
408 localmarks[b] = node
418 localmarks[b] = node
409 writer(msg)
419 writer(msg)
410 localmarks.recordchange(tr)
420 localmarks.recordchange(tr)
411
421
412 def diff(ui, dst, src):
422 def diff(ui, dst, src):
413 ui.status(_("searching for changed bookmarks\n"))
423 ui.status(_("searching for changed bookmarks\n"))
414
424
415 smarks = src.listkeys('bookmarks')
425 smarks = src.listkeys('bookmarks')
416 dmarks = dst.listkeys('bookmarks')
426 dmarks = dst.listkeys('bookmarks')
417
427
418 diff = sorted(set(smarks) - set(dmarks))
428 diff = sorted(set(smarks) - set(dmarks))
419 for k in diff:
429 for k in diff:
420 mark = ui.debugflag and smarks[k] or smarks[k][:12]
430 mark = ui.debugflag and smarks[k] or smarks[k][:12]
421 ui.write(" %-25s %s\n" % (k, mark))
431 ui.write(" %-25s %s\n" % (k, mark))
422
432
423 if len(diff) <= 0:
433 if len(diff) <= 0:
424 ui.status(_("no changed bookmarks found\n"))
434 ui.status(_("no changed bookmarks found\n"))
425 return 1
435 return 1
426 return 0
436 return 0
427
437
428 def validdest(repo, old, new):
438 def validdest(repo, old, new):
429 """Is the new bookmark destination a valid update from the old one"""
439 """Is the new bookmark destination a valid update from the old one"""
430 repo = repo.unfiltered()
440 repo = repo.unfiltered()
431 if old == new:
441 if old == new:
432 # Old == new -> nothing to update.
442 # Old == new -> nothing to update.
433 return False
443 return False
434 elif not old:
444 elif not old:
435 # old is nullrev, anything is valid.
445 # old is nullrev, anything is valid.
436 # (new != nullrev has been excluded by the previous check)
446 # (new != nullrev has been excluded by the previous check)
437 return True
447 return True
438 elif repo.obsstore:
448 elif repo.obsstore:
439 return new.node() in obsolete.foreground(repo, [old.node()])
449 return new.node() in obsolete.foreground(repo, [old.node()])
440 else:
450 else:
441 # still an independent clause as it is lazyer (and therefore faster)
451 # still an independent clause as it is lazyer (and therefore faster)
442 return old.descendant(new)
452 return old.descendant(new)
@@ -1,519 +1,519
1 Test exchange of common information using bundle2
1 Test exchange of common information using bundle2
2
2
3
3
4 $ getmainid() {
4 $ getmainid() {
5 > hg -R main log --template '{node}\n' --rev "$1"
5 > hg -R main log --template '{node}\n' --rev "$1"
6 > }
6 > }
7
7
8 enable obsolescence
8 enable obsolescence
9
9
10 $ cat >> $HGRCPATH << EOF
10 $ cat >> $HGRCPATH << EOF
11 > [experimental]
11 > [experimental]
12 > evolution=createmarkers,exchange
12 > evolution=createmarkers,exchange
13 > bundle2-exp=True
13 > bundle2-exp=True
14 > [ui]
14 > [ui]
15 > ssh=python "$TESTDIR/dummyssh"
15 > ssh=python "$TESTDIR/dummyssh"
16 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
16 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
17 > [web]
17 > [web]
18 > push_ssl = false
18 > push_ssl = false
19 > allow_push = *
19 > allow_push = *
20 > [phases]
20 > [phases]
21 > publish=False
21 > publish=False
22 > [hooks]
22 > [hooks]
23 > changegroup = sh -c "HG_LOCAL= python \"$TESTDIR/printenv.py\" changegroup"
23 > changegroup = sh -c "HG_LOCAL= python \"$TESTDIR/printenv.py\" changegroup"
24 > b2x-pretransactionclose.tip = printf 'pre-close-tip:'; hg log -r tip -T '{node|short} {phase} {bookmarks}\n'
24 > b2x-pretransactionclose.tip = printf 'pre-close-tip:'; hg log -r tip -T '{node|short} {phase} {bookmarks}\n'
25 > b2x-transactionclose.tip = printf 'postclose-tip:'; hg log -r tip -T '{node|short} {phase} {bookmarks}\n'
25 > b2x-transactionclose.tip = printf 'postclose-tip:'; hg log -r tip -T '{node|short} {phase} {bookmarks}\n'
26 > b2x-transactionclose.env = sh -c "HG_LOCAL= python \"$TESTDIR/printenv.py\" b2x-transactionclose"
26 > b2x-transactionclose.env = sh -c "HG_LOCAL= python \"$TESTDIR/printenv.py\" b2x-transactionclose"
27 > EOF
27 > EOF
28
28
29 The extension requires a repo (currently unused)
29 The extension requires a repo (currently unused)
30
30
31 $ hg init main
31 $ hg init main
32 $ cd main
32 $ cd main
33 $ touch a
33 $ touch a
34 $ hg add a
34 $ hg add a
35 $ hg commit -m 'a'
35 $ hg commit -m 'a'
36
36
37 $ hg unbundle $TESTDIR/bundles/rebase.hg
37 $ hg unbundle $TESTDIR/bundles/rebase.hg
38 adding changesets
38 adding changesets
39 adding manifests
39 adding manifests
40 adding file changes
40 adding file changes
41 added 8 changesets with 7 changes to 7 files (+3 heads)
41 added 8 changesets with 7 changes to 7 files (+3 heads)
42 changegroup hook: HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_SOURCE=unbundle HG_URL=bundle:*/rebase.hg (glob)
42 changegroup hook: HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_SOURCE=unbundle HG_URL=bundle:*/rebase.hg (glob)
43 (run 'hg heads' to see heads, 'hg merge' to merge)
43 (run 'hg heads' to see heads, 'hg merge' to merge)
44
44
45 $ cd ..
45 $ cd ..
46
46
47 Real world exchange
47 Real world exchange
48 =====================
48 =====================
49
49
50 Add more obsolescence information
50 Add more obsolescence information
51
51
52 $ hg -R main debugobsolete -d '0 0' 1111111111111111111111111111111111111111 `getmainid 9520eea781bc`
52 $ hg -R main debugobsolete -d '0 0' 1111111111111111111111111111111111111111 `getmainid 9520eea781bc`
53 $ hg -R main debugobsolete -d '0 0' 2222222222222222222222222222222222222222 `getmainid 24b6387c8c8c`
53 $ hg -R main debugobsolete -d '0 0' 2222222222222222222222222222222222222222 `getmainid 24b6387c8c8c`
54
54
55 clone --pull
55 clone --pull
56
56
57 $ hg -R main phase --public cd010b8cd998
57 $ hg -R main phase --public cd010b8cd998
58 $ hg clone main other --pull --rev 9520eea781bc
58 $ hg clone main other --pull --rev 9520eea781bc
59 adding changesets
59 adding changesets
60 adding manifests
60 adding manifests
61 adding file changes
61 adding file changes
62 added 2 changesets with 2 changes to 2 files
62 added 2 changesets with 2 changes to 2 files
63 1 new obsolescence markers
63 1 new obsolescence markers
64 pre-close-tip:9520eea781bc public
64 pre-close-tip:9520eea781bc public
65 postclose-tip:9520eea781bc draft
65 postclose-tip:9520eea781bc draft
66 b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
66 b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
67 changegroup hook: HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
67 changegroup hook: HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
68 updating to branch default
68 updating to branch default
69 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 $ hg -R other log -G
70 $ hg -R other log -G
71 @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
71 @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
72 |
72 |
73 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
73 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
74
74
75 $ hg -R other debugobsolete
75 $ hg -R other debugobsolete
76 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
76 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
77
77
78 pull
78 pull
79
79
80 $ hg -R main phase --public 9520eea781bc
80 $ hg -R main phase --public 9520eea781bc
81 $ hg -R other pull -r 24b6387c8c8c
81 $ hg -R other pull -r 24b6387c8c8c
82 pulling from $TESTTMP/main (glob)
82 pulling from $TESTTMP/main (glob)
83 searching for changes
83 searching for changes
84 adding changesets
84 adding changesets
85 adding manifests
85 adding manifests
86 adding file changes
86 adding file changes
87 added 1 changesets with 1 changes to 1 files (+1 heads)
87 added 1 changesets with 1 changes to 1 files (+1 heads)
88 1 new obsolescence markers
88 1 new obsolescence markers
89 pre-close-tip:24b6387c8c8c public
89 pre-close-tip:24b6387c8c8c public
90 postclose-tip:24b6387c8c8c draft
90 postclose-tip:24b6387c8c8c draft
91 b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
91 b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
92 changegroup hook: HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
92 changegroup hook: HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
93 (run 'hg heads' to see heads, 'hg merge' to merge)
93 (run 'hg heads' to see heads, 'hg merge' to merge)
94 $ hg -R other log -G
94 $ hg -R other log -G
95 o 2:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
95 o 2:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
96 |
96 |
97 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
97 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
98 |/
98 |/
99 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
99 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
100
100
101 $ hg -R other debugobsolete
101 $ hg -R other debugobsolete
102 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
102 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
103 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
103 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
104
104
105 pull empty (with phase movement)
105 pull empty (with phase movement)
106
106
107 $ hg -R main phase --public 24b6387c8c8c
107 $ hg -R main phase --public 24b6387c8c8c
108 $ hg -R other pull -r 24b6387c8c8c
108 $ hg -R other pull -r 24b6387c8c8c
109 pulling from $TESTTMP/main (glob)
109 pulling from $TESTTMP/main (glob)
110 no changes found
110 no changes found
111 pre-close-tip:000000000000 public
111 pre-close-tip:000000000000 public
112 postclose-tip:24b6387c8c8c public
112 postclose-tip:24b6387c8c8c public
113 b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
113 b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
114 $ hg -R other log -G
114 $ hg -R other log -G
115 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
115 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
116 |
116 |
117 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
117 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
118 |/
118 |/
119 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
119 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
120
120
121 $ hg -R other debugobsolete
121 $ hg -R other debugobsolete
122 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
122 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
123 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
123 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
124
124
125 pull empty
125 pull empty
126
126
127 $ hg -R other pull -r 24b6387c8c8c
127 $ hg -R other pull -r 24b6387c8c8c
128 pulling from $TESTTMP/main (glob)
128 pulling from $TESTTMP/main (glob)
129 no changes found
129 no changes found
130 pre-close-tip:24b6387c8c8c public
130 pre-close-tip:24b6387c8c8c public
131 postclose-tip:24b6387c8c8c public
131 postclose-tip:24b6387c8c8c public
132 b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
132 b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
133 $ hg -R other log -G
133 $ hg -R other log -G
134 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
134 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
135 |
135 |
136 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
136 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
137 |/
137 |/
138 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
138 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
139
139
140 $ hg -R other debugobsolete
140 $ hg -R other debugobsolete
141 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
141 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
142 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
142 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
143
143
144 add extra data to test their exchange during push
144 add extra data to test their exchange during push
145
145
146 $ hg -R main bookmark --rev eea13746799a book_eea1
146 $ hg -R main bookmark --rev eea13746799a book_eea1
147 $ hg -R main debugobsolete -d '0 0' 3333333333333333333333333333333333333333 `getmainid eea13746799a`
147 $ hg -R main debugobsolete -d '0 0' 3333333333333333333333333333333333333333 `getmainid eea13746799a`
148 $ hg -R main bookmark --rev 02de42196ebe book_02de
148 $ hg -R main bookmark --rev 02de42196ebe book_02de
149 $ hg -R main debugobsolete -d '0 0' 4444444444444444444444444444444444444444 `getmainid 02de42196ebe`
149 $ hg -R main debugobsolete -d '0 0' 4444444444444444444444444444444444444444 `getmainid 02de42196ebe`
150 $ hg -R main bookmark --rev 42ccdea3bb16 book_42cc
150 $ hg -R main bookmark --rev 42ccdea3bb16 book_42cc
151 $ hg -R main debugobsolete -d '0 0' 5555555555555555555555555555555555555555 `getmainid 42ccdea3bb16`
151 $ hg -R main debugobsolete -d '0 0' 5555555555555555555555555555555555555555 `getmainid 42ccdea3bb16`
152 $ hg -R main bookmark --rev 5fddd98957c8 book_5fdd
152 $ hg -R main bookmark --rev 5fddd98957c8 book_5fdd
153 $ hg -R main debugobsolete -d '0 0' 6666666666666666666666666666666666666666 `getmainid 5fddd98957c8`
153 $ hg -R main debugobsolete -d '0 0' 6666666666666666666666666666666666666666 `getmainid 5fddd98957c8`
154 $ hg -R main bookmark --rev 32af7686d403 book_32af
154 $ hg -R main bookmark --rev 32af7686d403 book_32af
155 $ hg -R main debugobsolete -d '0 0' 7777777777777777777777777777777777777777 `getmainid 32af7686d403`
155 $ hg -R main debugobsolete -d '0 0' 7777777777777777777777777777777777777777 `getmainid 32af7686d403`
156
156
157 $ hg -R other bookmark --rev cd010b8cd998 book_eea1
157 $ hg -R other bookmark --rev cd010b8cd998 book_eea1
158 $ hg -R other bookmark --rev cd010b8cd998 book_02de
158 $ hg -R other bookmark --rev cd010b8cd998 book_02de
159 $ hg -R other bookmark --rev cd010b8cd998 book_42cc
159 $ hg -R other bookmark --rev cd010b8cd998 book_42cc
160 $ hg -R other bookmark --rev cd010b8cd998 book_5fdd
160 $ hg -R other bookmark --rev cd010b8cd998 book_5fdd
161 $ hg -R other bookmark --rev cd010b8cd998 book_32af
161 $ hg -R other bookmark --rev cd010b8cd998 book_32af
162
162
163 $ hg -R main phase --public eea13746799a
163 $ hg -R main phase --public eea13746799a
164
164
165 push
165 push
166 $ hg -R main push other --rev eea13746799a --bookmark book_eea1
166 $ hg -R main push other --rev eea13746799a --bookmark book_eea1
167 pushing to other
167 pushing to other
168 searching for changes
168 searching for changes
169 pre-close-tip:eea13746799a draft
169 pre-close-tip:eea13746799a draft book_eea1
170 postclose-tip:eea13746799a public book_eea1
170 postclose-tip:eea13746799a public book_eea1
171 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
171 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
172 changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_SOURCE=push HG_URL=push
172 changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_SOURCE=push HG_URL=push
173 remote: adding changesets
173 remote: adding changesets
174 remote: adding manifests
174 remote: adding manifests
175 remote: adding file changes
175 remote: adding file changes
176 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
176 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
177 remote: 1 new obsolescence markers
177 remote: 1 new obsolescence markers
178 updating bookmark book_eea1
178 updating bookmark book_eea1
179 $ hg -R other log -G
179 $ hg -R other log -G
180 o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
180 o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
181 |\
181 |\
182 | o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
182 | o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
183 | |
183 | |
184 @ | 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
184 @ | 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
185 |/
185 |/
186 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de book_32af book_42cc book_5fdd A
186 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de book_32af book_42cc book_5fdd A
187
187
188 $ hg -R other debugobsolete
188 $ hg -R other debugobsolete
189 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
189 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
190 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
190 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
191 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
191 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
192
192
193 pull over ssh
193 pull over ssh
194
194
195 $ hg -R other pull ssh://user@dummy/main -r 02de42196ebe --bookmark book_02de
195 $ hg -R other pull ssh://user@dummy/main -r 02de42196ebe --bookmark book_02de
196 pulling from ssh://user@dummy/main
196 pulling from ssh://user@dummy/main
197 searching for changes
197 searching for changes
198 adding changesets
198 adding changesets
199 adding manifests
199 adding manifests
200 adding file changes
200 adding file changes
201 added 1 changesets with 1 changes to 1 files (+1 heads)
201 added 1 changesets with 1 changes to 1 files (+1 heads)
202 1 new obsolescence markers
202 1 new obsolescence markers
203 updating bookmark book_02de
203 updating bookmark book_02de
204 pre-close-tip:02de42196ebe public
204 pre-close-tip:02de42196ebe public book_02de
205 postclose-tip:02de42196ebe draft book_02de
205 postclose-tip:02de42196ebe draft book_02de
206 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
206 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
207 changegroup hook: HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
207 changegroup hook: HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
208 (run 'hg heads' to see heads, 'hg merge' to merge)
208 (run 'hg heads' to see heads, 'hg merge' to merge)
209 $ hg -R other debugobsolete
209 $ hg -R other debugobsolete
210 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
210 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
211 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
211 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
212 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
212 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
213 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
213 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
214
214
215 pull over http
215 pull over http
216
216
217 $ hg -R main serve -p $HGPORT -d --pid-file=main.pid -E main-error.log
217 $ hg -R main serve -p $HGPORT -d --pid-file=main.pid -E main-error.log
218 $ cat main.pid >> $DAEMON_PIDS
218 $ cat main.pid >> $DAEMON_PIDS
219
219
220 $ hg -R other pull http://localhost:$HGPORT/ -r 42ccdea3bb16 --bookmark book_42cc
220 $ hg -R other pull http://localhost:$HGPORT/ -r 42ccdea3bb16 --bookmark book_42cc
221 pulling from http://localhost:$HGPORT/
221 pulling from http://localhost:$HGPORT/
222 searching for changes
222 searching for changes
223 adding changesets
223 adding changesets
224 adding manifests
224 adding manifests
225 adding file changes
225 adding file changes
226 added 1 changesets with 1 changes to 1 files (+1 heads)
226 added 1 changesets with 1 changes to 1 files (+1 heads)
227 1 new obsolescence markers
227 1 new obsolescence markers
228 updating bookmark book_42cc
228 updating bookmark book_42cc
229 pre-close-tip:42ccdea3bb16 public
229 pre-close-tip:42ccdea3bb16 public book_42cc
230 postclose-tip:42ccdea3bb16 draft book_42cc
230 postclose-tip:42ccdea3bb16 draft book_42cc
231 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
231 b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
232 changegroup hook: HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
232 changegroup hook: HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
233 (run 'hg heads .' to see heads, 'hg merge' to merge)
233 (run 'hg heads .' to see heads, 'hg merge' to merge)
234 $ cat main-error.log
234 $ cat main-error.log
235 $ hg -R other debugobsolete
235 $ hg -R other debugobsolete
236 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
236 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
237 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
237 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
238 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
238 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
239 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
239 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
240 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
240 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
241
241
242 push over ssh
242 push over ssh
243
243
244 $ hg -R main push ssh://user@dummy/other -r 5fddd98957c8 --bookmark book_5fdd
244 $ hg -R main push ssh://user@dummy/other -r 5fddd98957c8 --bookmark book_5fdd
245 pushing to ssh://user@dummy/other
245 pushing to ssh://user@dummy/other
246 searching for changes
246 searching for changes
247 remote: adding changesets
247 remote: adding changesets
248 remote: adding manifests
248 remote: adding manifests
249 remote: adding file changes
249 remote: adding file changes
250 remote: added 1 changesets with 1 changes to 1 files
250 remote: added 1 changesets with 1 changes to 1 files
251 remote: 1 new obsolescence markers
251 remote: 1 new obsolescence markers
252 updating bookmark book_5fdd
252 updating bookmark book_5fdd
253 remote: pre-close-tip:5fddd98957c8 draft
253 remote: pre-close-tip:5fddd98957c8 draft book_5fdd
254 remote: postclose-tip:5fddd98957c8 draft book_5fdd
254 remote: postclose-tip:5fddd98957c8 draft book_5fdd
255 remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
255 remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
256 remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
256 remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
257 $ hg -R other log -G
257 $ hg -R other log -G
258 o 6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
258 o 6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
259 |
259 |
260 o 5:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
260 o 5:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
261 |
261 |
262 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
262 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
263 | |
263 | |
264 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
264 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
265 | |/|
265 | |/|
266 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
266 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
267 |/ /
267 |/ /
268 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
268 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
269 |/
269 |/
270 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af A
270 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af A
271
271
272 $ hg -R other debugobsolete
272 $ hg -R other debugobsolete
273 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
273 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
274 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
274 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
275 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
275 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
276 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
276 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
277 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
277 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
278 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
278 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
279
279
280 push over http
280 push over http
281
281
282 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
282 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
283 $ cat other.pid >> $DAEMON_PIDS
283 $ cat other.pid >> $DAEMON_PIDS
284
284
285 $ hg -R main phase --public 32af7686d403
285 $ hg -R main phase --public 32af7686d403
286 $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403 --bookmark book_32af
286 $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403 --bookmark book_32af
287 pushing to http://localhost:$HGPORT2/
287 pushing to http://localhost:$HGPORT2/
288 searching for changes
288 searching for changes
289 remote: adding changesets
289 remote: adding changesets
290 remote: adding manifests
290 remote: adding manifests
291 remote: adding file changes
291 remote: adding file changes
292 remote: added 1 changesets with 1 changes to 1 files
292 remote: added 1 changesets with 1 changes to 1 files
293 remote: 1 new obsolescence markers
293 remote: 1 new obsolescence markers
294 updating bookmark book_32af
294 updating bookmark book_32af
295 $ cat other-error.log
295 $ cat other-error.log
296
296
297 Check final content.
297 Check final content.
298
298
299 $ hg -R other log -G
299 $ hg -R other log -G
300 o 7:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af D
300 o 7:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af D
301 |
301 |
302 o 6:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
302 o 6:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
303 |
303 |
304 o 5:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
304 o 5:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
305 |
305 |
306 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
306 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
307 | |
307 | |
308 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
308 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
309 | |/|
309 | |/|
310 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
310 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
311 |/ /
311 |/ /
312 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
312 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
313 |/
313 |/
314 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
314 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
315
315
316 $ hg -R other debugobsolete
316 $ hg -R other debugobsolete
317 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
317 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
318 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
318 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
319 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
319 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
320 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
320 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
321 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
321 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
322 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
322 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
323 7777777777777777777777777777777777777777 32af7686d403cf45b5d95f2d70cebea587ac806a 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
323 7777777777777777777777777777777777777777 32af7686d403cf45b5d95f2d70cebea587ac806a 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
324
324
325 (check that no 'pending' files remain)
325 (check that no 'pending' files remain)
326
326
327 $ ls -1 other/.hg/bookmarks*
327 $ ls -1 other/.hg/bookmarks*
328 other/.hg/bookmarks
328 other/.hg/bookmarks
329 $ ls -1 other/.hg/store/phaseroots*
329 $ ls -1 other/.hg/store/phaseroots*
330 other/.hg/store/phaseroots
330 other/.hg/store/phaseroots
331 $ ls -1 other/.hg/store/00changelog.i*
331 $ ls -1 other/.hg/store/00changelog.i*
332 other/.hg/store/00changelog.i
332 other/.hg/store/00changelog.i
333
333
334 Error Handling
334 Error Handling
335 ==============
335 ==============
336
336
337 Check that errors are properly returned to the client during push.
337 Check that errors are properly returned to the client during push.
338
338
339 Setting up
339 Setting up
340
340
341 $ cat > failpush.py << EOF
341 $ cat > failpush.py << EOF
342 > """A small extension that makes push fails when using bundle2
342 > """A small extension that makes push fails when using bundle2
343 >
343 >
344 > used to test error handling in bundle2
344 > used to test error handling in bundle2
345 > """
345 > """
346 >
346 >
347 > from mercurial import util
347 > from mercurial import util
348 > from mercurial import bundle2
348 > from mercurial import bundle2
349 > from mercurial import exchange
349 > from mercurial import exchange
350 > from mercurial import extensions
350 > from mercurial import extensions
351 >
351 >
352 > def _pushbundle2failpart(pushop, bundler):
352 > def _pushbundle2failpart(pushop, bundler):
353 > reason = pushop.ui.config('failpush', 'reason', None)
353 > reason = pushop.ui.config('failpush', 'reason', None)
354 > part = None
354 > part = None
355 > if reason == 'abort':
355 > if reason == 'abort':
356 > bundler.newpart('test:abort')
356 > bundler.newpart('test:abort')
357 > if reason == 'unknown':
357 > if reason == 'unknown':
358 > bundler.newpart('TEST:UNKNOWN')
358 > bundler.newpart('TEST:UNKNOWN')
359 > if reason == 'race':
359 > if reason == 'race':
360 > # 20 Bytes of crap
360 > # 20 Bytes of crap
361 > bundler.newpart('b2x:check:heads', data='01234567890123456789')
361 > bundler.newpart('b2x:check:heads', data='01234567890123456789')
362 >
362 >
363 > @bundle2.parthandler("test:abort")
363 > @bundle2.parthandler("test:abort")
364 > def handleabort(op, part):
364 > def handleabort(op, part):
365 > raise util.Abort('Abandon ship!', hint="don't panic")
365 > raise util.Abort('Abandon ship!', hint="don't panic")
366 >
366 >
367 > def uisetup(ui):
367 > def uisetup(ui):
368 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
368 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
369 > exchange.b2partsgenorder.insert(0, 'failpart')
369 > exchange.b2partsgenorder.insert(0, 'failpart')
370 >
370 >
371 > EOF
371 > EOF
372
372
373 $ cd main
373 $ cd main
374 $ hg up tip
374 $ hg up tip
375 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
375 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
376 $ echo 'I' > I
376 $ echo 'I' > I
377 $ hg add I
377 $ hg add I
378 $ hg ci -m 'I'
378 $ hg ci -m 'I'
379 $ hg id
379 $ hg id
380 e7ec4e813ba6 tip
380 e7ec4e813ba6 tip
381 $ cd ..
381 $ cd ..
382
382
383 $ cat << EOF >> $HGRCPATH
383 $ cat << EOF >> $HGRCPATH
384 > [extensions]
384 > [extensions]
385 > failpush=$TESTTMP/failpush.py
385 > failpush=$TESTTMP/failpush.py
386 > EOF
386 > EOF
387
387
388 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
388 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
389 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
389 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
390 $ cat other.pid >> $DAEMON_PIDS
390 $ cat other.pid >> $DAEMON_PIDS
391
391
392 Doing the actual push: Abort error
392 Doing the actual push: Abort error
393
393
394 $ cat << EOF >> $HGRCPATH
394 $ cat << EOF >> $HGRCPATH
395 > [failpush]
395 > [failpush]
396 > reason = abort
396 > reason = abort
397 > EOF
397 > EOF
398
398
399 $ hg -R main push other -r e7ec4e813ba6
399 $ hg -R main push other -r e7ec4e813ba6
400 pushing to other
400 pushing to other
401 searching for changes
401 searching for changes
402 abort: Abandon ship!
402 abort: Abandon ship!
403 (don't panic)
403 (don't panic)
404 [255]
404 [255]
405
405
406 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
406 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
407 pushing to ssh://user@dummy/other
407 pushing to ssh://user@dummy/other
408 searching for changes
408 searching for changes
409 abort: Abandon ship!
409 abort: Abandon ship!
410 (don't panic)
410 (don't panic)
411 [255]
411 [255]
412
412
413 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
413 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
414 pushing to http://localhost:$HGPORT2/
414 pushing to http://localhost:$HGPORT2/
415 searching for changes
415 searching for changes
416 abort: Abandon ship!
416 abort: Abandon ship!
417 (don't panic)
417 (don't panic)
418 [255]
418 [255]
419
419
420
420
421 Doing the actual push: unknown mandatory parts
421 Doing the actual push: unknown mandatory parts
422
422
423 $ cat << EOF >> $HGRCPATH
423 $ cat << EOF >> $HGRCPATH
424 > [failpush]
424 > [failpush]
425 > reason = unknown
425 > reason = unknown
426 > EOF
426 > EOF
427
427
428 $ hg -R main push other -r e7ec4e813ba6
428 $ hg -R main push other -r e7ec4e813ba6
429 pushing to other
429 pushing to other
430 searching for changes
430 searching for changes
431 abort: missing support for test:unknown
431 abort: missing support for test:unknown
432 [255]
432 [255]
433
433
434 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
434 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
435 pushing to ssh://user@dummy/other
435 pushing to ssh://user@dummy/other
436 searching for changes
436 searching for changes
437 abort: missing support for test:unknown
437 abort: missing support for test:unknown
438 [255]
438 [255]
439
439
440 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
440 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
441 pushing to http://localhost:$HGPORT2/
441 pushing to http://localhost:$HGPORT2/
442 searching for changes
442 searching for changes
443 abort: missing support for test:unknown
443 abort: missing support for test:unknown
444 [255]
444 [255]
445
445
446 Doing the actual push: race
446 Doing the actual push: race
447
447
448 $ cat << EOF >> $HGRCPATH
448 $ cat << EOF >> $HGRCPATH
449 > [failpush]
449 > [failpush]
450 > reason = race
450 > reason = race
451 > EOF
451 > EOF
452
452
453 $ hg -R main push other -r e7ec4e813ba6
453 $ hg -R main push other -r e7ec4e813ba6
454 pushing to other
454 pushing to other
455 searching for changes
455 searching for changes
456 abort: push failed:
456 abort: push failed:
457 'repository changed while pushing - please try again'
457 'repository changed while pushing - please try again'
458 [255]
458 [255]
459
459
460 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
460 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
461 pushing to ssh://user@dummy/other
461 pushing to ssh://user@dummy/other
462 searching for changes
462 searching for changes
463 abort: push failed:
463 abort: push failed:
464 'repository changed while pushing - please try again'
464 'repository changed while pushing - please try again'
465 [255]
465 [255]
466
466
467 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
467 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
468 pushing to http://localhost:$HGPORT2/
468 pushing to http://localhost:$HGPORT2/
469 searching for changes
469 searching for changes
470 abort: push failed:
470 abort: push failed:
471 'repository changed while pushing - please try again'
471 'repository changed while pushing - please try again'
472 [255]
472 [255]
473
473
474 Doing the actual push: hook abort
474 Doing the actual push: hook abort
475
475
476 $ cat << EOF >> $HGRCPATH
476 $ cat << EOF >> $HGRCPATH
477 > [failpush]
477 > [failpush]
478 > reason =
478 > reason =
479 > [hooks]
479 > [hooks]
480 > b2x-pretransactionclose.failpush = false
480 > b2x-pretransactionclose.failpush = false
481 > EOF
481 > EOF
482
482
483 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
483 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
484 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
484 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
485 $ cat other.pid >> $DAEMON_PIDS
485 $ cat other.pid >> $DAEMON_PIDS
486
486
487 $ hg -R main push other -r e7ec4e813ba6
487 $ hg -R main push other -r e7ec4e813ba6
488 pushing to other
488 pushing to other
489 searching for changes
489 searching for changes
490 pre-close-tip:e7ec4e813ba6 draft
490 pre-close-tip:e7ec4e813ba6 draft
491 transaction abort!
491 transaction abort!
492 rollback completed
492 rollback completed
493 abort: b2x-pretransactionclose.failpush hook exited with status 1
493 abort: b2x-pretransactionclose.failpush hook exited with status 1
494 [255]
494 [255]
495
495
496 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
496 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
497 pushing to ssh://user@dummy/other
497 pushing to ssh://user@dummy/other
498 searching for changes
498 searching for changes
499 abort: b2x-pretransactionclose.failpush hook exited with status 1
499 abort: b2x-pretransactionclose.failpush hook exited with status 1
500 remote: pre-close-tip:e7ec4e813ba6 draft
500 remote: pre-close-tip:e7ec4e813ba6 draft
501 remote: transaction abort!
501 remote: transaction abort!
502 remote: rollback completed
502 remote: rollback completed
503 [255]
503 [255]
504
504
505 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
505 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
506 pushing to http://localhost:$HGPORT2/
506 pushing to http://localhost:$HGPORT2/
507 searching for changes
507 searching for changes
508 abort: b2x-pretransactionclose.failpush hook exited with status 1
508 abort: b2x-pretransactionclose.failpush hook exited with status 1
509 [255]
509 [255]
510
510
511 (check that no 'pending' files remain)
511 (check that no 'pending' files remain)
512
512
513 $ ls -1 other/.hg/bookmarks*
513 $ ls -1 other/.hg/bookmarks*
514 other/.hg/bookmarks
514 other/.hg/bookmarks
515 $ ls -1 other/.hg/store/phaseroots*
515 $ ls -1 other/.hg/store/phaseroots*
516 other/.hg/store/phaseroots
516 other/.hg/store/phaseroots
517 $ ls -1 other/.hg/store/00changelog.i*
517 $ ls -1 other/.hg/store/00changelog.i*
518 other/.hg/store/00changelog.i
518 other/.hg/store/00changelog.i
519
519
General Comments 0
You need to be logged in to leave comments. Login now