# HG changeset patch # User Pierre-Yves David # Date 1504278557 -7200 # Node ID 92566275be771fde890c753ec7f3b6fb81669f5a # Parent 610d06bcd714c93ce88b8aa94e154472f57c3aef convertbookmark: extract the revset into a module level constant This will make it easier to read and modify the query. diff -r 610d06bcd714 -r 92566275be77 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Sep 01 17:04:21 2017 +0200 +++ b/hgext3rd/topic/__init__.py Fri Sep 01 17:09:17 2017 +0200 @@ -517,6 +517,23 @@ finally: lockmod.release(tr, lock, wlock) +# inspired from mercurial.repair.stripbmrevset +CONVERTBOOKREVSET = """ +not public() and ( + ancestors(bookmark(%s)) + and not ( + ancestors( + head() + and not bookmark(%s) + ) + or ancestors( + bookmark() + and not bookmark(%s) + ) + ) +) +""" + def _convertbmarktopic(ui, repo, rev, bmark, tr): """Sets a topic as same as bname to all the changesets under the bookmark and delete the bookmark, if topic is set to any changeset @@ -524,11 +541,7 @@ rev is the revision on which bookmark bmark is and tr is transaction object. """ - # copied from mercurial.repair.stripbmrevset - bookrevset = ("not public() and (ancestors(bookmark(%s)) - ancestors(head()" - "and not bookmark(%s)) - ancestors(bookmark()" - "and not bookmark(%s)))") - touchedrevs = repo.revs(bookrevset, bmark, bmark, bmark) + touchedrevs = repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark) rewrote = _changetopics(ui, repo, touchedrevs, bmark) # We didn't changed topic to any changesets because the revset # returned an empty set of revisions, so let's skip deleting the