scmutil: move repair.stripbmrevset as scmutil.bookmarkrevs (API)
authorDavid Demelier <markand@malikania.fr>
Tue, 15 May 2018 14:35:41 +0200
changeset 38131 46c2b19a1263
parent 38130 a40cc6d7d8c3
child 38132 2b8cb0ab231c
scmutil: move repair.stripbmrevset as scmutil.bookmarkrevs (API)
hgext/patchbomb.py
hgext/strip.py
mercurial/commands.py
mercurial/repair.py
mercurial/scmutil.py
--- a/hgext/patchbomb.py	Tue May 22 23:48:08 2018 -0400
+++ b/hgext/patchbomb.py	Tue May 15 14:35:41 2018 +0200
@@ -94,7 +94,6 @@
     patch,
     pycompat,
     registrar,
-    repair,
     scmutil,
     templater,
     util,
@@ -624,7 +623,7 @@
     elif bookmark:
         if bookmark not in repo._bookmarks:
             raise error.Abort(_("bookmark '%s' not found") % bookmark)
-        revs = repair.stripbmrevset(repo, bookmark)
+        revs = scmutil.bookmarkrevs(repo, bookmark)
 
     revs = scmutil.revrange(repo, revs)
     if outgoing:
--- a/hgext/strip.py	Tue May 22 23:48:08 2018 -0400
+++ b/hgext/strip.py	Tue May 15 14:35:41 2018 +0200
@@ -165,7 +165,7 @@
                 nodetobookmarks.setdefault(node, []).append(mark)
             for marks in nodetobookmarks.values():
                 if bookmarks.issuperset(marks):
-                    rsrevs = repair.stripbmrevset(repo, marks[0])
+                    rsrevs = scmutil.bookmarkrevs(repo, marks[0])
                     revs.update(set(rsrevs))
             if not revs:
                 with repo.lock(), repo.transaction('bookmark') as tr:
--- a/mercurial/commands.py	Tue May 22 23:48:08 2018 -0400
+++ b/mercurial/commands.py	Tue May 15 14:35:41 2018 +0200
@@ -50,7 +50,6 @@
     pycompat,
     rcutil,
     registrar,
-    repair,
     revsetlang,
     rewriteutil,
     scmutil,
@@ -1982,7 +1981,7 @@
         if bookmark not in repo._bookmarks:
             raise error.Abort(_("bookmark '%s' not found") % bookmark)
 
-        revs = repair.stripbmrevset(repo, bookmark)
+        revs = scmutil.bookmarkrevs(repo, bookmark)
     else:
         if not changesets:
             changesets = ['.']
--- a/mercurial/repair.py	Tue May 22 23:48:08 2018 -0400
+++ b/mercurial/repair.py	Tue May 15 14:35:41 2018 +0200
@@ -405,18 +405,6 @@
         else:
             ui.write(_('fncache already up to date\n'))
 
-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)
-
 def deleteobsmarkers(obsstore, indices):
     """Delete some obsmarkers from obsstore and return how many were deleted
 
--- a/mercurial/scmutil.py	Tue May 22 23:48:08 2018 -0400
+++ b/mercurial/scmutil.py	Tue May 15 14:35:41 2018 +0200
@@ -1585,3 +1585,12 @@
                 revs.add(rev)
 
     return revs
+
+def bookmarkrevs(repo, mark):
+    """
+    Select revisions reachable by a given bookmark
+    """
+    return repo.revs("ancestors(bookmark(%s)) - "
+                     "ancestors(head() and not bookmark(%s)) - "
+                     "ancestors(bookmark() and not bookmark(%s))",
+                     mark, mark, mark)