Patchwork [1,of,2] strip: move tree strip logic to it's own function

login
register
mail settings
Submitter Durham Goode
Date May 8, 2017, 6:40 p.m.
Message ID <5dec5907fe49a488d3ad.1494268802@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/20523/
State Accepted
Headers show

Comments

Durham Goode - May 8, 2017, 6:40 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1494268523 25200
#      Mon May 08 11:35:23 2017 -0700
# Node ID 5dec5907fe49a488d3ade272d4a5cf090914e59c
# Parent  8f1a2b848b52ea7bf3fe2404e3b62924c7aae93f
strip: move tree strip logic to it's own function

This will allow external extensions to modify tree strip behavior more
precisely.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -165,13 +165,8 @@  def strip(ui, repo, nodelist, backup=Tru
             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 @@  def strip(ui, repo, nodelist, backup=Tru
     # 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.