Patchwork D1238: overlayworkingctx: add _manifest, files(), added(), removed(), modified()

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2017, 9:23 p.m.
Message ID <cd27d75421613c4c623160575978701d@localhost.localdomain>
Download mbox | patch
Permalink /patch/26018/
State Not Applicable
Headers show

Comments

phabricator - Dec. 7, 2017, 9:23 p.m.
phillco updated this revision to Diff 4184.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1238?vs=3111&id=4184

REVISION DETAIL
  https://phab.mercurial-scm.org/D1238

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2050,6 +2050,43 @@ 
         else:
             return self._wrappedctx[path].data()
 
+    @propertycache
+    def _manifest(self):
+        parents = self.parents()
+        man = parents[0].manifest().copy()
+
+        flag = self._flagfunc
+        for path in self.added():
+            man[path] = addednodeid
+            man.setflag(path,'')
+        for path in self.modified():
+            man[path] = modifiednodeid
+            man.setflag(path, '')
+        for path in self.removed():
+            del man[path]
+        return man
+
+    @propertycache
+    def _flagfunc(self):
+        def f(path):
+            return self._cache[path]['flags']
+        return f
+
+    def files(self):
+        return sorted(self.added() + self.modified() + self.removed())
+
+    def modified(self):
+        return [f for f in self._cache.keys() if self._cache[f]['exists'] and
+                self._existsinparent(f)]
+
+    def added(self):
+        return [f for f in self._cache.keys() if self._cache[f]['exists'] and
+                not self._existsinparent(f)]
+
+    def removed(self):
+        return [f for f in self._cache.keys() if
+                not self._cache[f]['exists'] and self._existsinparent(f)]
+
     def isinmemory(self):
         return True