Show More
@@ -64,12 +64,10 def commitctx(repo, ctx, error=False, or | |||||
64 | user = ctx.user() |
|
64 | user = ctx.user() | |
65 |
|
65 | |||
66 | with repo.lock(), repo.transaction(b"commit") as tr: |
|
66 | with repo.lock(), repo.transaction(b"commit") as tr: | |
67 |
|
|
67 | mn, files = _prepare_files(tr, ctx, error=error, origctx=origctx) | |
68 | mn, files, p1copies, p2copies, filesadded, filesremoved = r |
|
|||
69 |
|
68 | |||
70 | extra = ctx.extra().copy() |
|
69 | extra = ctx.extra().copy() | |
71 |
|
70 | |||
72 | files = sorted(files) |
|
|||
73 | if extra is not None: |
|
71 | if extra is not None: | |
74 | for name in ( |
|
72 | for name in ( | |
75 | b'p1copies', |
|
73 | b'p1copies', | |
@@ -79,16 +77,14 def commitctx(repo, ctx, error=False, or | |||||
79 | ): |
|
77 | ): | |
80 | extra.pop(name, None) |
|
78 | extra.pop(name, None) | |
81 | if repo.changelog._copiesstorage == b'extra': |
|
79 | if repo.changelog._copiesstorage == b'extra': | |
82 | extra = _extra_with_copies( |
|
80 | extra = _extra_with_copies(repo, extra, files) | |
83 | repo, extra, files, p1copies, p2copies, filesadded, filesremoved |
|
|||
84 | ) |
|
|||
85 |
|
81 | |||
86 | # update changelog |
|
82 | # update changelog | |
87 | repo.ui.note(_(b"committing changelog\n")) |
|
83 | repo.ui.note(_(b"committing changelog\n")) | |
88 | repo.changelog.delayupdate(tr) |
|
84 | repo.changelog.delayupdate(tr) | |
89 | n = repo.changelog.add( |
|
85 | n = repo.changelog.add( | |
90 | mn, |
|
86 | mn, | |
91 | files, |
|
87 | files.touched, | |
92 | ctx.description(), |
|
88 | ctx.description(), | |
93 | tr, |
|
89 | tr, | |
94 | p1.node(), |
|
90 | p1.node(), | |
@@ -96,10 +92,10 def commitctx(repo, ctx, error=False, or | |||||
96 | user, |
|
92 | user, | |
97 | ctx.date(), |
|
93 | ctx.date(), | |
98 | extra, |
|
94 | extra, | |
99 |
|
|
95 | files.copied_from_p1, | |
100 |
|
|
96 | files.copied_from_p2, | |
101 | filesadded, |
|
97 | files.added, | |
102 | filesremoved, |
|
98 | files.removed, | |
103 | ) |
|
99 | ) | |
104 | xp1, xp2 = p1.hex(), p2 and p2.hex() or b'' |
|
100 | xp1, xp2 = p1.hex(), p2 and p2.hex() or b'' | |
105 | repo.hook( |
|
101 | repo.hook( | |
@@ -149,7 +145,19 def _prepare_files(tr, ctx, error=False, | |||||
149 | if origctx and origctx.manifestnode() == mn: |
|
145 | if origctx and origctx.manifestnode() == mn: | |
150 | touched = origctx.files() |
|
146 | touched = origctx.files() | |
151 |
|
147 | |||
152 | return mn, touched, p1copies, p2copies, filesadded, filesremoved |
|
148 | files = metadata.ChangingFiles() | |
|
149 | if touched: | |||
|
150 | files.update_touched(touched) | |||
|
151 | if p1copies: | |||
|
152 | files.update_copies_from_p1(p1copies) | |||
|
153 | if p2copies: | |||
|
154 | files.update_copies_from_p2(p2copies) | |||
|
155 | if filesadded: | |||
|
156 | files.update_added(filesadded) | |||
|
157 | if filesremoved: | |||
|
158 | files.update_removed(filesremoved) | |||
|
159 | ||||
|
160 | return mn, files | |||
153 |
|
161 | |||
154 |
|
162 | |||
155 | def _process_files(tr, ctx, error=False): |
|
163 | def _process_files(tr, ctx, error=False): | |
@@ -413,10 +421,13 def _commit_manifest(tr, linkrev, ctx, m | |||||
413 | return mn |
|
421 | return mn | |
414 |
|
422 | |||
415 |
|
423 | |||
416 | def _extra_with_copies( |
|
424 | def _extra_with_copies(repo, extra, files): | |
417 | repo, extra, files, p1copies, p2copies, filesadded, filesremoved |
|
|||
418 | ): |
|
|||
419 | """encode copy information into a `extra` dictionnary""" |
|
425 | """encode copy information into a `extra` dictionnary""" | |
|
426 | p1copies = files.copied_from_p1 | |||
|
427 | p2copies = files.copied_from_p2 | |||
|
428 | filesadded = files.added | |||
|
429 | filesremoved = files.removed | |||
|
430 | files = sorted(files.touched) | |||
420 | if not _write_copy_meta(repo)[1]: |
|
431 | if not _write_copy_meta(repo)[1]: | |
421 | # If writing only to changeset extras, use None to indicate that |
|
432 | # If writing only to changeset extras, use None to indicate that | |
422 | # no entry should be written. If writing to both, write an empty |
|
433 | # no entry should be written. If writing to both, write an empty |
@@ -22,6 +22,79 from .revlogutils import ( | |||||
22 | ) |
|
22 | ) | |
23 |
|
23 | |||
24 |
|
24 | |||
|
25 | class ChangingFiles(object): | |||
|
26 | """A class recording the changes made to a file by a revision | |||
|
27 | """ | |||
|
28 | ||||
|
29 | def __init__( | |||
|
30 | self, touched=(), added=(), removed=(), p1_copies=(), p2_copies=(), | |||
|
31 | ): | |||
|
32 | self._added = set(added) | |||
|
33 | self._removed = set(removed) | |||
|
34 | self._touched = set(touched) | |||
|
35 | self._touched.update(self._added) | |||
|
36 | self._touched.update(self._removed) | |||
|
37 | self._p1_copies = dict(p1_copies) | |||
|
38 | self._p2_copies = dict(p2_copies) | |||
|
39 | ||||
|
40 | @property | |||
|
41 | def added(self): | |||
|
42 | return frozenset(self._added) | |||
|
43 | ||||
|
44 | def mark_added(self, filename): | |||
|
45 | self._added.add(filename) | |||
|
46 | self._touched.add(filename) | |||
|
47 | ||||
|
48 | def update_added(self, filenames): | |||
|
49 | for f in filenames: | |||
|
50 | self.mark_added(f) | |||
|
51 | ||||
|
52 | @property | |||
|
53 | def removed(self): | |||
|
54 | return frozenset(self._removed) | |||
|
55 | ||||
|
56 | def mark_removed(self, filename): | |||
|
57 | self._removed.add(filename) | |||
|
58 | self._touched.add(filename) | |||
|
59 | ||||
|
60 | def update_removed(self, filenames): | |||
|
61 | for f in filenames: | |||
|
62 | self.mark_removed(f) | |||
|
63 | ||||
|
64 | @property | |||
|
65 | def touched(self): | |||
|
66 | return frozenset(self._touched) | |||
|
67 | ||||
|
68 | def mark_touched(self, filename): | |||
|
69 | self._touched.add(filename) | |||
|
70 | ||||
|
71 | def update_touched(self, filenames): | |||
|
72 | for f in filenames: | |||
|
73 | self.mark_touched(f) | |||
|
74 | ||||
|
75 | @property | |||
|
76 | def copied_from_p1(self): | |||
|
77 | return self._p1_copies.copy() | |||
|
78 | ||||
|
79 | def mark_copied_from_p1(self, source, dest): | |||
|
80 | self._p1_copies[dest] = source | |||
|
81 | ||||
|
82 | def update_copies_from_p1(self, copies): | |||
|
83 | for dest, source in copies.items(): | |||
|
84 | self.mark_copied_from_p1(source, dest) | |||
|
85 | ||||
|
86 | @property | |||
|
87 | def copied_from_p2(self): | |||
|
88 | return self._p2_copies.copy() | |||
|
89 | ||||
|
90 | def mark_copied_from_p2(self, source, dest): | |||
|
91 | self._p2_copies[dest] = source | |||
|
92 | ||||
|
93 | def update_copies_from_p2(self, copies): | |||
|
94 | for dest, source in copies.items(): | |||
|
95 | self.mark_copied_from_p2(source, dest) | |||
|
96 | ||||
|
97 | ||||
25 | def computechangesetfilesadded(ctx): |
|
98 | def computechangesetfilesadded(ctx): | |
26 | """return the list of files added in a changeset |
|
99 | """return the list of files added in a changeset | |
27 | """ |
|
100 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now