comparison hgext3rd/topic/__init__.py @ 2906:92566275be77

convertbookmark: extract the revset into a module level constant This will make it easier to read and modify the query.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 01 Sep 2017 17:09:17 +0200
parents 610d06bcd714
children d617128279f6
comparison
equal deleted inserted replaced
2905:610d06bcd714 2906:92566275be77
515 _convertbmarktopic(ui, repo, revnum, bmark, tr) 515 _convertbmarktopic(ui, repo, revnum, bmark, tr)
516 tr.close() 516 tr.close()
517 finally: 517 finally:
518 lockmod.release(tr, lock, wlock) 518 lockmod.release(tr, lock, wlock)
519 519
520 # inspired from mercurial.repair.stripbmrevset
521 CONVERTBOOKREVSET = """
522 not public() and (
523 ancestors(bookmark(%s))
524 and not (
525 ancestors(
526 head()
527 and not bookmark(%s)
528 )
529 or ancestors(
530 bookmark()
531 and not bookmark(%s)
532 )
533 )
534 )
535 """
536
520 def _convertbmarktopic(ui, repo, rev, bmark, tr): 537 def _convertbmarktopic(ui, repo, rev, bmark, tr):
521 """Sets a topic as same as bname to all the changesets under the bookmark 538 """Sets a topic as same as bname to all the changesets under the bookmark
522 and delete the bookmark, if topic is set to any changeset 539 and delete the bookmark, if topic is set to any changeset
523 540
524 rev is the revision on which bookmark bmark is and tr is transaction object. 541 rev is the revision on which bookmark bmark is and tr is transaction object.
525 """ 542 """
526 543
527 # copied from mercurial.repair.stripbmrevset 544 touchedrevs = repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark)
528 bookrevset = ("not public() and (ancestors(bookmark(%s)) - ancestors(head()"
529 "and not bookmark(%s)) - ancestors(bookmark()"
530 "and not bookmark(%s)))")
531 touchedrevs = repo.revs(bookrevset, bmark, bmark, bmark)
532 rewrote = _changetopics(ui, repo, touchedrevs, bmark) 545 rewrote = _changetopics(ui, repo, touchedrevs, bmark)
533 # We didn't changed topic to any changesets because the revset 546 # We didn't changed topic to any changesets because the revset
534 # returned an empty set of revisions, so let's skip deleting the 547 # returned an empty set of revisions, so let's skip deleting the
535 # bookmark corresponding to which we didn't put a topic on any 548 # bookmark corresponding to which we didn't put a topic on any
536 # changeset 549 # changeset