[PATCH 10 of 13 sparse] merge: move getrawprofile() from sparse

Gregory Szorc gregory.szorc at gmail.com
Sat Jul 1 21:55:27 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1498946764 25200
#      Sat Jul 01 15:06:04 2017 -0700
# Node ID 3d25c8086aa11be32b459d944098118a59fbc46d
# Parent  a2d07300bdc999403954e965debf53db898ccdc3
merge: move getrawprofile() from sparse

Our more step towards weaning off methods on repo instances and
moving code to core. While this function is only used once and
is simple, it needs to exist on its own so Facebook can monkeypatch
it to enable simplecache integration.

diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -431,7 +431,7 @@ def _wraprepo(ui, repo):
                     visited.add(profile)
 
                     try:
-                        raw = self.getrawprofile(profile, rev)
+                        raw = mergemod.rawsparseprofile(self, profile, rev)
                     except error.ManifestLookupError:
                         msg = (
                             "warning: sparse profile '%s' not found "
@@ -455,9 +455,6 @@ def _wraprepo(ui, repo):
                 includes.add('.hg*')
             return includes, excludes, profiles
 
-        def getrawprofile(self, profile, changeid):
-            return self.filectx(profile, changeid=changeid).data()
-
         def _sparsechecksum(self, path):
             data = self.vfs.read(path)
             return hashlib.sha1(data).hexdigest()
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1781,3 +1781,7 @@ def readsparseconfig(ui, raw):
             current.add(line)
 
     return includes, excludes, profiles
+
+# Exists as separate function to facilitate monkeypatching.
+def rawsparseprofile(repo, profile, changeid):
+    return repo.filectx(profile, changeid=changeid).data()


More information about the Mercurial-devel mailing list