Mercurial > hg
comparison mercurial/metadata.py @ 45611:e5578dbe36cb
changing-files: add the ability to track merged files too
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.
Differential Revision: https://phab.mercurial-scm.org/D9087
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 24 Sep 2020 09:50:09 +0200 |
parents | 3d5b2b8e93fd |
children | ddcee0b0fd67 |
comparison
equal
deleted
inserted
replaced
45610:496537c9c1b4 | 45611:e5578dbe36cb |
---|---|
26 """A class recording the changes made to a file by a changeset | 26 """A class recording the changes made to a file by a changeset |
27 | 27 |
28 Actions performed on files are gathered into 3 sets: | 28 Actions performed on files are gathered into 3 sets: |
29 | 29 |
30 - added: files actively added in the changeset. | 30 - added: files actively added in the changeset. |
31 - merged: files whose history got merged | |
31 - removed: files removed in the revision | 32 - removed: files removed in the revision |
32 - touched: files affected by the merge | 33 - touched: files affected by the merge |
33 | 34 |
34 and copies information is held by 2 mappings | 35 and copies information is held by 2 mappings |
35 | 36 |
42 def __init__( | 43 def __init__( |
43 self, | 44 self, |
44 touched=None, | 45 touched=None, |
45 added=None, | 46 added=None, |
46 removed=None, | 47 removed=None, |
48 merged=None, | |
47 p1_copies=None, | 49 p1_copies=None, |
48 p2_copies=None, | 50 p2_copies=None, |
49 ): | 51 ): |
50 self._added = set(() if added is None else added) | 52 self._added = set(() if added is None else added) |
53 self._merged = set(() if merged is None else merged) | |
51 self._removed = set(() if removed is None else removed) | 54 self._removed = set(() if removed is None else removed) |
52 self._touched = set(() if touched is None else touched) | 55 self._touched = set(() if touched is None else touched) |
53 self._touched.update(self._added) | 56 self._touched.update(self._added) |
57 self._touched.update(self._merged) | |
54 self._touched.update(self._removed) | 58 self._touched.update(self._removed) |
55 self._p1_copies = dict(() if p1_copies is None else p1_copies) | 59 self._p1_copies = dict(() if p1_copies is None else p1_copies) |
56 self._p2_copies = dict(() if p2_copies is None else p2_copies) | 60 self._p2_copies = dict(() if p2_copies is None else p2_copies) |
57 | 61 |
58 def __eq__(self, other): | 62 def __eq__(self, other): |
59 return ( | 63 return ( |
60 self.added == other.added | 64 self.added == other.added |
65 and self.merged == other.merged | |
61 and self.removed == other.removed | 66 and self.removed == other.removed |
62 and self.touched == other.touched | 67 and self.touched == other.touched |
63 and self.copied_from_p1 == other.copied_from_p1 | 68 and self.copied_from_p1 == other.copied_from_p1 |
64 and self.copied_from_p2 == other.copied_from_p2 | 69 and self.copied_from_p2 == other.copied_from_p2 |
65 ) | 70 ) |
82 self._touched.add(filename) | 87 self._touched.add(filename) |
83 | 88 |
84 def update_added(self, filenames): | 89 def update_added(self, filenames): |
85 for f in filenames: | 90 for f in filenames: |
86 self.mark_added(f) | 91 self.mark_added(f) |
92 | |
93 @property | |
94 def merged(self): | |
95 """files actively merged during a merge | |
96 | |
97 Any modified files which had modification on both size that needed merging. | |
98 | |
99 In this case a new filenode was created and it has two parents. | |
100 """ | |
101 return frozenset(self._merged) | |
102 | |
103 def mark_merged(self, filename): | |
104 self._merged.add(filename) | |
105 self._touched.add(filename) | |
106 | |
107 def update_merged(self, filenames): | |
108 for f in filenames: | |
109 self.mark_merged(f) | |
87 | 110 |
88 @property | 111 @property |
89 def removed(self): | 112 def removed(self): |
90 """files actively removed by the changeset | 113 """files actively removed by the changeset |
91 | 114 |