[PATCH] strip: factor out revset calculation for strip -B

Ryan McElroy rm at fb.com
Tue Oct 13 01:26:31 CDT 2015


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1444427339 25200
#      Fri Oct 09 14:48:59 2015 -0700
# Node ID 46e08e9b27198502662670f8299eee3267c8e6f4
# Parent  a38924f7680c6b7d95e14ade999c35748c9dcafd
strip: factor out revset calculation for strip -B

This will allow reusing it in evolve and overriding it in other extensions.

diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -142,10 +142,7 @@ def stripcmd(ui, repo, *revs, **opts):
                     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
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -299,3 +299,15 @@ def rebuildfncache(ui, repo):
     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)
+


More information about the Mercurial-devel mailing list