Patchwork D9087: changing-files: add the ability to track merged files too

login
register
mail settings
Submitter phabricator
Date Sept. 26, 2020, 12:10 p.m.
Message ID <differential-rev-PHID-DREV-isq3s3juqyll5n3o3yeg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47289/
State Superseded
Headers show

Comments

phabricator - Sept. 26, 2020, 12:10 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The set of merged files is used when doing changeset centric copy tracing (cf
  `is_merged` in `mercurial/copies.py`. So tracking (and persisting) this set will
  be useful. We start with adding the attribute on the new object.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/metadata.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/metadata.py b/mercurial/metadata.py
--- a/mercurial/metadata.py
+++ b/mercurial/metadata.py
@@ -28,6 +28,7 @@ 
     Actions performed on files are gathered into 3 sets:
 
     - added:   files actively added in the changeset.
+    - merged:  files whose history got merged
     - removed: files removed in the revision
     - touched: files affected by the merge
 
@@ -44,13 +45,16 @@ 
         touched=None,
         added=None,
         removed=None,
+        merged=None,
         p1_copies=None,
         p2_copies=None,
     ):
         self._added = set(() if added is None else added)
+        self._merged = set(() if merged is None else merged)
         self._removed = set(() if removed is None else removed)
         self._touched = set(() if touched is None else touched)
         self._touched.update(self._added)
+        self._touched.update(self._merged)
         self._touched.update(self._removed)
         self._p1_copies = dict(() if p1_copies is None else p1_copies)
         self._p2_copies = dict(() if p2_copies is None else p2_copies)
@@ -58,6 +62,7 @@ 
     def __eq__(self, other):
         return (
             self.added == other.added
+            and self.merged == other.merged
             and self.removed == other.removed
             and self.touched == other.touched
             and self.copied_from_p1 == other.copied_from_p1
@@ -86,6 +91,24 @@ 
             self.mark_added(f)
 
     @property
+    def merged(self):
+        """files actively merged during a merge
+
+        Any modified files which had modification on both size that needed merging.
+
+        In this case a new filenode was created and it has two parents.
+        """
+        return frozenset(self._merged)
+
+    def mark_merged(self, filename):
+        self._merged.add(filename)
+        self._touched.add(filename)
+
+    def update_merged(self, filenames):
+        for f in filenames:
+            self.mark_merged(f)
+
+    @property
     def removed(self):
         """files actively removed by the changeset