Mercurial > hg
comparison mercurial/bookmarks.py @ 33512:1424a769f31b
bookmark: use 'divergent2delete' when updating a bookmark
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 10 Jul 2017 19:12:25 +0200 |
parents | 07b556d1b74e |
children | 904894edb205 |
comparison
equal
deleted
inserted
replaced
33511:9689239d7c2b | 33512:1424a769f31b |
---|---|
352 return (checkout, movemarkfrom) | 352 return (checkout, movemarkfrom) |
353 | 353 |
354 def update(repo, parents, node): | 354 def update(repo, parents, node): |
355 deletefrom = parents | 355 deletefrom = parents |
356 marks = repo._bookmarks | 356 marks = repo._bookmarks |
357 update = False | |
358 active = marks.active | 357 active = marks.active |
359 if not active: | 358 if not active: |
360 return False | 359 return False |
361 | 360 |
362 bmchanges = [] | 361 bmchanges = [] |
366 if b.split('@', 1)[0] == active.split('@', 1)[0]] | 365 if b.split('@', 1)[0] == active.split('@', 1)[0]] |
367 anc = repo.changelog.ancestors([new.rev()]) | 366 anc = repo.changelog.ancestors([new.rev()]) |
368 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new] | 367 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new] |
369 if validdest(repo, repo[marks[active]], new): | 368 if validdest(repo, repo[marks[active]], new): |
370 bmchanges.append((active, new.node())) | 369 bmchanges.append((active, new.node())) |
371 update = True | 370 |
372 | 371 for bm in divergent2delete(repo, deletefrom, active): |
373 if deletedivergent(repo, deletefrom, active): | 372 bmchanges.append((bm, None)) |
374 update = True | 373 |
375 | 374 if bmchanges: |
376 if update: | |
377 lock = tr = None | 375 lock = tr = None |
378 try: | 376 try: |
379 lock = repo.lock() | 377 lock = repo.lock() |
380 tr = repo.transaction('bookmark') | 378 tr = repo.transaction('bookmark') |
381 marks.applychanges(repo, tr, bmchanges) | 379 marks.applychanges(repo, tr, bmchanges) |
382 tr.close() | 380 tr.close() |
383 finally: | 381 finally: |
384 lockmod.release(tr, lock) | 382 lockmod.release(tr, lock) |
385 return update | 383 return bool(bmchanges) |
386 | 384 |
387 def listbinbookmarks(repo): | 385 def listbinbookmarks(repo): |
388 # We may try to list bookmarks on a repo type that does not | 386 # We may try to list bookmarks on a repo type that does not |
389 # support it (e.g., statichttprepository). | 387 # support it (e.g., statichttprepository). |
390 marks = getattr(repo, '_bookmarks', {}) | 388 marks = getattr(repo, '_bookmarks', {}) |