Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 2907:d617128279f6
converbookmark: split target computation from actual update
This will allow for further refactoring helping consistency.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 01 Sep 2017 18:33:08 +0200 |
parents | 92566275be77 |
children | 95bb27b8918c |
comparison
equal
deleted
inserted
replaced
2906:92566275be77 | 2907:d617128279f6 |
---|---|
486 revnum = repo[node].rev() | 486 revnum = repo[node].rev() |
487 try: | 487 try: |
488 wlock = repo.wlock() | 488 wlock = repo.wlock() |
489 lock = repo.lock() | 489 lock = repo.lock() |
490 tr = repo.transaction('debugconvertbookmark') | 490 tr = repo.transaction('debugconvertbookmark') |
491 _convertbmarktopic(ui, repo, revnum, bookmark, tr) | 491 targetrevs = _findconvertbmarktopic(repo, bookmark) |
492 _applyconvertbmarktopic(ui, repo, targetrevs, revnum, bookmark, tr) | |
492 tr.close() | 493 tr.close() |
493 finally: | 494 finally: |
494 lockmod.release(tr, lock, wlock) | 495 lockmod.release(tr, lock, wlock) |
495 | 496 |
496 elif convertall: | 497 elif convertall: |
510 " it\n") % revnum) | 511 " it\n") % revnum) |
511 skipped.append(revnum) | 512 skipped.append(revnum) |
512 continue | 513 continue |
513 if bmark == '@': | 514 if bmark == '@': |
514 continue | 515 continue |
515 _convertbmarktopic(ui, repo, revnum, bmark, tr) | 516 targetrevs = _findconvertbmarktopic(repo, bmark) |
517 _applyconvertbmarktopic(ui, repo, targetrevs, revnum, bmark, tr) | |
516 tr.close() | 518 tr.close() |
517 finally: | 519 finally: |
518 lockmod.release(tr, lock, wlock) | 520 lockmod.release(tr, lock, wlock) |
519 | 521 |
520 # inspired from mercurial.repair.stripbmrevset | 522 # inspired from mercurial.repair.stripbmrevset |
532 ) | 534 ) |
533 ) | 535 ) |
534 ) | 536 ) |
535 """ | 537 """ |
536 | 538 |
537 def _convertbmarktopic(ui, repo, rev, bmark, tr): | 539 def _findconvertbmarktopic(repo, bmark): |
538 """Sets a topic as same as bname to all the changesets under the bookmark | 540 """find revisions unambigiously defined by a bookmark |
541 | |
542 find all changesets under the bookmark and under that bookmark only. | |
543 """ | |
544 return repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark) | |
545 | |
546 def _applyconvertbmarktopic(ui, repo, revs, old, bmark, tr): | |
547 """apply bookmark convertion to topic | |
548 | |
549 Sets a topic as same as bname to all the changesets under the bookmark | |
539 and delete the bookmark, if topic is set to any changeset | 550 and delete the bookmark, if topic is set to any changeset |
540 | 551 |
541 rev is the revision on which bookmark bmark is and tr is transaction object. | 552 old is the revision on which bookmark bmark is and tr is transaction object. |
542 """ | 553 """ |
543 | 554 |
544 touchedrevs = repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark) | 555 rewrote = _changetopics(ui, repo, revs, bmark) |
545 rewrote = _changetopics(ui, repo, touchedrevs, bmark) | |
546 # We didn't changed topic to any changesets because the revset | 556 # We didn't changed topic to any changesets because the revset |
547 # returned an empty set of revisions, so let's skip deleting the | 557 # returned an empty set of revisions, so let's skip deleting the |
548 # bookmark corresponding to which we didn't put a topic on any | 558 # bookmark corresponding to which we didn't put a topic on any |
549 # changeset | 559 # changeset |
550 if rewrote == 0: | 560 if rewrote == 0: |
551 return | 561 return |
552 ui.status(_('changed topic to "%s" on %d revisions\n') % (bmark, | 562 ui.status(_('changed topic to "%s" on %d revisions\n') % (bmark, |
553 rewrote)) | 563 rewrote)) |
554 ui.debug('removing bookmark "%s" from "%d"' % (bmark, rev)) | 564 ui.debug('removing bookmark "%s" from "%d"' % (bmark, old)) |
555 bookmarks.delete(repo, tr, [bmark]) | 565 bookmarks.delete(repo, tr, [bmark]) |
556 | 566 |
557 def _changecurrenttopic(repo, newtopic): | 567 def _changecurrenttopic(repo, newtopic): |
558 """changes the current topic.""" | 568 """changes the current topic.""" |
559 | 569 |