diff --git a/hgext/strip.py b/hgext/strip.py
index 5a95fe44121d96805daacb2d9a84b947d8c68a03_aGdleHQvc3RyaXAucHk=..bcace0fbb4c80df96ddd9104addef11a32172348_aGdleHQvc3RyaXAucHk= 100644
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -142,10 +142,7 @@
                     uniquebm = False
                     break
             if uniquebm:
-                rsrevs = repo.revs("ancestors(bookmark(%s)) - "
-                                   "ancestors(head() and not bookmark(%s)) - "
-                                   "ancestors(bookmark() and not bookmark(%s))",
-                                   mark, mark, mark)
+                rsrevs = repair.stripbmrevset(repo, mark)
                 revs.update(set(rsrevs))
             if not revs:
                 del marks[mark]
diff --git a/mercurial/repair.py b/mercurial/repair.py
index 5a95fe44121d96805daacb2d9a84b947d8c68a03_bWVyY3VyaWFsL3JlcGFpci5weQ==..bcace0fbb4c80df96ddd9104addef11a32172348_bWVyY3VyaWFsL3JlcGFpci5weQ== 100644
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -299,3 +299,15 @@
     finally:
         lock.release()
 
+def stripbmrevset(repo, mark):
+    """
+    The revset to strip when strip is called with -B mark
+
+    Needs to live here so extensions can use it and wrap it even when strip is
+    not enabled or not present on a box.
+    """
+    return repo.revs("ancestors(bookmark(%s)) - "
+                     "ancestors(head() and not bookmark(%s)) - "
+                     "ancestors(bookmark() and not bookmark(%s))",
+                     mark, mark, mark)
+