##// END OF EJS Templates
repoview: invalidate 'visible' filtered revisions when bookmarks change...
Laurent Charignon -
r25569:2612e6da default
parent child Browse files
Show More
@@ -1,559 +1,560 b''
1 1 # Mercurial bookmark support code
2 2 #
3 3 # Copyright 2008 David Soria Parra <dsp@php.net>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 import os
9 9 from mercurial.i18n import _
10 10 from mercurial.node import hex, bin
11 11 from mercurial import encoding, util, obsolete, lock as lockmod
12 12 import errno
13 13
14 14 class bmstore(dict):
15 15 """Storage for bookmarks.
16 16
17 17 This object should do all bookmark reads and writes, so that it's
18 18 fairly simple to replace the storage underlying bookmarks without
19 19 having to clone the logic surrounding bookmarks.
20 20
21 21 This particular bmstore implementation stores bookmarks as
22 22 {hash}\s{name}\n (the same format as localtags) in
23 23 .hg/bookmarks. The mapping is stored as {name: nodeid}.
24 24
25 25 This class does NOT handle the "active" bookmark state at this
26 26 time.
27 27 """
28 28
29 29 def __init__(self, repo):
30 30 dict.__init__(self)
31 31 self._repo = repo
32 32 try:
33 33 bkfile = self.getbkfile(repo)
34 34 for line in bkfile:
35 35 line = line.strip()
36 36 if not line:
37 37 continue
38 38 if ' ' not in line:
39 39 repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
40 40 % line)
41 41 continue
42 42 sha, refspec = line.split(' ', 1)
43 43 refspec = encoding.tolocal(refspec)
44 44 try:
45 45 self[refspec] = repo.changelog.lookup(sha)
46 46 except LookupError:
47 47 pass
48 48 except IOError, inst:
49 49 if inst.errno != errno.ENOENT:
50 50 raise
51 51
52 52 def getbkfile(self, repo):
53 53 bkfile = None
54 54 if 'HG_PENDING' in os.environ:
55 55 try:
56 56 bkfile = repo.vfs('bookmarks.pending')
57 57 except IOError, inst:
58 58 if inst.errno != errno.ENOENT:
59 59 raise
60 60 if bkfile is None:
61 61 bkfile = repo.vfs('bookmarks')
62 62 return bkfile
63 63
64 64 def recordchange(self, tr):
65 65 """record that bookmarks have been changed in a transaction
66 66
67 67 The transaction is then responsible for updating the file content."""
68 68 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
69 69 location='plain')
70 70 tr.hookargs['bookmark_moved'] = '1'
71 71
72 72 def write(self):
73 73 '''Write bookmarks
74 74
75 75 Write the given bookmark => hash dictionary to the .hg/bookmarks file
76 76 in a format equal to those of localtags.
77 77
78 78 We also store a backup of the previous state in undo.bookmarks that
79 79 can be copied back on rollback.
80 80 '''
81 81 repo = self._repo
82 82 self._writerepo(repo)
83 repo.invalidatevolatilesets()
83 84
84 85 def _writerepo(self, repo):
85 86 """Factored out for extensibility"""
86 87 if repo._activebookmark not in self:
87 88 deactivate(repo)
88 89
89 90 wlock = repo.wlock()
90 91 try:
91 92
92 93 file = repo.vfs('bookmarks', 'w', atomictemp=True)
93 94 self._write(file)
94 95 file.close()
95 96
96 97 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed)
97 98 try:
98 99 repo.svfs.utime('00changelog.i', None)
99 100 except OSError:
100 101 pass
101 102
102 103 finally:
103 104 wlock.release()
104 105
105 106 def _write(self, fp):
106 107 for name, node in self.iteritems():
107 108 fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name)))
108 109
109 110 def readactive(repo):
110 111 """
111 112 Get the active bookmark. We can have an active bookmark that updates
112 113 itself as we commit. This function returns the name of that bookmark.
113 114 It is stored in .hg/bookmarks.current
114 115 """
115 116 mark = None
116 117 try:
117 118 file = repo.vfs('bookmarks.current')
118 119 except IOError, inst:
119 120 if inst.errno != errno.ENOENT:
120 121 raise
121 122 return None
122 123 try:
123 124 # No readline() in osutil.posixfile, reading everything is cheap
124 125 mark = encoding.tolocal((file.readlines() or [''])[0])
125 126 if mark == '' or mark not in repo._bookmarks:
126 127 mark = None
127 128 finally:
128 129 file.close()
129 130 return mark
130 131
131 132 def activate(repo, mark):
132 133 """
133 134 Set the given bookmark to be 'active', meaning that this bookmark will
134 135 follow new commits that are made.
135 136 The name is recorded in .hg/bookmarks.current
136 137 """
137 138 if mark not in repo._bookmarks:
138 139 raise AssertionError('bookmark %s does not exist!' % mark)
139 140
140 141 active = repo._activebookmark
141 142 if active == mark:
142 143 return
143 144
144 145 wlock = repo.wlock()
145 146 try:
146 147 file = repo.vfs('bookmarks.current', 'w', atomictemp=True)
147 148 file.write(encoding.fromlocal(mark))
148 149 file.close()
149 150 finally:
150 151 wlock.release()
151 152 repo._activebookmark = mark
152 153
153 154 def deactivate(repo):
154 155 """
155 156 Unset the active bookmark in this reposiotry.
156 157 """
157 158 wlock = repo.wlock()
158 159 try:
159 160 repo.vfs.unlink('bookmarks.current')
160 161 repo._activebookmark = None
161 162 except OSError, inst:
162 163 if inst.errno != errno.ENOENT:
163 164 raise
164 165 finally:
165 166 wlock.release()
166 167
167 168 def isactivewdirparent(repo):
168 169 """
169 170 Tell whether the 'active' bookmark (the one that follows new commits)
170 171 points to one of the parents of the current working directory (wdir).
171 172
172 173 While this is normally the case, it can on occasion be false; for example,
173 174 immediately after a pull, the active bookmark can be moved to point
174 175 to a place different than the wdir. This is solved by running `hg update`.
175 176 """
176 177 mark = repo._activebookmark
177 178 marks = repo._bookmarks
178 179 parents = [p.node() for p in repo[None].parents()]
179 180 return (mark in marks and marks[mark] in parents)
180 181
181 182 def deletedivergent(repo, deletefrom, bm):
182 183 '''Delete divergent versions of bm on nodes in deletefrom.
183 184
184 185 Return True if at least one bookmark was deleted, False otherwise.'''
185 186 deleted = False
186 187 marks = repo._bookmarks
187 188 divergent = [b for b in marks if b.split('@', 1)[0] == bm.split('@', 1)[0]]
188 189 for mark in divergent:
189 190 if mark == '@' or '@' not in mark:
190 191 # can't be divergent by definition
191 192 continue
192 193 if mark and marks[mark] in deletefrom:
193 194 if mark != bm:
194 195 del marks[mark]
195 196 deleted = True
196 197 return deleted
197 198
198 199 def calculateupdate(ui, repo, checkout):
199 200 '''Return a tuple (targetrev, movemarkfrom) indicating the rev to
200 201 check out and where to move the active bookmark from, if needed.'''
201 202 movemarkfrom = None
202 203 if checkout is None:
203 204 activemark = repo._activebookmark
204 205 if isactivewdirparent(repo):
205 206 movemarkfrom = repo['.'].node()
206 207 elif activemark:
207 208 ui.status(_("updating to active bookmark %s\n") % activemark)
208 209 checkout = activemark
209 210 return (checkout, movemarkfrom)
210 211
211 212 def update(repo, parents, node):
212 213 deletefrom = parents
213 214 marks = repo._bookmarks
214 215 update = False
215 216 active = repo._activebookmark
216 217 if not active:
217 218 return False
218 219
219 220 if marks[active] in parents:
220 221 new = repo[node]
221 222 divs = [repo[b] for b in marks
222 223 if b.split('@', 1)[0] == active.split('@', 1)[0]]
223 224 anc = repo.changelog.ancestors([new.rev()])
224 225 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
225 226 if validdest(repo, repo[marks[active]], new):
226 227 marks[active] = new.node()
227 228 update = True
228 229
229 230 if deletedivergent(repo, deletefrom, active):
230 231 update = True
231 232
232 233 if update:
233 234 marks.write()
234 235 return update
235 236
236 237 def listbookmarks(repo):
237 238 # We may try to list bookmarks on a repo type that does not
238 239 # support it (e.g., statichttprepository).
239 240 marks = getattr(repo, '_bookmarks', {})
240 241
241 242 d = {}
242 243 hasnode = repo.changelog.hasnode
243 244 for k, v in marks.iteritems():
244 245 # don't expose local divergent bookmarks
245 246 if hasnode(v) and ('@' not in k or k.endswith('@')):
246 247 d[k] = hex(v)
247 248 return d
248 249
249 250 def pushbookmark(repo, key, old, new):
250 251 w = l = tr = None
251 252 try:
252 253 w = repo.wlock()
253 254 l = repo.lock()
254 255 tr = repo.transaction('bookmarks')
255 256 marks = repo._bookmarks
256 257 existing = hex(marks.get(key, ''))
257 258 if existing != old and existing != new:
258 259 return False
259 260 if new == '':
260 261 del marks[key]
261 262 else:
262 263 if new not in repo:
263 264 return False
264 265 marks[key] = repo[new].node()
265 266 marks.recordchange(tr)
266 267 tr.close()
267 268 return True
268 269 finally:
269 270 lockmod.release(tr, l, w)
270 271
271 272 def compare(repo, srcmarks, dstmarks,
272 273 srchex=None, dsthex=None, targets=None):
273 274 '''Compare bookmarks between srcmarks and dstmarks
274 275
275 276 This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
276 277 differ, invalid)", each are list of bookmarks below:
277 278
278 279 :addsrc: added on src side (removed on dst side, perhaps)
279 280 :adddst: added on dst side (removed on src side, perhaps)
280 281 :advsrc: advanced on src side
281 282 :advdst: advanced on dst side
282 283 :diverge: diverge
283 284 :differ: changed, but changeset referred on src is unknown on dst
284 285 :invalid: unknown on both side
285 286 :same: same on both side
286 287
287 288 Each elements of lists in result tuple is tuple "(bookmark name,
288 289 changeset ID on source side, changeset ID on destination
289 290 side)". Each changeset IDs are 40 hexadecimal digit string or
290 291 None.
291 292
292 293 Changeset IDs of tuples in "addsrc", "adddst", "differ" or
293 294 "invalid" list may be unknown for repo.
294 295
295 296 This function expects that "srcmarks" and "dstmarks" return
296 297 changeset ID in 40 hexadecimal digit string for specified
297 298 bookmark. If not so (e.g. bmstore "repo._bookmarks" returning
298 299 binary value), "srchex" or "dsthex" should be specified to convert
299 300 into such form.
300 301
301 302 If "targets" is specified, only bookmarks listed in it are
302 303 examined.
303 304 '''
304 305 if not srchex:
305 306 srchex = lambda x: x
306 307 if not dsthex:
307 308 dsthex = lambda x: x
308 309
309 310 if targets:
310 311 bset = set(targets)
311 312 else:
312 313 srcmarkset = set(srcmarks)
313 314 dstmarkset = set(dstmarks)
314 315 bset = srcmarkset | dstmarkset
315 316
316 317 results = ([], [], [], [], [], [], [], [])
317 318 addsrc = results[0].append
318 319 adddst = results[1].append
319 320 advsrc = results[2].append
320 321 advdst = results[3].append
321 322 diverge = results[4].append
322 323 differ = results[5].append
323 324 invalid = results[6].append
324 325 same = results[7].append
325 326
326 327 for b in sorted(bset):
327 328 if b not in srcmarks:
328 329 if b in dstmarks:
329 330 adddst((b, None, dsthex(dstmarks[b])))
330 331 else:
331 332 invalid((b, None, None))
332 333 elif b not in dstmarks:
333 334 addsrc((b, srchex(srcmarks[b]), None))
334 335 else:
335 336 scid = srchex(srcmarks[b])
336 337 dcid = dsthex(dstmarks[b])
337 338 if scid == dcid:
338 339 same((b, scid, dcid))
339 340 elif scid in repo and dcid in repo:
340 341 sctx = repo[scid]
341 342 dctx = repo[dcid]
342 343 if sctx.rev() < dctx.rev():
343 344 if validdest(repo, sctx, dctx):
344 345 advdst((b, scid, dcid))
345 346 else:
346 347 diverge((b, scid, dcid))
347 348 else:
348 349 if validdest(repo, dctx, sctx):
349 350 advsrc((b, scid, dcid))
350 351 else:
351 352 diverge((b, scid, dcid))
352 353 else:
353 354 # it is too expensive to examine in detail, in this case
354 355 differ((b, scid, dcid))
355 356
356 357 return results
357 358
358 359 def _diverge(ui, b, path, localmarks, remotenode):
359 360 '''Return appropriate diverged bookmark for specified ``path``
360 361
361 362 This returns None, if it is failed to assign any divergent
362 363 bookmark name.
363 364
364 365 This reuses already existing one with "@number" suffix, if it
365 366 refers ``remotenode``.
366 367 '''
367 368 if b == '@':
368 369 b = ''
369 370 # try to use an @pathalias suffix
370 371 # if an @pathalias already exists, we overwrite (update) it
371 372 if path.startswith("file:"):
372 373 path = util.url(path).path
373 374 for p, u in ui.configitems("paths"):
374 375 if u.startswith("file:"):
375 376 u = util.url(u).path
376 377 if path == u:
377 378 return '%s@%s' % (b, p)
378 379
379 380 # assign a unique "@number" suffix newly
380 381 for x in range(1, 100):
381 382 n = '%s@%d' % (b, x)
382 383 if n not in localmarks or localmarks[n] == remotenode:
383 384 return n
384 385
385 386 return None
386 387
387 388 def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()):
388 389 ui.debug("checking for updated bookmarks\n")
389 390 localmarks = repo._bookmarks
390 391 (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
391 392 ) = compare(repo, remotemarks, localmarks, dsthex=hex)
392 393
393 394 status = ui.status
394 395 warn = ui.warn
395 396 if ui.configbool('ui', 'quietbookmarkmove', False):
396 397 status = warn = ui.debug
397 398
398 399 explicit = set(explicit)
399 400 changed = []
400 401 for b, scid, dcid in addsrc:
401 402 if scid in repo: # add remote bookmarks for changes we already have
402 403 changed.append((b, bin(scid), status,
403 404 _("adding remote bookmark %s\n") % (b)))
404 405 elif b in explicit:
405 406 explicit.remove(b)
406 407 ui.warn(_("remote bookmark %s points to locally missing %s\n")
407 408 % (b, scid[:12]))
408 409
409 410 for b, scid, dcid in advsrc:
410 411 changed.append((b, bin(scid), status,
411 412 _("updating bookmark %s\n") % (b)))
412 413 # remove normal movement from explicit set
413 414 explicit.difference_update(d[0] for d in changed)
414 415
415 416 for b, scid, dcid in diverge:
416 417 if b in explicit:
417 418 explicit.discard(b)
418 419 changed.append((b, bin(scid), status,
419 420 _("importing bookmark %s\n") % (b)))
420 421 else:
421 422 snode = bin(scid)
422 423 db = _diverge(ui, b, path, localmarks, snode)
423 424 if db:
424 425 changed.append((db, snode, warn,
425 426 _("divergent bookmark %s stored as %s\n") %
426 427 (b, db)))
427 428 else:
428 429 warn(_("warning: failed to assign numbered name "
429 430 "to divergent bookmark %s\n") % (b))
430 431 for b, scid, dcid in adddst + advdst:
431 432 if b in explicit:
432 433 explicit.discard(b)
433 434 changed.append((b, bin(scid), status,
434 435 _("importing bookmark %s\n") % (b)))
435 436 for b, scid, dcid in differ:
436 437 if b in explicit:
437 438 explicit.remove(b)
438 439 ui.warn(_("remote bookmark %s points to locally missing %s\n")
439 440 % (b, scid[:12]))
440 441
441 442 if changed:
442 443 tr = trfunc()
443 444 for b, node, writer, msg in sorted(changed):
444 445 localmarks[b] = node
445 446 writer(msg)
446 447 localmarks.recordchange(tr)
447 448
448 449 def incoming(ui, repo, other):
449 450 '''Show bookmarks incoming from other to repo
450 451 '''
451 452 ui.status(_("searching for changed bookmarks\n"))
452 453
453 454 r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
454 455 dsthex=hex)
455 456 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
456 457
457 458 incomings = []
458 459 if ui.debugflag:
459 460 getid = lambda id: id
460 461 else:
461 462 getid = lambda id: id[:12]
462 463 if ui.verbose:
463 464 def add(b, id, st):
464 465 incomings.append(" %-25s %s %s\n" % (b, getid(id), st))
465 466 else:
466 467 def add(b, id, st):
467 468 incomings.append(" %-25s %s\n" % (b, getid(id)))
468 469 for b, scid, dcid in addsrc:
469 470 # i18n: "added" refers to a bookmark
470 471 add(b, scid, _('added'))
471 472 for b, scid, dcid in advsrc:
472 473 # i18n: "advanced" refers to a bookmark
473 474 add(b, scid, _('advanced'))
474 475 for b, scid, dcid in diverge:
475 476 # i18n: "diverged" refers to a bookmark
476 477 add(b, scid, _('diverged'))
477 478 for b, scid, dcid in differ:
478 479 # i18n: "changed" refers to a bookmark
479 480 add(b, scid, _('changed'))
480 481
481 482 if not incomings:
482 483 ui.status(_("no changed bookmarks found\n"))
483 484 return 1
484 485
485 486 for s in sorted(incomings):
486 487 ui.write(s)
487 488
488 489 return 0
489 490
490 491 def outgoing(ui, repo, other):
491 492 '''Show bookmarks outgoing from repo to other
492 493 '''
493 494 ui.status(_("searching for changed bookmarks\n"))
494 495
495 496 r = compare(repo, repo._bookmarks, other.listkeys('bookmarks'),
496 497 srchex=hex)
497 498 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
498 499
499 500 outgoings = []
500 501 if ui.debugflag:
501 502 getid = lambda id: id
502 503 else:
503 504 getid = lambda id: id[:12]
504 505 if ui.verbose:
505 506 def add(b, id, st):
506 507 outgoings.append(" %-25s %s %s\n" % (b, getid(id), st))
507 508 else:
508 509 def add(b, id, st):
509 510 outgoings.append(" %-25s %s\n" % (b, getid(id)))
510 511 for b, scid, dcid in addsrc:
511 512 # i18n: "added refers to a bookmark
512 513 add(b, scid, _('added'))
513 514 for b, scid, dcid in adddst:
514 515 # i18n: "deleted" refers to a bookmark
515 516 add(b, ' ' * 40, _('deleted'))
516 517 for b, scid, dcid in advsrc:
517 518 # i18n: "advanced" refers to a bookmark
518 519 add(b, scid, _('advanced'))
519 520 for b, scid, dcid in diverge:
520 521 # i18n: "diverged" refers to a bookmark
521 522 add(b, scid, _('diverged'))
522 523 for b, scid, dcid in differ:
523 524 # i18n: "changed" refers to a bookmark
524 525 add(b, scid, _('changed'))
525 526
526 527 if not outgoings:
527 528 ui.status(_("no changed bookmarks found\n"))
528 529 return 1
529 530
530 531 for s in sorted(outgoings):
531 532 ui.write(s)
532 533
533 534 return 0
534 535
535 536 def summary(repo, other):
536 537 '''Compare bookmarks between repo and other for "hg summary" output
537 538
538 539 This returns "(# of incoming, # of outgoing)" tuple.
539 540 '''
540 541 r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
541 542 dsthex=hex)
542 543 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
543 544 return (len(addsrc), len(adddst))
544 545
545 546 def validdest(repo, old, new):
546 547 """Is the new bookmark destination a valid update from the old one"""
547 548 repo = repo.unfiltered()
548 549 if old == new:
549 550 # Old == new -> nothing to update.
550 551 return False
551 552 elif not old:
552 553 # old is nullrev, anything is valid.
553 554 # (new != nullrev has been excluded by the previous check)
554 555 return True
555 556 elif repo.obsstore:
556 557 return new.node() in obsolete.foreground(repo, [old.node()])
557 558 else:
558 559 # still an independent clause as it is lazier (and therefore faster)
559 560 return old.descendant(new)
@@ -1,929 +1,968 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [phases]
3 3 > # public changeset are not obsolete
4 4 > publish=false
5 5 > [ui]
6 6 > logtemplate="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n"
7 7 > [experimental]
8 8 > # drop me once bundle2 is the default,
9 9 > # added to get test change early.
10 10 > bundle2-exp = True
11 11 > EOF
12 12 $ mkcommit() {
13 13 > echo "$1" > "$1"
14 14 > hg add "$1"
15 15 > hg ci -m "add $1"
16 16 > }
17 17 $ getid() {
18 18 > hg log -T "{node}\n" --hidden -r "desc('$1')"
19 19 > }
20 20
21 21 $ cat > debugkeys.py <<EOF
22 22 > def reposetup(ui, repo):
23 23 > class debugkeysrepo(repo.__class__):
24 24 > def listkeys(self, namespace):
25 25 > ui.write('listkeys %s\n' % (namespace,))
26 26 > return super(debugkeysrepo, self).listkeys(namespace)
27 27 >
28 28 > if repo.local():
29 29 > repo.__class__ = debugkeysrepo
30 30 > EOF
31 31
32 32 $ hg init tmpa
33 33 $ cd tmpa
34 34 $ mkcommit kill_me
35 35
36 36 Checking that the feature is properly disabled
37 37
38 38 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
39 39 abort: creating obsolete markers is not enabled on this repo
40 40 [255]
41 41
42 42 Enabling it
43 43
44 44 $ cat >> $HGRCPATH << EOF
45 45 > [experimental]
46 46 > evolution=createmarkers,exchange
47 47 > EOF
48 48
49 49 Killing a single changeset without replacement
50 50
51 51 $ hg debugobsolete 0
52 52 abort: changeset references must be full hexadecimal node identifiers
53 53 [255]
54 54 $ hg debugobsolete '00'
55 55 abort: changeset references must be full hexadecimal node identifiers
56 56 [255]
57 57 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
58 58 $ hg debugobsolete
59 59 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'}
60 60
61 61 (test that mercurial is not confused)
62 62
63 63 $ hg up null --quiet # having 0 as parent prevents it to be hidden
64 64 $ hg tip
65 65 -1:000000000000 (public) [tip ]
66 66 $ hg up --hidden tip --quiet
67 67
68 68 Killing a single changeset with itself should fail
69 69 (simple local safeguard)
70 70
71 71 $ hg debugobsolete `getid kill_me` `getid kill_me`
72 72 abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0
73 73 [255]
74 74
75 75 $ cd ..
76 76
77 77 Killing a single changeset with replacement
78 78 (and testing the format option)
79 79
80 80 $ hg init tmpb
81 81 $ cd tmpb
82 82 $ mkcommit a
83 83 $ mkcommit b
84 84 $ mkcommit original_c
85 85 $ hg up "desc('b')"
86 86 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 87 $ mkcommit new_c
88 88 created new head
89 89 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
90 90 $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '121 120'
91 91 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
92 92 2:245bde4270cd add original_c
93 93 $ hg debugrevlog -cd
94 94 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
95 95 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0
96 96 1 0 -1 59 118 59 59 0 0 58 116 0 1 0
97 97 2 1 -1 118 193 118 118 59 0 76 192 0 1 0
98 98 3 1 -1 193 260 193 193 59 0 66 258 0 2 0
99 99 $ hg debugobsolete
100 100 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
101 101
102 102 (check for version number of the obsstore)
103 103
104 104 $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null
105 105 \x00 (no-eol) (esc)
106 106
107 107 do it again (it read the obsstore before adding new changeset)
108 108
109 109 $ hg up '.^'
110 110 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
111 111 $ mkcommit new_2_c
112 112 created new head
113 113 $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
114 114 $ hg debugobsolete
115 115 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
116 116 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
117 117
118 118 Register two markers with a missing node
119 119
120 120 $ hg up '.^'
121 121 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
122 122 $ mkcommit new_3_c
123 123 created new head
124 124 $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
125 125 $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
126 126 $ hg debugobsolete
127 127 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
128 128 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
129 129 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
130 130 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
131 131
132 132 Refuse pathological nullid successors
133 133 $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
134 134 transaction abort!
135 135 rollback completed
136 136 abort: bad obsolescence marker detected: invalid successors nullid
137 137 [255]
138 138
139 139 Check that graphlog detect that a changeset is obsolete:
140 140
141 141 $ hg log -G
142 142 @ 5:5601fb93a350 (draft) [tip ] add new_3_c
143 143 |
144 144 o 1:7c3bad9141dc (draft) [ ] add b
145 145 |
146 146 o 0:1f0dee641bb7 (draft) [ ] add a
147 147
148 148
149 149 check that heads does not report them
150 150
151 151 $ hg heads
152 152 5:5601fb93a350 (draft) [tip ] add new_3_c
153 153 $ hg heads --hidden
154 154 5:5601fb93a350 (draft) [tip ] add new_3_c
155 155 4:ca819180edb9 (draft) [ ] add new_2_c
156 156 3:cdbce2fbb163 (draft) [ ] add new_c
157 157 2:245bde4270cd (draft) [ ] add original_c
158 158
159 159
160 160 check that summary does not report them
161 161
162 162 $ hg init ../sink
163 163 $ echo '[paths]' >> .hg/hgrc
164 164 $ echo 'default=../sink' >> .hg/hgrc
165 165 $ hg summary --remote
166 166 parent: 5:5601fb93a350 tip
167 167 add new_3_c
168 168 branch: default
169 169 commit: (clean)
170 170 update: (current)
171 171 phases: 3 draft
172 172 remote: 3 outgoing
173 173
174 174 $ hg summary --remote --hidden
175 175 parent: 5:5601fb93a350 tip
176 176 add new_3_c
177 177 branch: default
178 178 commit: (clean)
179 179 update: 3 new changesets, 4 branch heads (merge)
180 180 phases: 6 draft
181 181 remote: 3 outgoing
182 182
183 183 check that various commands work well with filtering
184 184
185 185 $ hg tip
186 186 5:5601fb93a350 (draft) [tip ] add new_3_c
187 187 $ hg log -r 6
188 188 abort: unknown revision '6'!
189 189 [255]
190 190 $ hg log -r 4
191 191 abort: hidden revision '4'!
192 192 (use --hidden to access hidden revisions)
193 193 [255]
194 194 $ hg debugrevspec 'rev(6)'
195 195 $ hg debugrevspec 'rev(4)'
196 196 $ hg debugrevspec 'null'
197 197 -1
198 198
199 199 Check that public changeset are not accounted as obsolete:
200 200
201 201 $ hg --hidden phase --public 2
202 202 $ hg log -G
203 203 @ 5:5601fb93a350 (draft) [tip ] add new_3_c
204 204 |
205 205 | o 2:245bde4270cd (public) [ ] add original_c
206 206 |/
207 207 o 1:7c3bad9141dc (public) [ ] add b
208 208 |
209 209 o 0:1f0dee641bb7 (public) [ ] add a
210 210
211 211
212 212 And that bumped changeset are detected
213 213 --------------------------------------
214 214
215 215 If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also
216 216 note that the bumped changeset (5:5601fb93a350) is not a direct successor of
217 217 the public changeset
218 218
219 219 $ hg log --hidden -r 'bumped()'
220 220 5:5601fb93a350 (draft) [tip ] add new_3_c
221 221
222 222 And that we can't push bumped changeset
223 223
224 224 $ hg push ../tmpa -r 0 --force #(make repo related)
225 225 pushing to ../tmpa
226 226 searching for changes
227 227 warning: repository is unrelated
228 228 adding changesets
229 229 adding manifests
230 230 adding file changes
231 231 added 1 changesets with 1 changes to 1 files (+1 heads)
232 232 $ hg push ../tmpa
233 233 pushing to ../tmpa
234 234 searching for changes
235 235 abort: push includes bumped changeset: 5601fb93a350!
236 236 [255]
237 237
238 238 Fixing "bumped" situation
239 239 We need to create a clone of 5 and add a special marker with a flag
240 240
241 241 $ hg up '5^'
242 242 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
243 243 $ hg revert -ar 5
244 244 adding new_3_c
245 245 $ hg ci -m 'add n3w_3_c'
246 246 created new head
247 247 $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c`
248 248 $ hg log -r 'bumped()'
249 249 $ hg log -G
250 250 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
251 251 |
252 252 | o 2:245bde4270cd (public) [ ] add original_c
253 253 |/
254 254 o 1:7c3bad9141dc (public) [ ] add b
255 255 |
256 256 o 0:1f0dee641bb7 (public) [ ] add a
257 257
258 258
259 259 $ cd ..
260 260
261 261 Revision 0 is hidden
262 262 --------------------
263 263
264 264 $ hg init rev0hidden
265 265 $ cd rev0hidden
266 266
267 267 $ mkcommit kill0
268 268 $ hg up -q null
269 269 $ hg debugobsolete `getid kill0`
270 270 $ mkcommit a
271 271 $ mkcommit b
272 272
273 273 Should pick the first visible revision as "repo" node
274 274
275 275 $ hg archive ../archive-null
276 276 $ cat ../archive-null/.hg_archival.txt
277 277 repo: 1f0dee641bb7258c56bd60e93edfa2405381c41e
278 278 node: 7c3bad9141dcb46ff89abf5f61856facd56e476c
279 279 branch: default
280 280 latesttag: null
281 281 latesttagdistance: 2
282 282 changessincelatesttag: 2
283 283
284 284
285 285 $ cd ..
286 286
287 287 Exchange Test
288 288 ============================
289 289
290 290 Destination repo does not have any data
291 291 ---------------------------------------
292 292
293 293 Simple incoming test
294 294
295 295 $ hg init tmpc
296 296 $ cd tmpc
297 297 $ hg incoming ../tmpb
298 298 comparing with ../tmpb
299 299 0:1f0dee641bb7 (public) [ ] add a
300 300 1:7c3bad9141dc (public) [ ] add b
301 301 2:245bde4270cd (public) [ ] add original_c
302 302 6:6f9641995072 (draft) [tip ] add n3w_3_c
303 303
304 304 Try to pull markers
305 305 (extinct changeset are excluded but marker are pushed)
306 306
307 307 $ hg pull ../tmpb
308 308 pulling from ../tmpb
309 309 requesting all changes
310 310 adding changesets
311 311 adding manifests
312 312 adding file changes
313 313 added 4 changesets with 4 changes to 4 files (+1 heads)
314 314 5 new obsolescence markers
315 315 (run 'hg heads' to see heads, 'hg merge' to merge)
316 316 $ hg debugobsolete
317 317 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
318 318 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
319 319 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
320 320 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
321 321 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
322 322
323 323 Rollback//Transaction support
324 324
325 325 $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
326 326 $ hg debugobsolete
327 327 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
328 328 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
329 329 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
330 330 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
331 331 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
332 332 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'}
333 333 $ hg rollback -n
334 334 repository tip rolled back to revision 3 (undo debugobsolete)
335 335 $ hg rollback
336 336 repository tip rolled back to revision 3 (undo debugobsolete)
337 337 $ hg debugobsolete
338 338 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
339 339 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
340 340 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
341 341 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
342 342 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
343 343
344 344 $ cd ..
345 345
346 346 Try to push markers
347 347
348 348 $ hg init tmpd
349 349 $ hg -R tmpb push tmpd
350 350 pushing to tmpd
351 351 searching for changes
352 352 adding changesets
353 353 adding manifests
354 354 adding file changes
355 355 added 4 changesets with 4 changes to 4 files (+1 heads)
356 356 5 new obsolescence markers
357 357 $ hg -R tmpd debugobsolete | sort
358 358 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
359 359 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
360 360 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
361 361 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
362 362 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
363 363
364 364 Check obsolete keys are exchanged only if source has an obsolete store
365 365
366 366 $ hg init empty
367 367 $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
368 368 pushing to tmpd
369 369 listkeys phases
370 370 listkeys bookmarks
371 371 no changes found
372 372 listkeys phases
373 373 [1]
374 374
375 375 clone support
376 376 (markers are copied and extinct changesets are included to allow hardlinks)
377 377
378 378 $ hg clone tmpb clone-dest
379 379 updating to branch default
380 380 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
381 381 $ hg -R clone-dest log -G --hidden
382 382 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
383 383 |
384 384 | x 5:5601fb93a350 (draft) [ ] add new_3_c
385 385 |/
386 386 | x 4:ca819180edb9 (draft) [ ] add new_2_c
387 387 |/
388 388 | x 3:cdbce2fbb163 (draft) [ ] add new_c
389 389 |/
390 390 | o 2:245bde4270cd (public) [ ] add original_c
391 391 |/
392 392 o 1:7c3bad9141dc (public) [ ] add b
393 393 |
394 394 o 0:1f0dee641bb7 (public) [ ] add a
395 395
396 396 $ hg -R clone-dest debugobsolete
397 397 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
398 398 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
399 399 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
400 400 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
401 401 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
402 402
403 403
404 404 Destination repo have existing data
405 405 ---------------------------------------
406 406
407 407 On pull
408 408
409 409 $ hg init tmpe
410 410 $ cd tmpe
411 411 $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00
412 412 $ hg pull ../tmpb
413 413 pulling from ../tmpb
414 414 requesting all changes
415 415 adding changesets
416 416 adding manifests
417 417 adding file changes
418 418 added 4 changesets with 4 changes to 4 files (+1 heads)
419 419 5 new obsolescence markers
420 420 (run 'hg heads' to see heads, 'hg merge' to merge)
421 421 $ hg debugobsolete
422 422 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
423 423 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
424 424 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
425 425 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
426 426 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
427 427 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
428 428
429 429
430 430 On push
431 431
432 432 $ hg push ../tmpc
433 433 pushing to ../tmpc
434 434 searching for changes
435 435 no changes found
436 436 1 new obsolescence markers
437 437 [1]
438 438 $ hg -R ../tmpc debugobsolete
439 439 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
440 440 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
441 441 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
442 442 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
443 443 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
444 444 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
445 445
446 446 detect outgoing obsolete and unstable
447 447 ---------------------------------------
448 448
449 449
450 450 $ hg log -G
451 451 o 3:6f9641995072 (draft) [tip ] add n3w_3_c
452 452 |
453 453 | o 2:245bde4270cd (public) [ ] add original_c
454 454 |/
455 455 o 1:7c3bad9141dc (public) [ ] add b
456 456 |
457 457 o 0:1f0dee641bb7 (public) [ ] add a
458 458
459 459 $ hg up 'desc("n3w_3_c")'
460 460 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
461 461 $ mkcommit original_d
462 462 $ mkcommit original_e
463 463 $ hg debugobsolete --record-parents `getid original_d` -d '0 0'
464 464 $ hg debugobsolete | grep `getid original_d`
465 465 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
466 466 $ hg log -r 'obsolete()'
467 467 4:94b33453f93b (draft) [ ] add original_d
468 468 $ hg log -G -r '::unstable()'
469 469 @ 5:cda648ca50f5 (draft) [tip ] add original_e
470 470 |
471 471 x 4:94b33453f93b (draft) [ ] add original_d
472 472 |
473 473 o 3:6f9641995072 (draft) [ ] add n3w_3_c
474 474 |
475 475 o 1:7c3bad9141dc (public) [ ] add b
476 476 |
477 477 o 0:1f0dee641bb7 (public) [ ] add a
478 478
479 479
480 480 refuse to push obsolete changeset
481 481
482 482 $ hg push ../tmpc/ -r 'desc("original_d")'
483 483 pushing to ../tmpc/
484 484 searching for changes
485 485 abort: push includes obsolete changeset: 94b33453f93b!
486 486 [255]
487 487
488 488 refuse to push unstable changeset
489 489
490 490 $ hg push ../tmpc/
491 491 pushing to ../tmpc/
492 492 searching for changes
493 493 abort: push includes unstable changeset: cda648ca50f5!
494 494 [255]
495 495
496 496 Test that extinct changeset are properly detected
497 497
498 498 $ hg log -r 'extinct()'
499 499
500 500 Don't try to push extinct changeset
501 501
502 502 $ hg init ../tmpf
503 503 $ hg out ../tmpf
504 504 comparing with ../tmpf
505 505 searching for changes
506 506 0:1f0dee641bb7 (public) [ ] add a
507 507 1:7c3bad9141dc (public) [ ] add b
508 508 2:245bde4270cd (public) [ ] add original_c
509 509 3:6f9641995072 (draft) [ ] add n3w_3_c
510 510 4:94b33453f93b (draft) [ ] add original_d
511 511 5:cda648ca50f5 (draft) [tip ] add original_e
512 512 $ hg push ../tmpf -f # -f because be push unstable too
513 513 pushing to ../tmpf
514 514 searching for changes
515 515 adding changesets
516 516 adding manifests
517 517 adding file changes
518 518 added 6 changesets with 6 changes to 6 files (+1 heads)
519 519 7 new obsolescence markers
520 520
521 521 no warning displayed
522 522
523 523 $ hg push ../tmpf
524 524 pushing to ../tmpf
525 525 searching for changes
526 526 no changes found
527 527 [1]
528 528
529 529 Do not warn about new head when the new head is a successors of a remote one
530 530
531 531 $ hg log -G
532 532 @ 5:cda648ca50f5 (draft) [tip ] add original_e
533 533 |
534 534 x 4:94b33453f93b (draft) [ ] add original_d
535 535 |
536 536 o 3:6f9641995072 (draft) [ ] add n3w_3_c
537 537 |
538 538 | o 2:245bde4270cd (public) [ ] add original_c
539 539 |/
540 540 o 1:7c3bad9141dc (public) [ ] add b
541 541 |
542 542 o 0:1f0dee641bb7 (public) [ ] add a
543 543
544 544 $ hg up -q 'desc(n3w_3_c)'
545 545 $ mkcommit obsolete_e
546 546 created new head
547 547 $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'`
548 548 $ hg outgoing ../tmpf # parasite hg outgoing testin
549 549 comparing with ../tmpf
550 550 searching for changes
551 551 6:3de5eca88c00 (draft) [tip ] add obsolete_e
552 552 $ hg push ../tmpf
553 553 pushing to ../tmpf
554 554 searching for changes
555 555 adding changesets
556 556 adding manifests
557 557 adding file changes
558 558 added 1 changesets with 1 changes to 1 files (+1 heads)
559 559 1 new obsolescence markers
560 560
561 561 test relevance computation
562 562 ---------------------------------------
563 563
564 564 Checking simple case of "marker relevance".
565 565
566 566
567 567 Reminder of the repo situation
568 568
569 569 $ hg log --hidden --graph
570 570 @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e
571 571 |
572 572 | x 5:cda648ca50f5 (draft) [ ] add original_e
573 573 | |
574 574 | x 4:94b33453f93b (draft) [ ] add original_d
575 575 |/
576 576 o 3:6f9641995072 (draft) [ ] add n3w_3_c
577 577 |
578 578 | o 2:245bde4270cd (public) [ ] add original_c
579 579 |/
580 580 o 1:7c3bad9141dc (public) [ ] add b
581 581 |
582 582 o 0:1f0dee641bb7 (public) [ ] add a
583 583
584 584
585 585 List of all markers
586 586
587 587 $ hg debugobsolete
588 588 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
589 589 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
590 590 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
591 591 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
592 592 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
593 593 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
594 594 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
595 595 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob)
596 596
597 597 List of changesets with no chain
598 598
599 599 $ hg debugobsolete --hidden --rev ::2
600 600
601 601 List of changesets that are included on marker chain
602 602
603 603 $ hg debugobsolete --hidden --rev 6
604 604 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob)
605 605
606 606 List of changesets with a longer chain, (including a pruned children)
607 607
608 608 $ hg debugobsolete --hidden --rev 3
609 609 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
610 610 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
611 611 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
612 612 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
613 613 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
614 614 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
615 615 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
616 616
617 617 List of both
618 618
619 619 $ hg debugobsolete --hidden --rev 3::6
620 620 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
621 621 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
622 622 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
623 623 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
624 624 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
625 625 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
626 626 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob)
627 627 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
628 628
629 629 #if serve
630 630
631 631 Test the debug output for exchange
632 632 ----------------------------------
633 633
634 634 $ hg pull ../tmpb --config 'experimental.obsmarkers-exchange-debug=True' --config 'experimental.bundle2-exp=True'
635 635 pulling from ../tmpb
636 636 searching for changes
637 637 no changes found
638 638 obsmarker-exchange: 346 bytes received
639 639
640 640 check hgweb does not explode
641 641 ====================================
642 642
643 643 $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg
644 644 adding changesets
645 645 adding manifests
646 646 adding file changes
647 647 added 62 changesets with 63 changes to 9 files (+60 heads)
648 648 (run 'hg heads .' to see heads, 'hg merge' to merge)
649 649 $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`;
650 650 > do
651 651 > hg debugobsolete $node
652 652 > done
653 653 $ hg up tip
654 654 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
655 655
656 656 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
657 657 $ cat hg.pid >> $DAEMON_PIDS
658 658
659 659 check changelog view
660 660
661 661 $ get-with-headers.py --headeronly localhost:$HGPORT 'shortlog/'
662 662 200 Script output follows
663 663
664 664 check graph view
665 665
666 666 $ get-with-headers.py --headeronly localhost:$HGPORT 'graph'
667 667 200 Script output follows
668 668
669 669 check filelog view
670 670
671 671 $ get-with-headers.py --headeronly localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar'
672 672 200 Script output follows
673 673
674 674 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68'
675 675 200 Script output follows
676 676 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
677 677 404 Not Found
678 678 [1]
679 679
680 680 check that web.view config option:
681 681
682 682 $ killdaemons.py hg.pid
683 683 $ cat >> .hg/hgrc << EOF
684 684 > [web]
685 685 > view=all
686 686 > EOF
687 687 $ wait
688 688 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
689 689 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
690 690 200 Script output follows
691 691 $ killdaemons.py hg.pid
692 692
693 693 Checking _enable=False warning if obsolete marker exists
694 694
695 695 $ echo '[experimental]' >> $HGRCPATH
696 696 $ echo "evolution=" >> $HGRCPATH
697 697 $ hg log -r tip
698 698 obsolete feature not enabled but 68 markers found!
699 699 68:c15e9edfca13 (draft) [tip ] add celestine
700 700
701 701 reenable for later test
702 702
703 703 $ echo '[experimental]' >> $HGRCPATH
704 704 $ echo "evolution=createmarkers,exchange" >> $HGRCPATH
705 705
706 706 #endif
707 707
708 708 Test incoming/outcoming with changesets obsoleted remotely, known locally
709 709 ===============================================================================
710 710
711 711 This test issue 3805
712 712
713 713 $ hg init repo-issue3805
714 714 $ cd repo-issue3805
715 715 $ echo "foo" > foo
716 716 $ hg ci -Am "A"
717 717 adding foo
718 718 $ hg clone . ../other-issue3805
719 719 updating to branch default
720 720 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
721 721 $ echo "bar" >> foo
722 722 $ hg ci --amend
723 723 $ cd ../other-issue3805
724 724 $ hg log -G
725 725 @ 0:193e9254ce7e (draft) [tip ] A
726 726
727 727 $ hg log -G -R ../repo-issue3805
728 728 @ 2:3816541e5485 (draft) [tip ] A
729 729
730 730 $ hg incoming
731 731 comparing with $TESTTMP/tmpe/repo-issue3805 (glob)
732 732 searching for changes
733 733 2:3816541e5485 (draft) [tip ] A
734 734 $ hg incoming --bundle ../issue3805.hg
735 735 comparing with $TESTTMP/tmpe/repo-issue3805 (glob)
736 736 searching for changes
737 737 2:3816541e5485 (draft) [tip ] A
738 738 $ hg outgoing
739 739 comparing with $TESTTMP/tmpe/repo-issue3805 (glob)
740 740 searching for changes
741 741 no changes found
742 742 [1]
743 743
744 744 #if serve
745 745
746 746 $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
747 747 $ cat hg.pid >> $DAEMON_PIDS
748 748
749 749 $ hg incoming http://localhost:$HGPORT
750 750 comparing with http://localhost:$HGPORT/
751 751 searching for changes
752 752 1:3816541e5485 (draft) [tip ] A
753 753 $ hg outgoing http://localhost:$HGPORT
754 754 comparing with http://localhost:$HGPORT/
755 755 searching for changes
756 756 no changes found
757 757 [1]
758 758
759 759 $ killdaemons.py
760 760
761 761 #endif
762 762
763 763 This test issue 3814
764 764
765 765 (nothing to push but locally hidden changeset)
766 766
767 767 $ cd ..
768 768 $ hg init repo-issue3814
769 769 $ cd repo-issue3805
770 770 $ hg push -r 3816541e5485 ../repo-issue3814
771 771 pushing to ../repo-issue3814
772 772 searching for changes
773 773 adding changesets
774 774 adding manifests
775 775 adding file changes
776 776 added 1 changesets with 1 changes to 1 files
777 777 2 new obsolescence markers
778 778 $ hg out ../repo-issue3814
779 779 comparing with ../repo-issue3814
780 780 searching for changes
781 781 no changes found
782 782 [1]
783 783
784 784 Test that a local tag blocks a changeset from being hidden
785 785
786 786 $ hg tag -l visible -r 0 --hidden
787 787 $ hg log -G
788 788 @ 2:3816541e5485 (draft) [tip ] A
789 789
790 790 x 0:193e9254ce7e (draft) [visible ] A
791 791
792 792 Test that removing a local tag does not cause some commands to fail
793 793
794 794 $ hg tag -l -r tip tiptag
795 795 $ hg tags
796 796 tiptag 2:3816541e5485
797 797 tip 2:3816541e5485
798 798 visible 0:193e9254ce7e
799 799 $ hg --config extensions.strip= strip -r tip --no-backup
800 800 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
801 801 $ hg tags
802 802 visible 0:193e9254ce7e
803 803 tip 0:193e9254ce7e
804 804
805 805 Test bundle overlay onto hidden revision
806 806
807 807 $ cd ..
808 808 $ hg init repo-bundleoverlay
809 809 $ cd repo-bundleoverlay
810 810 $ echo "A" > foo
811 811 $ hg ci -Am "A"
812 812 adding foo
813 813 $ echo "B" >> foo
814 814 $ hg ci -m "B"
815 815 $ hg up 0
816 816 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
817 817 $ echo "C" >> foo
818 818 $ hg ci -m "C"
819 819 created new head
820 820 $ hg log -G
821 821 @ 2:c186d7714947 (draft) [tip ] C
822 822 |
823 823 | o 1:44526ebb0f98 (draft) [ ] B
824 824 |/
825 825 o 0:4b34ecfb0d56 (draft) [ ] A
826 826
827 827
828 828 $ hg clone -r1 . ../other-bundleoverlay
829 829 adding changesets
830 830 adding manifests
831 831 adding file changes
832 832 added 2 changesets with 2 changes to 1 files
833 833 updating to branch default
834 834 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
835 835 $ cd ../other-bundleoverlay
836 836 $ echo "B+" >> foo
837 837 $ hg ci --amend -m "B+"
838 838 $ hg log -G --hidden
839 839 @ 3:b7d587542d40 (draft) [tip ] B+
840 840 |
841 841 | x 2:eb95e9297e18 (draft) [ ] temporary amend commit for 44526ebb0f98
842 842 | |
843 843 | x 1:44526ebb0f98 (draft) [ ] B
844 844 |/
845 845 o 0:4b34ecfb0d56 (draft) [ ] A
846 846
847 847
848 848 $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
849 849 comparing with ../repo-bundleoverlay
850 850 searching for changes
851 851 1:44526ebb0f98 (draft) [ ] B
852 852 2:c186d7714947 (draft) [tip ] C
853 853 $ hg log -G -R ../bundleoverlay.hg
854 854 o 4:c186d7714947 (draft) [tip ] C
855 855 |
856 856 | @ 3:b7d587542d40 (draft) [ ] B+
857 857 |/
858 858 o 0:4b34ecfb0d56 (draft) [ ] A
859 859
860 860
861 861 #if serve
862 862
863 863 Test issue 4506
864 864
865 865 $ cd ..
866 866 $ hg init repo-issue4506
867 867 $ cd repo-issue4506
868 868 $ echo "0" > foo
869 869 $ hg add foo
870 870 $ hg ci -m "content-0"
871 871
872 872 $ hg up null
873 873 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
874 874 $ echo "1" > bar
875 875 $ hg add bar
876 876 $ hg ci -m "content-1"
877 877 created new head
878 878 $ hg up 0
879 879 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
880 880 $ hg graft 1
881 881 grafting 1:1c9eddb02162 "content-1" (tip)
882 882
883 883 $ hg debugobsolete `hg log -r1 -T'{node}'` `hg log -r2 -T'{node}'`
884 884
885 885 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
886 886 $ cat hg.pid >> $DAEMON_PIDS
887 887
888 888 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/1'
889 889 404 Not Found
890 890 [1]
891 891 $ get-with-headers.py --headeronly localhost:$HGPORT 'file/tip/bar'
892 892 200 Script output follows
893 893 $ get-with-headers.py --headeronly localhost:$HGPORT 'annotate/tip/bar'
894 894 200 Script output follows
895 895
896 896 $ killdaemons.py
897 897
898 898 #endif
899 899
900 900 Test heads computation on pending index changes with obsolescence markers
901 901 $ cd ..
902 902 $ cat >$TESTTMP/test_extension.py << EOF
903 903 > from mercurial import cmdutil
904 904 > from mercurial.i18n import _
905 905 >
906 906 > cmdtable = {}
907 907 > command = cmdutil.command(cmdtable)
908 908 > @command("amendtransient",[], _('hg amendtransient [rev]'))
909 909 > def amend(ui, repo, *pats, **opts):
910 910 > def commitfunc(ui, repo, message, match, opts):
911 911 > return repo.commit(message, repo['.'].user(), repo['.'].date(), match)
912 912 > opts['message'] = 'Test'
913 913 > opts['logfile'] = None
914 914 > cmdutil.amend(ui, repo, commitfunc, repo['.'], {}, pats, opts)
915 915 > print repo.changelog.headrevs()
916 916 > EOF
917 917 $ cat >> $HGRCPATH << EOF
918 918 > [extensions]
919 919 > testextension=$TESTTMP/test_extension.py
920 920 > EOF
921 921 $ hg init repo-issue-nativerevs-pending-changes
922 922 $ cd repo-issue-nativerevs-pending-changes
923 923 $ mkcommit a
924 924 $ mkcommit b
925 925 $ hg up ".^"
926 926 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
927 927 $ echo aa > a
928 928 $ hg amendtransient
929 929 [1, 3]
930
931 Test cache consistency for the visible filter
932 1) We want to make sure that the cached filtered revs are invalidated when
933 bookmarks change
934 $ cd ..
935 $ cat >$TESTTMP/test_extension.py << EOF
936 > from mercurial import cmdutil, extensions, bookmarks, repoview
937 > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
938 > repo = bkmstoreinst._repo
939 > ret = orig(bkmstoreinst, *args, **kwargs)
940 > hidden1 = repoview.computehidden(repo)
941 > hidden = repoview.filterrevs(repo, 'visible')
942 > if sorted(hidden1) != sorted(hidden):
943 > print "cache inconsistency"
944 > return ret
945 > def extsetup(ui):
946 > extensions.wrapfunction(bookmarks.bmstore, 'write', _bookmarkchanged)
947 > EOF
948
949 $ hg init repo-cache-inconsistency
950 $ cd repo-issue-nativerevs-pending-changes
951 $ mkcommit a
952 a already tracked!
953 $ mkcommit b
954 $ hg id
955 13bedc178fce tip
956 $ echo "hello" > b
957 $ hg commit --amend -m "message"
958 $ hg book bookb -r 13bedc178fce --hidden
959 $ hg log -r 13bedc178fce
960 5:13bedc178fce (draft) [ bookb] add b
961 $ hg book -d bookb
962 $ hg log -r 13bedc178fce
963 abort: hidden revision '13bedc178fce'!
964 (use --hidden to access hidden revisions)
965 [255]
966
967
968
General Comments 0
You need to be logged in to leave comments. Login now