strip: move tree strip logic to it's own function
authorDurham Goode <durham@fb.com>
Mon, 08 May 2017 11:35:23 -0700
changeset 32196 a2be2abe9476
parent 32195 9d3136638784
child 32197 7bcc9a5ab96e
strip: move tree strip logic to it's own function This will allow external extensions to modify tree strip behavior more precisely.
mercurial/repair.py
--- a/mercurial/repair.py	Mon May 08 09:39:21 2017 -0700
+++ b/mercurial/repair.py	Mon May 08 11:35:23 2017 -0700
@@ -165,13 +165,8 @@
             tr.startgroup()
             cl.strip(striprev, tr)
             mfst.strip(striprev, tr)
-            if 'treemanifest' in repo.requirements: # safe but unnecessary
-                                                    # otherwise
-                for unencoded, encoded, size in repo.store.datafiles():
-                    if (unencoded.startswith('meta/') and
-                        unencoded.endswith('00manifest.i')):
-                        dir = unencoded[5:-12]
-                        repo.manifestlog._revlog.dirlog(dir).strip(striprev, tr)
+            striptrees(repo, tr, striprev, files)
+
             for fn in files:
                 repo.file(fn).strip(striprev, tr)
             tr.endgroup()
@@ -240,6 +235,15 @@
     # extensions can use it
     return backupfile
 
+def striptrees(repo, tr, striprev, files):
+    if 'treemanifest' in repo.requirements: # safe but unnecessary
+                                            # otherwise
+        for unencoded, encoded, size in repo.store.datafiles():
+            if (unencoded.startswith('meta/') and
+                unencoded.endswith('00manifest.i')):
+                dir = unencoded[5:-12]
+                repo.manifestlog._revlog.dirlog(dir).strip(striprev, tr)
+
 def rebuildfncache(ui, repo):
     """Rebuilds the fncache file from repo history.