changeset 5995:d4cdba7077db stable

compat: patch overlayworkingctx._markdirty() for hg 5.0 and earlier This is required for the fix for issue6416 (4a09e95d29c9) to work on older Mercurial versions.
author Anton Shestakov <av6@dwimlabs.net>
date Sun, 08 Aug 2021 01:00:45 +0300
parents 189f4775ac2b
children 91c3a9dd5f77 4c208bb90c5b
files hgext3rd/evolve/compat.py
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/compat.py	Sun Aug 08 00:59:11 2021 +0300
+++ b/hgext3rd/evolve/compat.py	Sun Aug 08 01:00:45 2021 +0300
@@ -493,3 +493,39 @@
                         flags=self.flags(path), copied=origin)
 
     context.overlayworkingctx.markcopied = fixedmarkcopied
+
+# what we're actually targeting here is e079e001d536
+# hg <= 5.0 (dc3fdd1b5af4)
+try:
+    from mercurial import state as statemod
+    markdirtyfixed = util.safehasattr(statemod, '_statecheck')
+except (AttributeError, ImportError):
+    markdirtyfixed = False
+if not markdirtyfixed:
+    def fixedmarkdirty(
+        self,
+        path,
+        exists,
+        data=None,
+        date=None,
+        flags='',
+        copied=None,
+    ):
+        # data not provided, let's see if we already have some; if not, let's
+        # grab it from our underlying context, so that we always have data if
+        # the file is marked as existing.
+        if exists and data is None:
+            oldentry = self._cache.get(path) or {}
+            data = oldentry.get('data')
+            if data is None:
+                data = self._wrappedctx[path].data()
+
+        self._cache[path] = {
+            'exists': exists,
+            'data': data,
+            'date': date,
+            'flags': flags,
+            'copied': copied,
+        }
+
+    context.overlayworkingctx._markdirty = fixedmarkdirty