hgext3rd/topic/__init__.py
changeset 2906 92566275be77
parent 2905 610d06bcd714
child 2907 d617128279f6
--- 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