Show More
@@ -1,914 +1,918 b'' | |||
|
1 | 1 | # coding: utf8 |
|
2 | 2 | # metadata.py -- code related to various metadata computation and access. |
|
3 | 3 | # |
|
4 | 4 | # Copyright 2019 Google, Inc <martinvonz@google.com> |
|
5 | 5 | # Copyright 2020 Pierre-Yves David <pierre-yves.david@octobus.net> |
|
6 | 6 | # |
|
7 | 7 | # This software may be used and distributed according to the terms of the |
|
8 | 8 | # GNU General Public License version 2 or any later version. |
|
9 | 9 | from __future__ import absolute_import, print_function |
|
10 | 10 | |
|
11 | 11 | import multiprocessing |
|
12 | 12 | import struct |
|
13 | 13 | |
|
14 | 14 | from . import ( |
|
15 | 15 | error, |
|
16 | 16 | node, |
|
17 | 17 | pycompat, |
|
18 | 18 | util, |
|
19 | 19 | ) |
|
20 | 20 | |
|
21 | 21 | from .revlogutils import ( |
|
22 | 22 | flagutil as sidedataflag, |
|
23 | 23 | sidedata as sidedatamod, |
|
24 | 24 | ) |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | class ChangingFiles(object): |
|
28 | 28 | """A class recording the changes made to files by a changeset |
|
29 | 29 | |
|
30 | 30 | Actions performed on files are gathered into 3 sets: |
|
31 | 31 | |
|
32 | 32 | - added: files actively added in the changeset. |
|
33 | 33 | - merged: files whose history got merged |
|
34 | 34 | - removed: files removed in the revision |
|
35 | 35 | - salvaged: files that might have been deleted by a merge but were not |
|
36 | 36 | - touched: files affected by the merge |
|
37 | 37 | |
|
38 | 38 | and copies information is held by 2 mappings |
|
39 | 39 | |
|
40 | 40 | - copied_from_p1: {"<new-name>": "<source-name-in-p1>"} mapping for copies |
|
41 | 41 | - copied_from_p2: {"<new-name>": "<source-name-in-p2>"} mapping for copies |
|
42 | 42 | |
|
43 | 43 | See their inline help for details. |
|
44 | 44 | """ |
|
45 | 45 | |
|
46 | 46 | def __init__( |
|
47 | 47 | self, |
|
48 | 48 | touched=None, |
|
49 | 49 | added=None, |
|
50 | 50 | removed=None, |
|
51 | 51 | merged=None, |
|
52 | 52 | salvaged=None, |
|
53 | 53 | p1_copies=None, |
|
54 | 54 | p2_copies=None, |
|
55 | 55 | ): |
|
56 | 56 | self._added = set(() if added is None else added) |
|
57 | 57 | self._merged = set(() if merged is None else merged) |
|
58 | 58 | self._removed = set(() if removed is None else removed) |
|
59 | 59 | self._touched = set(() if touched is None else touched) |
|
60 | 60 | self._salvaged = set(() if salvaged is None else salvaged) |
|
61 | 61 | self._touched.update(self._added) |
|
62 | 62 | self._touched.update(self._merged) |
|
63 | 63 | self._touched.update(self._removed) |
|
64 | 64 | self._p1_copies = dict(() if p1_copies is None else p1_copies) |
|
65 | 65 | self._p2_copies = dict(() if p2_copies is None else p2_copies) |
|
66 | 66 | |
|
67 | 67 | def __eq__(self, other): |
|
68 | 68 | return ( |
|
69 | 69 | self.added == other.added |
|
70 | 70 | and self.merged == other.merged |
|
71 | 71 | and self.removed == other.removed |
|
72 | 72 | and self.salvaged == other.salvaged |
|
73 | 73 | and self.touched == other.touched |
|
74 | 74 | and self.copied_from_p1 == other.copied_from_p1 |
|
75 | 75 | and self.copied_from_p2 == other.copied_from_p2 |
|
76 | 76 | ) |
|
77 | 77 | |
|
78 | 78 | @util.propertycache |
|
79 | 79 | def added(self): |
|
80 | 80 | """files actively added in the changeset |
|
81 | 81 | |
|
82 | 82 | Any file present in that revision that was absent in all the changeset's |
|
83 | 83 | parents. |
|
84 | 84 | |
|
85 | 85 | In case of merge, this means a file absent in one of the parents but |
|
86 | 86 | existing in the other will *not* be contained in this set. (They were |
|
87 | 87 | added by an ancestor) |
|
88 | 88 | """ |
|
89 | 89 | return frozenset(self._added) |
|
90 | 90 | |
|
91 | 91 | def mark_added(self, filename): |
|
92 | 92 | if 'added' in vars(self): |
|
93 | 93 | del self.added |
|
94 | 94 | self._added.add(filename) |
|
95 | 95 | self.mark_touched(filename) |
|
96 | 96 | |
|
97 | 97 | def update_added(self, filenames): |
|
98 | 98 | for f in filenames: |
|
99 | 99 | self.mark_added(f) |
|
100 | 100 | |
|
101 | 101 | @util.propertycache |
|
102 | 102 | def merged(self): |
|
103 | 103 | """files actively merged during a merge |
|
104 | 104 | |
|
105 | 105 | Any modified files which had modification on both size that needed merging. |
|
106 | 106 | |
|
107 | 107 | In this case a new filenode was created and it has two parents. |
|
108 | 108 | """ |
|
109 | 109 | return frozenset(self._merged) |
|
110 | 110 | |
|
111 | 111 | def mark_merged(self, filename): |
|
112 | 112 | if 'merged' in vars(self): |
|
113 | 113 | del self.merged |
|
114 | 114 | self._merged.add(filename) |
|
115 | 115 | self.mark_touched(filename) |
|
116 | 116 | |
|
117 | 117 | def update_merged(self, filenames): |
|
118 | 118 | for f in filenames: |
|
119 | 119 | self.mark_merged(f) |
|
120 | 120 | |
|
121 | 121 | @util.propertycache |
|
122 | 122 | def removed(self): |
|
123 | 123 | """files actively removed by the changeset |
|
124 | 124 | |
|
125 | 125 | In case of merge this will only contain the set of files removing "new" |
|
126 | 126 | content. For any file absent in the current changeset: |
|
127 | 127 | |
|
128 | 128 | a) If the file exists in both parents, it is clearly "actively" removed |
|
129 | 129 | by this changeset. |
|
130 | 130 | |
|
131 | 131 | b) If a file exists in only one parent and in none of the common |
|
132 | 132 | ancestors, then the file was newly added in one of the merged branches |
|
133 | 133 | and then got "actively" removed. |
|
134 | 134 | |
|
135 | 135 | c) If a file exists in only one parent and at least one of the common |
|
136 | 136 | ancestors using the same filenode, then the file was unchanged on one |
|
137 | 137 | side and deleted on the other side. The merge "passively" propagated |
|
138 | 138 | that deletion, but didn't "actively" remove the file. In this case the |
|
139 | 139 | file is *not* included in the `removed` set. |
|
140 | 140 | |
|
141 | 141 | d) If a file exists in only one parent and at least one of the common |
|
142 | 142 | ancestors using a different filenode, then the file was changed on one |
|
143 | 143 | side and removed on the other side. The merge process "actively" |
|
144 | 144 | decided to drop the new change and delete the file. Unlike in the |
|
145 | 145 | previous case, (c), the file included in the `removed` set. |
|
146 | 146 | |
|
147 | 147 | Summary table for merge: |
|
148 | 148 | |
|
149 | 149 | case | exists in parents | exists in gca || removed |
|
150 | 150 | (a) | both | * || yes |
|
151 | 151 | (b) | one | none || yes |
|
152 | 152 | (c) | one | same filenode || no |
|
153 | 153 | (d) | one | new filenode || yes |
|
154 | 154 | """ |
|
155 | 155 | return frozenset(self._removed) |
|
156 | 156 | |
|
157 | 157 | def mark_removed(self, filename): |
|
158 | 158 | if 'removed' in vars(self): |
|
159 | 159 | del self.removed |
|
160 | 160 | self._removed.add(filename) |
|
161 | 161 | self.mark_touched(filename) |
|
162 | 162 | |
|
163 | 163 | def update_removed(self, filenames): |
|
164 | 164 | for f in filenames: |
|
165 | 165 | self.mark_removed(f) |
|
166 | 166 | |
|
167 | 167 | @util.propertycache |
|
168 | 168 | def salvaged(self): |
|
169 | 169 | """files that might have been deleted by a merge, but still exists. |
|
170 | 170 | |
|
171 | 171 | During a merge, the manifest merging might select some files for |
|
172 | 172 | removal, or for a removed/changed conflict. If at commit time the file |
|
173 | 173 | still exists, its removal was "reverted" and the file is "salvaged" |
|
174 | 174 | """ |
|
175 | 175 | return frozenset(self._salvaged) |
|
176 | 176 | |
|
177 | 177 | def mark_salvaged(self, filename): |
|
178 | 178 | if "salvaged" in vars(self): |
|
179 | 179 | del self.salvaged |
|
180 | 180 | self._salvaged.add(filename) |
|
181 | 181 | self.mark_touched(filename) |
|
182 | 182 | |
|
183 | 183 | def update_salvaged(self, filenames): |
|
184 | 184 | for f in filenames: |
|
185 | 185 | self.mark_salvaged(f) |
|
186 | 186 | |
|
187 | 187 | @util.propertycache |
|
188 | 188 | def touched(self): |
|
189 | 189 | """files either actively modified, added or removed""" |
|
190 | 190 | return frozenset(self._touched) |
|
191 | 191 | |
|
192 | 192 | def mark_touched(self, filename): |
|
193 | 193 | if 'touched' in vars(self): |
|
194 | 194 | del self.touched |
|
195 | 195 | self._touched.add(filename) |
|
196 | 196 | |
|
197 | 197 | def update_touched(self, filenames): |
|
198 | 198 | for f in filenames: |
|
199 | 199 | self.mark_touched(f) |
|
200 | 200 | |
|
201 | 201 | @util.propertycache |
|
202 | 202 | def copied_from_p1(self): |
|
203 | 203 | return self._p1_copies.copy() |
|
204 | 204 | |
|
205 | 205 | def mark_copied_from_p1(self, source, dest): |
|
206 | 206 | if 'copied_from_p1' in vars(self): |
|
207 | 207 | del self.copied_from_p1 |
|
208 | 208 | self._p1_copies[dest] = source |
|
209 | 209 | |
|
210 | 210 | def update_copies_from_p1(self, copies): |
|
211 | 211 | for dest, source in copies.items(): |
|
212 | 212 | self.mark_copied_from_p1(source, dest) |
|
213 | 213 | |
|
214 | 214 | @util.propertycache |
|
215 | 215 | def copied_from_p2(self): |
|
216 | 216 | return self._p2_copies.copy() |
|
217 | 217 | |
|
218 | 218 | def mark_copied_from_p2(self, source, dest): |
|
219 | 219 | if 'copied_from_p2' in vars(self): |
|
220 | 220 | del self.copied_from_p2 |
|
221 | 221 | self._p2_copies[dest] = source |
|
222 | 222 | |
|
223 | 223 | def update_copies_from_p2(self, copies): |
|
224 | 224 | for dest, source in copies.items(): |
|
225 | 225 | self.mark_copied_from_p2(source, dest) |
|
226 | 226 | |
|
227 | 227 | |
|
228 | 228 | def compute_all_files_changes(ctx): |
|
229 | 229 | """compute the files changed by a revision""" |
|
230 | 230 | p1 = ctx.p1() |
|
231 | 231 | p2 = ctx.p2() |
|
232 | 232 | if p1.rev() == node.nullrev and p2.rev() == node.nullrev: |
|
233 | 233 | return _process_root(ctx) |
|
234 | 234 | elif p1.rev() != node.nullrev and p2.rev() == node.nullrev: |
|
235 | 235 | return _process_linear(p1, ctx) |
|
236 | 236 | elif p1.rev() == node.nullrev and p2.rev() != node.nullrev: |
|
237 | 237 | # In the wild, one can encounter changeset where p1 is null but p2 is not |
|
238 | 238 | return _process_linear(p1, ctx, parent=2) |
|
239 | 239 | elif p1.rev() == p2.rev(): |
|
240 | 240 | # In the wild, one can encounter such "non-merge" |
|
241 | 241 | return _process_linear(p1, ctx) |
|
242 | 242 | else: |
|
243 | 243 | return _process_merge(p1, p2, ctx) |
|
244 | 244 | |
|
245 | 245 | |
|
246 | 246 | def _process_root(ctx): |
|
247 | 247 | """compute the appropriate changed files for a changeset with no parents |
|
248 | 248 | """ |
|
249 | 249 | # Simple, there was nothing before it, so everything is added. |
|
250 | 250 | md = ChangingFiles() |
|
251 | 251 | manifest = ctx.manifest() |
|
252 | 252 | for filename in manifest: |
|
253 | 253 | md.mark_added(filename) |
|
254 | 254 | return md |
|
255 | 255 | |
|
256 | 256 | |
|
257 | 257 | def _process_linear(parent_ctx, children_ctx, parent=1): |
|
258 | 258 | """compute the appropriate changed files for a changeset with a single parent |
|
259 | 259 | """ |
|
260 | 260 | md = ChangingFiles() |
|
261 | 261 | parent_manifest = parent_ctx.manifest() |
|
262 | 262 | children_manifest = children_ctx.manifest() |
|
263 | 263 | |
|
264 | 264 | copies_candidate = [] |
|
265 | 265 | |
|
266 | 266 | for filename, d in parent_manifest.diff(children_manifest).items(): |
|
267 | 267 | if d[1][0] is None: |
|
268 | 268 | # no filenode for the "new" value, file is absent |
|
269 | 269 | md.mark_removed(filename) |
|
270 | 270 | else: |
|
271 | 271 | copies_candidate.append(filename) |
|
272 | 272 | if d[0][0] is None: |
|
273 | 273 | # not filenode for the "old" value file was absent |
|
274 | 274 | md.mark_added(filename) |
|
275 | 275 | else: |
|
276 | 276 | # filenode for both "old" and "new" |
|
277 | 277 | md.mark_touched(filename) |
|
278 | 278 | |
|
279 | 279 | if parent == 1: |
|
280 | 280 | copied = md.mark_copied_from_p1 |
|
281 | 281 | elif parent == 2: |
|
282 | 282 | copied = md.mark_copied_from_p2 |
|
283 | 283 | else: |
|
284 | 284 | assert False, "bad parent value %d" % parent |
|
285 | 285 | |
|
286 | 286 | for filename in copies_candidate: |
|
287 | 287 | copy_info = children_ctx[filename].renamed() |
|
288 | 288 | if copy_info: |
|
289 | 289 | source, srcnode = copy_info |
|
290 | 290 | copied(source, filename) |
|
291 | 291 | |
|
292 | 292 | return md |
|
293 | 293 | |
|
294 | 294 | |
|
295 | 295 | def _process_merge(p1_ctx, p2_ctx, ctx): |
|
296 | 296 | """compute the appropriate changed files for a changeset with two parents |
|
297 | 297 | |
|
298 | 298 | This is a more advance case. The information we need to record is summarise |
|
299 | 299 | in the following table: |
|
300 | 300 | |
|
301 | 301 | ββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ |
|
302 | 302 | β diff β² diff β ΓΈ β (Some, None) β (None, Some) β (Some, Some) β |
|
303 | 303 | β p2 β² p1 β β β β β |
|
304 | 304 | ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€ |
|
305 | 305 | β β βπ± No Changes βπ³ No Changes β β |
|
306 | 306 | β ΓΈ βπ° No Changes β OR β OR βπ΅ No Changes β |
|
307 | 307 | β β βπ² Deleted[1] βπ΄ Salvaged[2]β [3] β |
|
308 | 308 | ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€ |
|
309 | 309 | β βπΆ No Changes β β β β |
|
310 | 310 | β (Some, None) β OR βπ» Deleted β ΓΈ β ΓΈ β |
|
311 | 311 | β βπ· Deleted[1] β β β β |
|
312 | 312 | ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€ |
|
313 | 313 | β βπΈ No Changes β β β β |
|
314 | 314 | β (None, Some) β OR β ΓΈ βπΌ Added βπ½ Merged β |
|
315 | 315 | β βπΉ Salvaged[2]β β (copied?) β (copied?) β |
|
316 | 316 | ββββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββ€ |
|
317 | 317 | β β β β β β |
|
318 | 318 | β (Some, Some) βπΊ No Changes β ΓΈ βπΎ Merged βπΏ Merged β |
|
319 | 319 | β β [3] β β (copied?) β (copied?) β |
|
320 | 320 | ββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ |
|
321 | 321 | |
|
322 | 322 | Special case [1]: |
|
323 | 323 | |
|
324 | 324 | The situation is: |
|
325 | 325 | - parent-A: file exists, |
|
326 | 326 | - parent-B: no file, |
|
327 | 327 | - working-copy: no file. |
|
328 | 328 | |
|
329 | 329 | Detecting a "deletion" will depend on the presence of actual change on |
|
330 | 330 | the "parent-A" branch: |
|
331 | 331 | |
|
332 | 332 | Subcase π± or πΆ : if the state of the file in "parent-A" is unchanged |
|
333 | 333 | compared to the merge ancestors, then parent-A branch left the file |
|
334 | 334 | untouched while parent-B deleted it. We simply apply the change from |
|
335 | 335 | "parent-B" branch the file was automatically dropped. |
|
336 | 336 | The result is: |
|
337 | 337 | - file is not recorded as touched by the merge. |
|
338 | 338 | |
|
339 | 339 | Subcase π² or π· : otherwise, the change from parent-A branch were explicitly dropped and |
|
340 | 340 | the file was "deleted again". From a user perspective, the message |
|
341 | 341 | about "locally changed" while "remotely deleted" (or the other way |
|
342 | 342 | around) was issued and the user chose to deleted the file. |
|
343 | 343 | The result: |
|
344 | 344 | - file is recorded as touched by the merge. |
|
345 | 345 | |
|
346 | 346 | |
|
347 | 347 | Special case [2]: |
|
348 | 348 | |
|
349 | 349 | The situation is: |
|
350 | 350 | - parent-A: no file, |
|
351 | 351 | - parent-B: file, |
|
352 | 352 | - working-copy: file (same content as parent-B). |
|
353 | 353 | |
|
354 | 354 | There are three subcases depending on the ancestors contents: |
|
355 | 355 | |
|
356 | 356 | - A) the file is missing in all ancestors, |
|
357 | 357 | - B) at least one ancestor has the file with filenode β from parent-B, |
|
358 | 358 | - C) all ancestors use the same filenode as parent-B, |
|
359 | 359 | |
|
360 | 360 | Subcase (A) is the simpler, nothing happend on parent-A side while |
|
361 | 361 | parent-B added it. |
|
362 | 362 | |
|
363 | 363 | The result: |
|
364 | 364 | - the file is not marked as touched by the merge. |
|
365 | 365 | |
|
366 | 366 | Subcase (B) is the counter part of "Special case [1]", the file was |
|
367 | 367 | modified on parent-B side, while parent-A side deleted it. However this |
|
368 | 368 | time, the conflict was solved by keeping the file (and its |
|
369 | 369 | modification). We consider the file as "salvaged". |
|
370 | 370 | |
|
371 | 371 | The result: |
|
372 | 372 | - the file is marked as "salvaged" by the merge. |
|
373 | 373 | |
|
374 | 374 | Subcase (C) is subtle variation of the case above. In this case, the |
|
375 | 375 | file in unchanged on the parent-B side and actively removed on the |
|
376 | 376 | parent-A side. So the merge machinery correctly decide it should be |
|
377 | 377 | removed. However, the file was explicitly restored to its parent-B |
|
378 | 378 | content before the merge was commited. The file is be marked |
|
379 | 379 | as salvaged too. From the merge result perspective, this is similar to |
|
380 | 380 | Subcase (B), however from the merge resolution perspective they differ |
|
381 | 381 | since in (C), there was some conflict not obvious solution to the |
|
382 | 382 | merge (That got reversed) |
|
383 | 383 | |
|
384 | 384 | Special case [3]: |
|
385 | 385 | |
|
386 | 386 | The situation is: |
|
387 | 387 | - parent-A: file, |
|
388 | 388 | - parent-B: file (different filenode as parent-A), |
|
389 | 389 | - working-copy: file (same filenode as parent-B). |
|
390 | 390 | |
|
391 | 391 | This case is in theory much simple, for this to happens, this mean the |
|
392 | 392 | filenode in parent-A is purely replacing the one in parent-B (either a |
|
393 | 393 | descendant, or a full new file history, see changeset). So the merge |
|
394 | 394 | introduce no changes, and the file is not affected by the merge... |
|
395 | 395 | |
|
396 | 396 | However, in the wild it is possible to find commit with the above is not |
|
397 | 397 | True. For example repository have some commit where the *new* node is an |
|
398 | 398 | ancestor of the node in parent-A, or where parent-A and parent-B are two |
|
399 | 399 | branches of the same file history, yet not merge-filenode were created |
|
400 | 400 | (while the "merge" should have led to a "modification"). |
|
401 | 401 | |
|
402 | 402 | Detecting such cases (and not recording the file as modified) would be a |
|
403 | 403 | nice bonus. However do not any of this yet. |
|
404 | 404 | """ |
|
405 | 405 | |
|
406 | 406 | md = ChangingFiles() |
|
407 | 407 | |
|
408 | 408 | m = ctx.manifest() |
|
409 | 409 | p1m = p1_ctx.manifest() |
|
410 | 410 | p2m = p2_ctx.manifest() |
|
411 | 411 | diff_p1 = p1m.diff(m) |
|
412 | 412 | diff_p2 = p2m.diff(m) |
|
413 | 413 | |
|
414 | 414 | cahs = ctx.repo().changelog.commonancestorsheads( |
|
415 | 415 | p1_ctx.node(), p2_ctx.node() |
|
416 | 416 | ) |
|
417 | 417 | if not cahs: |
|
418 | 418 | cahs = [node.nullrev] |
|
419 | 419 | mas = [ctx.repo()[r].manifest() for r in cahs] |
|
420 | 420 | |
|
421 | 421 | copy_candidates = [] |
|
422 | 422 | |
|
423 | 423 | # Dealing with case π° happens automatically. Since there are no entry in |
|
424 | 424 | # d1 nor d2, we won't iterate on it ever. |
|
425 | 425 | |
|
426 | 426 | # Iteration over d1 content will deal with all cases, but the one in the |
|
427 | 427 | # first column of the table. |
|
428 | 428 | for filename, d1 in diff_p1.items(): |
|
429 | 429 | |
|
430 | 430 | d2 = diff_p2.pop(filename, None) |
|
431 | 431 | |
|
432 | 432 | if d2 is None: |
|
433 | 433 | # this deal with the first line of the table. |
|
434 | 434 | _process_other_unchanged(md, mas, filename, d1) |
|
435 | 435 | else: |
|
436 | 436 | |
|
437 | 437 | if d1[0][0] is None and d2[0][0] is None: |
|
438 | 438 | # case πΌ β both deleted the file. |
|
439 | 439 | md.mark_added(filename) |
|
440 | 440 | copy_candidates.append(filename) |
|
441 | 441 | elif d1[1][0] is None and d2[1][0] is None: |
|
442 | 442 | # case π» β both deleted the file. |
|
443 | 443 | md.mark_removed(filename) |
|
444 | 444 | elif d1[1][0] is not None and d2[1][0] is not None: |
|
445 | 445 | # case π½ πΎ πΏ |
|
446 | 446 | md.mark_merged(filename) |
|
447 | 447 | copy_candidates.append(filename) |
|
448 | 448 | else: |
|
449 | 449 | # Impossible case, the post-merge file status cannot be None on |
|
450 | 450 | # one side and Something on the other side. |
|
451 | 451 | assert False, "unreachable" |
|
452 | 452 | |
|
453 | 453 | # Iteration over remaining d2 content deal with the first column of the |
|
454 | 454 | # table. |
|
455 | 455 | for filename, d2 in diff_p2.items(): |
|
456 | 456 | _process_other_unchanged(md, mas, filename, d2) |
|
457 | 457 | |
|
458 | 458 | for filename in copy_candidates: |
|
459 | 459 | copy_info = ctx[filename].renamed() |
|
460 | 460 | if copy_info: |
|
461 | 461 | source, srcnode = copy_info |
|
462 | 462 | if source in p1_ctx and p1_ctx[source].filenode() == srcnode: |
|
463 | 463 | md.mark_copied_from_p1(source, filename) |
|
464 | 464 | elif source in p2_ctx and p2_ctx[source].filenode() == srcnode: |
|
465 | 465 | md.mark_copied_from_p2(source, filename) |
|
466 | 466 | return md |
|
467 | 467 | |
|
468 | 468 | |
|
469 | 469 | def _find(manifest, filename): |
|
470 | 470 | """return the associate filenode or None""" |
|
471 | 471 | if filename not in manifest: |
|
472 | 472 | return None |
|
473 | 473 | return manifest.find(filename)[0] |
|
474 | 474 | |
|
475 | 475 | |
|
476 | 476 | def _process_other_unchanged(md, mas, filename, diff): |
|
477 | 477 | source_node = diff[0][0] |
|
478 | 478 | target_node = diff[1][0] |
|
479 | 479 | |
|
480 | 480 | if source_node is not None and target_node is None: |
|
481 | 481 | if any(not _find(ma, filename) == source_node for ma in mas): |
|
482 | 482 | # case π² of π· |
|
483 | 483 | md.mark_removed(filename) |
|
484 | 484 | # else, we have case π± or πΆ : no change need to be recorded |
|
485 | 485 | elif source_node is None and target_node is not None: |
|
486 | 486 | if any(_find(ma, filename) is not None for ma in mas): |
|
487 | 487 | # case π΄ or πΉ |
|
488 | 488 | md.mark_salvaged(filename) |
|
489 | 489 | # else, we have case π³ or πΈ : simple merge without intervention |
|
490 | 490 | elif source_node is not None and target_node is not None: |
|
491 | 491 | # case π΅ or πΊ : simple merge without intervention |
|
492 | 492 | # |
|
493 | 493 | # In buggy case where source_node is not an ancestors of target_node. |
|
494 | 494 | # There should have a been a new filenode created, recording this as |
|
495 | 495 | # "modified". We do not deal with them yet. |
|
496 | 496 | pass |
|
497 | 497 | else: |
|
498 | 498 | # An impossible case, the diff algorithm should not return entry if the |
|
499 | 499 | # file is missing on both side. |
|
500 | 500 | assert False, "unreachable" |
|
501 | 501 | |
|
502 | 502 | |
|
503 | 503 | def _missing_from_all_ancestors(mas, filename): |
|
504 | 504 | return all(_find(ma, filename) is None for ma in mas) |
|
505 | 505 | |
|
506 | 506 | |
|
507 | 507 | def computechangesetfilesadded(ctx): |
|
508 | 508 | """return the list of files added in a changeset |
|
509 | 509 | """ |
|
510 | 510 | added = [] |
|
511 | 511 | for f in ctx.files(): |
|
512 | 512 | if not any(f in p for p in ctx.parents()): |
|
513 | 513 | added.append(f) |
|
514 | 514 | return added |
|
515 | 515 | |
|
516 | 516 | |
|
517 | 517 | def get_removal_filter(ctx, x=None): |
|
518 | 518 | """return a function to detect files "wrongly" detected as `removed` |
|
519 | 519 | |
|
520 | 520 | When a file is removed relative to p1 in a merge, this |
|
521 | 521 | function determines whether the absence is due to a |
|
522 | 522 | deletion from a parent, or whether the merge commit |
|
523 | 523 | itself deletes the file. We decide this by doing a |
|
524 | 524 | simplified three way merge of the manifest entry for |
|
525 | 525 | the file. There are two ways we decide the merge |
|
526 | 526 | itself didn't delete a file: |
|
527 | 527 | - neither parent (nor the merge) contain the file |
|
528 | 528 | - exactly one parent contains the file, and that |
|
529 | 529 | parent has the same filelog entry as the merge |
|
530 | 530 | ancestor (or all of them if there two). In other |
|
531 | 531 | words, that parent left the file unchanged while the |
|
532 | 532 | other one deleted it. |
|
533 | 533 | One way to think about this is that deleting a file is |
|
534 | 534 | similar to emptying it, so the list of changed files |
|
535 | 535 | should be similar either way. The computation |
|
536 | 536 | described above is not done directly in _filecommit |
|
537 | 537 | when creating the list of changed files, however |
|
538 | 538 | it does something very similar by comparing filelog |
|
539 | 539 | nodes. |
|
540 | 540 | """ |
|
541 | 541 | |
|
542 | 542 | if x is not None: |
|
543 | 543 | p1, p2, m1, m2 = x |
|
544 | 544 | else: |
|
545 | 545 | p1 = ctx.p1() |
|
546 | 546 | p2 = ctx.p2() |
|
547 | 547 | m1 = p1.manifest() |
|
548 | 548 | m2 = p2.manifest() |
|
549 | 549 | |
|
550 | 550 | @util.cachefunc |
|
551 | 551 | def mas(): |
|
552 | 552 | p1n = p1.node() |
|
553 | 553 | p2n = p2.node() |
|
554 | 554 | cahs = ctx.repo().changelog.commonancestorsheads(p1n, p2n) |
|
555 | 555 | if not cahs: |
|
556 | 556 | cahs = [node.nullrev] |
|
557 | 557 | return [ctx.repo()[r].manifest() for r in cahs] |
|
558 | 558 | |
|
559 | 559 | def deletionfromparent(f): |
|
560 | 560 | if f in m1: |
|
561 | 561 | return f not in m2 and all( |
|
562 | 562 | f in ma and ma.find(f) == m1.find(f) for ma in mas() |
|
563 | 563 | ) |
|
564 | 564 | elif f in m2: |
|
565 | 565 | return all(f in ma and ma.find(f) == m2.find(f) for ma in mas()) |
|
566 | 566 | else: |
|
567 | 567 | return True |
|
568 | 568 | |
|
569 | 569 | return deletionfromparent |
|
570 | 570 | |
|
571 | 571 | |
|
572 | 572 | def computechangesetfilesremoved(ctx): |
|
573 | 573 | """return the list of files removed in a changeset |
|
574 | 574 | """ |
|
575 | 575 | removed = [] |
|
576 | 576 | for f in ctx.files(): |
|
577 | 577 | if f not in ctx: |
|
578 | 578 | removed.append(f) |
|
579 | 579 | if removed: |
|
580 | 580 | rf = get_removal_filter(ctx) |
|
581 | 581 | removed = [r for r in removed if not rf(r)] |
|
582 | 582 | return removed |
|
583 | 583 | |
|
584 | 584 | |
|
585 | 585 | def computechangesetfilesmerged(ctx): |
|
586 | 586 | """return the list of files merged in a changeset |
|
587 | 587 | """ |
|
588 | 588 | merged = [] |
|
589 | 589 | if len(ctx.parents()) < 2: |
|
590 | 590 | return merged |
|
591 | 591 | for f in ctx.files(): |
|
592 | 592 | if f in ctx: |
|
593 | 593 | fctx = ctx[f] |
|
594 | 594 | parents = fctx._filelog.parents(fctx._filenode) |
|
595 | 595 | if parents[1] != node.nullid: |
|
596 | 596 | merged.append(f) |
|
597 | 597 | return merged |
|
598 | 598 | |
|
599 | 599 | |
|
600 | 600 | def computechangesetcopies(ctx): |
|
601 | 601 | """return the copies data for a changeset |
|
602 | 602 | |
|
603 | 603 | The copies data are returned as a pair of dictionnary (p1copies, p2copies). |
|
604 | 604 | |
|
605 | 605 | Each dictionnary are in the form: `{newname: oldname}` |
|
606 | 606 | """ |
|
607 | 607 | p1copies = {} |
|
608 | 608 | p2copies = {} |
|
609 | 609 | p1 = ctx.p1() |
|
610 | 610 | p2 = ctx.p2() |
|
611 | 611 | narrowmatch = ctx._repo.narrowmatch() |
|
612 | 612 | for dst in ctx.files(): |
|
613 | 613 | if not narrowmatch(dst) or dst not in ctx: |
|
614 | 614 | continue |
|
615 | 615 | copied = ctx[dst].renamed() |
|
616 | 616 | if not copied: |
|
617 | 617 | continue |
|
618 | 618 | src, srcnode = copied |
|
619 | 619 | if src in p1 and p1[src].filenode() == srcnode: |
|
620 | 620 | p1copies[dst] = src |
|
621 | 621 | elif src in p2 and p2[src].filenode() == srcnode: |
|
622 | 622 | p2copies[dst] = src |
|
623 | 623 | return p1copies, p2copies |
|
624 | 624 | |
|
625 | 625 | |
|
626 | 626 | def encodecopies(files, copies): |
|
627 | 627 | items = [] |
|
628 | 628 | for i, dst in enumerate(files): |
|
629 | 629 | if dst in copies: |
|
630 | 630 | items.append(b'%d\0%s' % (i, copies[dst])) |
|
631 | 631 | if len(items) != len(copies): |
|
632 | 632 | raise error.ProgrammingError( |
|
633 | 633 | b'some copy targets missing from file list' |
|
634 | 634 | ) |
|
635 | 635 | return b"\n".join(items) |
|
636 | 636 | |
|
637 | 637 | |
|
638 | 638 | def decodecopies(files, data): |
|
639 | 639 | try: |
|
640 | 640 | copies = {} |
|
641 | 641 | if not data: |
|
642 | 642 | return copies |
|
643 | 643 | for l in data.split(b'\n'): |
|
644 | 644 | strindex, src = l.split(b'\0') |
|
645 | 645 | i = int(strindex) |
|
646 | 646 | dst = files[i] |
|
647 | 647 | copies[dst] = src |
|
648 | 648 | return copies |
|
649 | 649 | except (ValueError, IndexError): |
|
650 | 650 | # Perhaps someone had chosen the same key name (e.g. "p1copies") and |
|
651 | 651 | # used different syntax for the value. |
|
652 | 652 | return None |
|
653 | 653 | |
|
654 | 654 | |
|
655 | 655 | def encodefileindices(files, subset): |
|
656 | 656 | subset = set(subset) |
|
657 | 657 | indices = [] |
|
658 | 658 | for i, f in enumerate(files): |
|
659 | 659 | if f in subset: |
|
660 | 660 | indices.append(b'%d' % i) |
|
661 | 661 | return b'\n'.join(indices) |
|
662 | 662 | |
|
663 | 663 | |
|
664 | 664 | def decodefileindices(files, data): |
|
665 | 665 | try: |
|
666 | 666 | subset = [] |
|
667 | 667 | if not data: |
|
668 | 668 | return subset |
|
669 | 669 | for strindex in data.split(b'\n'): |
|
670 | 670 | i = int(strindex) |
|
671 | 671 | if i < 0 or i >= len(files): |
|
672 | 672 | return None |
|
673 | 673 | subset.append(files[i]) |
|
674 | 674 | return subset |
|
675 | 675 | except (ValueError, IndexError): |
|
676 | 676 | # Perhaps someone had chosen the same key name (e.g. "added") and |
|
677 | 677 | # used different syntax for the value. |
|
678 | 678 | return None |
|
679 | 679 | |
|
680 | 680 | |
|
681 | 681 | # see mercurial/helptext/internals/revlogs.txt for details about the format |
|
682 | 682 | |
|
683 | 683 | ACTION_MASK = int("111" "00", 2) |
|
684 | 684 | # note: untouched file used as copy source will as `000` for this mask. |
|
685 | 685 | ADDED_FLAG = int("001" "00", 2) |
|
686 | 686 | MERGED_FLAG = int("010" "00", 2) |
|
687 | 687 | REMOVED_FLAG = int("011" "00", 2) |
|
688 | # `100` is reserved for future use | |
|
688 | SALVAGED_FLAG = int("100" "00", 2) | |
|
689 | 689 | TOUCHED_FLAG = int("101" "00", 2) |
|
690 | 690 | |
|
691 | 691 | COPIED_MASK = int("11", 2) |
|
692 | 692 | COPIED_FROM_P1_FLAG = int("10", 2) |
|
693 | 693 | COPIED_FROM_P2_FLAG = int("11", 2) |
|
694 | 694 | |
|
695 | 695 | # structure is <flag><filename-end><copy-source> |
|
696 | 696 | INDEX_HEADER = struct.Struct(">L") |
|
697 | 697 | INDEX_ENTRY = struct.Struct(">bLL") |
|
698 | 698 | |
|
699 | 699 | |
|
700 | 700 | def encode_files_sidedata(files): |
|
701 |
all_files = set(files.touched |
|
|
701 | all_files = set(files.touched) | |
|
702 | 702 | all_files.update(files.copied_from_p1.values()) |
|
703 | 703 | all_files.update(files.copied_from_p2.values()) |
|
704 | 704 | all_files = sorted(all_files) |
|
705 | 705 | file_idx = {f: i for (i, f) in enumerate(all_files)} |
|
706 | 706 | file_idx[None] = 0 |
|
707 | 707 | |
|
708 | 708 | chunks = [INDEX_HEADER.pack(len(all_files))] |
|
709 | 709 | |
|
710 | 710 | filename_length = 0 |
|
711 | 711 | for f in all_files: |
|
712 | 712 | filename_size = len(f) |
|
713 | 713 | filename_length += filename_size |
|
714 | 714 | flag = 0 |
|
715 | 715 | if f in files.added: |
|
716 | 716 | flag |= ADDED_FLAG |
|
717 | 717 | elif f in files.merged: |
|
718 | 718 | flag |= MERGED_FLAG |
|
719 | 719 | elif f in files.removed: |
|
720 | 720 | flag |= REMOVED_FLAG |
|
721 | elif f in files.salvaged: | |
|
722 | flag |= SALVAGED_FLAG | |
|
721 | 723 | elif f in files.touched: |
|
722 | 724 | flag |= TOUCHED_FLAG |
|
723 | 725 | |
|
724 | 726 | copy = None |
|
725 | 727 | if f in files.copied_from_p1: |
|
726 | 728 | flag |= COPIED_FROM_P1_FLAG |
|
727 | 729 | copy = files.copied_from_p1.get(f) |
|
728 | 730 | elif f in files.copied_from_p2: |
|
729 | 731 | copy = files.copied_from_p2.get(f) |
|
730 | 732 | flag |= COPIED_FROM_P2_FLAG |
|
731 | 733 | copy_idx = file_idx[copy] |
|
732 | 734 | chunks.append(INDEX_ENTRY.pack(flag, filename_length, copy_idx)) |
|
733 | 735 | chunks.extend(all_files) |
|
734 | 736 | return {sidedatamod.SD_FILES: b''.join(chunks)} |
|
735 | 737 | |
|
736 | 738 | |
|
737 | 739 | def decode_files_sidedata(sidedata): |
|
738 | 740 | md = ChangingFiles() |
|
739 | 741 | raw = sidedata.get(sidedatamod.SD_FILES) |
|
740 | 742 | |
|
741 | 743 | if raw is None: |
|
742 | 744 | return md |
|
743 | 745 | |
|
744 | 746 | copies = [] |
|
745 | 747 | all_files = [] |
|
746 | 748 | |
|
747 | 749 | assert len(raw) >= INDEX_HEADER.size |
|
748 | 750 | total_files = INDEX_HEADER.unpack_from(raw, 0)[0] |
|
749 | 751 | |
|
750 | 752 | offset = INDEX_HEADER.size |
|
751 | 753 | file_offset_base = offset + (INDEX_ENTRY.size * total_files) |
|
752 | 754 | file_offset_last = file_offset_base |
|
753 | 755 | |
|
754 | 756 | assert len(raw) >= file_offset_base |
|
755 | 757 | |
|
756 | 758 | for idx in range(total_files): |
|
757 | 759 | flag, file_end, copy_idx = INDEX_ENTRY.unpack_from(raw, offset) |
|
758 | 760 | file_end += file_offset_base |
|
759 | 761 | filename = raw[file_offset_last:file_end] |
|
760 | 762 | filesize = file_end - file_offset_last |
|
761 | 763 | assert len(filename) == filesize |
|
762 | 764 | offset += INDEX_ENTRY.size |
|
763 | 765 | file_offset_last = file_end |
|
764 | 766 | all_files.append(filename) |
|
765 | 767 | if flag & ACTION_MASK == ADDED_FLAG: |
|
766 | 768 | md.mark_added(filename) |
|
767 | 769 | elif flag & ACTION_MASK == MERGED_FLAG: |
|
768 | 770 | md.mark_merged(filename) |
|
769 | 771 | elif flag & ACTION_MASK == REMOVED_FLAG: |
|
770 | 772 | md.mark_removed(filename) |
|
773 | elif flag & ACTION_MASK == SALVAGED_FLAG: | |
|
774 | md.mark_salvaged(filename) | |
|
771 | 775 | elif flag & ACTION_MASK == TOUCHED_FLAG: |
|
772 | 776 | md.mark_touched(filename) |
|
773 | 777 | |
|
774 | 778 | copied = None |
|
775 | 779 | if flag & COPIED_MASK == COPIED_FROM_P1_FLAG: |
|
776 | 780 | copied = md.mark_copied_from_p1 |
|
777 | 781 | elif flag & COPIED_MASK == COPIED_FROM_P2_FLAG: |
|
778 | 782 | copied = md.mark_copied_from_p2 |
|
779 | 783 | |
|
780 | 784 | if copied is not None: |
|
781 | 785 | copies.append((copied, filename, copy_idx)) |
|
782 | 786 | |
|
783 | 787 | for copied, filename, copy_idx in copies: |
|
784 | 788 | copied(all_files[copy_idx], filename) |
|
785 | 789 | |
|
786 | 790 | return md |
|
787 | 791 | |
|
788 | 792 | |
|
789 | 793 | def _getsidedata(srcrepo, rev): |
|
790 | 794 | ctx = srcrepo[rev] |
|
791 | 795 | files = compute_all_files_changes(ctx) |
|
792 | 796 | return encode_files_sidedata(files) |
|
793 | 797 | |
|
794 | 798 | |
|
795 | 799 | def getsidedataadder(srcrepo, destrepo): |
|
796 | 800 | use_w = srcrepo.ui.configbool(b'experimental', b'worker.repository-upgrade') |
|
797 | 801 | if pycompat.iswindows or not use_w: |
|
798 | 802 | return _get_simple_sidedata_adder(srcrepo, destrepo) |
|
799 | 803 | else: |
|
800 | 804 | return _get_worker_sidedata_adder(srcrepo, destrepo) |
|
801 | 805 | |
|
802 | 806 | |
|
803 | 807 | def _sidedata_worker(srcrepo, revs_queue, sidedata_queue, tokens): |
|
804 | 808 | """The function used by worker precomputing sidedata |
|
805 | 809 | |
|
806 | 810 | It read an input queue containing revision numbers |
|
807 | 811 | It write in an output queue containing (rev, <sidedata-map>) |
|
808 | 812 | |
|
809 | 813 | The `None` input value is used as a stop signal. |
|
810 | 814 | |
|
811 | 815 | The `tokens` semaphore is user to avoid having too many unprocessed |
|
812 | 816 | entries. The workers needs to acquire one token before fetching a task. |
|
813 | 817 | They will be released by the consumer of the produced data. |
|
814 | 818 | """ |
|
815 | 819 | tokens.acquire() |
|
816 | 820 | rev = revs_queue.get() |
|
817 | 821 | while rev is not None: |
|
818 | 822 | data = _getsidedata(srcrepo, rev) |
|
819 | 823 | sidedata_queue.put((rev, data)) |
|
820 | 824 | tokens.acquire() |
|
821 | 825 | rev = revs_queue.get() |
|
822 | 826 | # processing of `None` is completed, release the token. |
|
823 | 827 | tokens.release() |
|
824 | 828 | |
|
825 | 829 | |
|
826 | 830 | BUFF_PER_WORKER = 50 |
|
827 | 831 | |
|
828 | 832 | |
|
829 | 833 | def _get_worker_sidedata_adder(srcrepo, destrepo): |
|
830 | 834 | """The parallel version of the sidedata computation |
|
831 | 835 | |
|
832 | 836 | This code spawn a pool of worker that precompute a buffer of sidedata |
|
833 | 837 | before we actually need them""" |
|
834 | 838 | # avoid circular import copies -> scmutil -> worker -> copies |
|
835 | 839 | from . import worker |
|
836 | 840 | |
|
837 | 841 | nbworkers = worker._numworkers(srcrepo.ui) |
|
838 | 842 | |
|
839 | 843 | tokens = multiprocessing.BoundedSemaphore(nbworkers * BUFF_PER_WORKER) |
|
840 | 844 | revsq = multiprocessing.Queue() |
|
841 | 845 | sidedataq = multiprocessing.Queue() |
|
842 | 846 | |
|
843 | 847 | assert srcrepo.filtername is None |
|
844 | 848 | # queue all tasks beforehand, revision numbers are small and it make |
|
845 | 849 | # synchronisation simpler |
|
846 | 850 | # |
|
847 | 851 | # Since the computation for each node can be quite expensive, the overhead |
|
848 | 852 | # of using a single queue is not revelant. In practice, most computation |
|
849 | 853 | # are fast but some are very expensive and dominate all the other smaller |
|
850 | 854 | # cost. |
|
851 | 855 | for r in srcrepo.changelog.revs(): |
|
852 | 856 | revsq.put(r) |
|
853 | 857 | # queue the "no more tasks" markers |
|
854 | 858 | for i in range(nbworkers): |
|
855 | 859 | revsq.put(None) |
|
856 | 860 | |
|
857 | 861 | allworkers = [] |
|
858 | 862 | for i in range(nbworkers): |
|
859 | 863 | args = (srcrepo, revsq, sidedataq, tokens) |
|
860 | 864 | w = multiprocessing.Process(target=_sidedata_worker, args=args) |
|
861 | 865 | allworkers.append(w) |
|
862 | 866 | w.start() |
|
863 | 867 | |
|
864 | 868 | # dictionnary to store results for revision higher than we one we are |
|
865 | 869 | # looking for. For example, if we need the sidedatamap for 42, and 43 is |
|
866 | 870 | # received, when shelve 43 for later use. |
|
867 | 871 | staging = {} |
|
868 | 872 | |
|
869 | 873 | def sidedata_companion(revlog, rev): |
|
870 | 874 | sidedata = {} |
|
871 | 875 | if util.safehasattr(revlog, b'filteredrevs'): # this is a changelog |
|
872 | 876 | # Is the data previously shelved ? |
|
873 | 877 | sidedata = staging.pop(rev, None) |
|
874 | 878 | if sidedata is None: |
|
875 | 879 | # look at the queued result until we find the one we are lookig |
|
876 | 880 | # for (shelve the other ones) |
|
877 | 881 | r, sidedata = sidedataq.get() |
|
878 | 882 | while r != rev: |
|
879 | 883 | staging[r] = sidedata |
|
880 | 884 | r, sidedata = sidedataq.get() |
|
881 | 885 | tokens.release() |
|
882 | 886 | return False, (), sidedata |
|
883 | 887 | |
|
884 | 888 | return sidedata_companion |
|
885 | 889 | |
|
886 | 890 | |
|
887 | 891 | def _get_simple_sidedata_adder(srcrepo, destrepo): |
|
888 | 892 | """The simple version of the sidedata computation |
|
889 | 893 | |
|
890 | 894 | It just compute it in the same thread on request""" |
|
891 | 895 | |
|
892 | 896 | def sidedatacompanion(revlog, rev): |
|
893 | 897 | sidedata = {} |
|
894 | 898 | if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
|
895 | 899 | sidedata = _getsidedata(srcrepo, rev) |
|
896 | 900 | return False, (), sidedata |
|
897 | 901 | |
|
898 | 902 | return sidedatacompanion |
|
899 | 903 | |
|
900 | 904 | |
|
901 | 905 | def getsidedataremover(srcrepo, destrepo): |
|
902 | 906 | def sidedatacompanion(revlog, rev): |
|
903 | 907 | f = () |
|
904 | 908 | if util.safehasattr(revlog, 'filteredrevs'): # this is a changelog |
|
905 | 909 | if revlog.flags(rev) & sidedataflag.REVIDX_SIDEDATA: |
|
906 | 910 | f = ( |
|
907 | 911 | sidedatamod.SD_P1COPIES, |
|
908 | 912 | sidedatamod.SD_P2COPIES, |
|
909 | 913 | sidedatamod.SD_FILESADDED, |
|
910 | 914 | sidedatamod.SD_FILESREMOVED, |
|
911 | 915 | ) |
|
912 | 916 | return False, f, {} |
|
913 | 917 | |
|
914 | 918 | return sidedatacompanion |
@@ -1,1192 +1,1196 b'' | |||
|
1 | 1 | #testcases filelog compatibility sidedata |
|
2 | 2 | |
|
3 | 3 | ===================================================== |
|
4 | 4 | Test Copy tracing for chain of copies involving merge |
|
5 | 5 | ===================================================== |
|
6 | 6 | |
|
7 | 7 | This test files covers copies/rename case for a chains of commit where merges |
|
8 | 8 | are involved. It cheks we do not have unwanted update of behavior and that the |
|
9 | 9 | different options to retrieve copies behave correctly. |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | Setup |
|
13 | 13 | ===== |
|
14 | 14 | |
|
15 | 15 | use git diff to see rename |
|
16 | 16 | |
|
17 | 17 | $ cat << EOF >> $HGRCPATH |
|
18 | 18 | > [diff] |
|
19 | 19 | > git=yes |
|
20 | 20 | > [ui] |
|
21 | 21 | > logtemplate={rev} {desc}\n |
|
22 | 22 | > EOF |
|
23 | 23 | |
|
24 | 24 | #if compatibility |
|
25 | 25 | $ cat >> $HGRCPATH << EOF |
|
26 | 26 | > [experimental] |
|
27 | 27 | > copies.read-from = compatibility |
|
28 | 28 | > EOF |
|
29 | 29 | #endif |
|
30 | 30 | |
|
31 | 31 | #if sidedata |
|
32 | 32 | $ cat >> $HGRCPATH << EOF |
|
33 | 33 | > [format] |
|
34 | 34 | > exp-use-side-data = yes |
|
35 | 35 | > exp-use-copies-side-data-changeset = yes |
|
36 | 36 | > EOF |
|
37 | 37 | #endif |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | $ hg init repo-chain |
|
41 | 41 | $ cd repo-chain |
|
42 | 42 | |
|
43 | 43 | Add some linear rename initialy |
|
44 | 44 | |
|
45 | 45 | $ touch a b h |
|
46 | 46 | $ hg ci -Am 'i-0 initial commit: a b h' |
|
47 | 47 | adding a |
|
48 | 48 | adding b |
|
49 | 49 | adding h |
|
50 | 50 | $ hg mv a c |
|
51 | 51 | $ hg ci -Am 'i-1: a -move-> c' |
|
52 | 52 | $ hg mv c d |
|
53 | 53 | $ hg ci -Am 'i-2: c -move-> d' |
|
54 | 54 | $ hg log -G |
|
55 | 55 | @ 2 i-2: c -move-> d |
|
56 | 56 | | |
|
57 | 57 | o 1 i-1: a -move-> c |
|
58 | 58 | | |
|
59 | 59 | o 0 i-0 initial commit: a b h |
|
60 | 60 | |
|
61 | 61 | |
|
62 | 62 | And having another branch with renames on the other side |
|
63 | 63 | |
|
64 | 64 | $ hg mv d e |
|
65 | 65 | $ hg ci -Am 'a-1: d -move-> e' |
|
66 | 66 | $ hg mv e f |
|
67 | 67 | $ hg ci -Am 'a-2: e -move-> f' |
|
68 | 68 | $ hg log -G --rev '::.' |
|
69 | 69 | @ 4 a-2: e -move-> f |
|
70 | 70 | | |
|
71 | 71 | o 3 a-1: d -move-> e |
|
72 | 72 | | |
|
73 | 73 | o 2 i-2: c -move-> d |
|
74 | 74 | | |
|
75 | 75 | o 1 i-1: a -move-> c |
|
76 | 76 | | |
|
77 | 77 | o 0 i-0 initial commit: a b h |
|
78 | 78 | |
|
79 | 79 | |
|
80 | 80 | Have a branching with nothing on one side |
|
81 | 81 | |
|
82 | 82 | $ hg up 'desc("i-2")' |
|
83 | 83 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
84 | 84 | $ echo foo > b |
|
85 | 85 | $ hg ci -m 'b-1: b update' |
|
86 | 86 | created new head |
|
87 | 87 | $ hg log -G --rev '::.' |
|
88 | 88 | @ 5 b-1: b update |
|
89 | 89 | | |
|
90 | 90 | o 2 i-2: c -move-> d |
|
91 | 91 | | |
|
92 | 92 | o 1 i-1: a -move-> c |
|
93 | 93 | | |
|
94 | 94 | o 0 i-0 initial commit: a b h |
|
95 | 95 | |
|
96 | 96 | |
|
97 | 97 | Create a branch that delete a file previous renamed |
|
98 | 98 | |
|
99 | 99 | $ hg up 'desc("i-2")' |
|
100 | 100 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
101 | 101 | $ hg rm d |
|
102 | 102 | $ hg ci -m 'c-1 delete d' |
|
103 | 103 | created new head |
|
104 | 104 | $ hg log -G --rev '::.' |
|
105 | 105 | @ 6 c-1 delete d |
|
106 | 106 | | |
|
107 | 107 | o 2 i-2: c -move-> d |
|
108 | 108 | | |
|
109 | 109 | o 1 i-1: a -move-> c |
|
110 | 110 | | |
|
111 | 111 | o 0 i-0 initial commit: a b h |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | Create a branch that delete a file previous renamed and recreate it |
|
115 | 115 | |
|
116 | 116 | $ hg up 'desc("i-2")' |
|
117 | 117 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
118 | 118 | $ hg rm d |
|
119 | 119 | $ hg ci -m 'd-1 delete d' |
|
120 | 120 | created new head |
|
121 | 121 | $ echo bar > d |
|
122 | 122 | $ hg add d |
|
123 | 123 | $ hg ci -m 'd-2 re-add d' |
|
124 | 124 | $ hg log -G --rev '::.' |
|
125 | 125 | @ 8 d-2 re-add d |
|
126 | 126 | | |
|
127 | 127 | o 7 d-1 delete d |
|
128 | 128 | | |
|
129 | 129 | o 2 i-2: c -move-> d |
|
130 | 130 | | |
|
131 | 131 | o 1 i-1: a -move-> c |
|
132 | 132 | | |
|
133 | 133 | o 0 i-0 initial commit: a b h |
|
134 | 134 | |
|
135 | 135 | |
|
136 | 136 | Having another branch renaming a different file to the same filename as another |
|
137 | 137 | |
|
138 | 138 | $ hg up 'desc("i-2")' |
|
139 | 139 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
140 | 140 | $ hg mv b g |
|
141 | 141 | $ hg ci -m 'e-1 b -move-> g' |
|
142 | 142 | created new head |
|
143 | 143 | $ hg mv g f |
|
144 | 144 | $ hg ci -m 'e-2 g -move-> f' |
|
145 | 145 | $ hg log -G --rev '::.' |
|
146 | 146 | @ 10 e-2 g -move-> f |
|
147 | 147 | | |
|
148 | 148 | o 9 e-1 b -move-> g |
|
149 | 149 | | |
|
150 | 150 | o 2 i-2: c -move-> d |
|
151 | 151 | | |
|
152 | 152 | o 1 i-1: a -move-> c |
|
153 | 153 | | |
|
154 | 154 | o 0 i-0 initial commit: a b h |
|
155 | 155 | |
|
156 | 156 | |
|
157 | 157 | merging with unrelated change does not interfere with the renames |
|
158 | 158 | --------------------------------------------------------------- |
|
159 | 159 | |
|
160 | 160 | - rename on one side |
|
161 | 161 | - unrelated change on the other side |
|
162 | 162 | |
|
163 | 163 | $ hg up 'desc("b-1")' |
|
164 | 164 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
165 | 165 | $ hg merge 'desc("a-2")' |
|
166 | 166 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
167 | 167 | (branch merge, don't forget to commit) |
|
168 | 168 | $ hg ci -m 'mBAm-0 simple merge - one way' |
|
169 | 169 | $ hg up 'desc("a-2")' |
|
170 | 170 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
171 | 171 | $ hg merge 'desc("b-1")' |
|
172 | 172 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
173 | 173 | (branch merge, don't forget to commit) |
|
174 | 174 | $ hg ci -m 'mABm-0 simple merge - the other way' |
|
175 | 175 | created new head |
|
176 | 176 | $ hg log -G --rev '::(desc("mABm")+desc("mBAm"))' |
|
177 | 177 | @ 12 mABm-0 simple merge - the other way |
|
178 | 178 | |\ |
|
179 | 179 | +---o 11 mBAm-0 simple merge - one way |
|
180 | 180 | | |/ |
|
181 | 181 | | o 5 b-1: b update |
|
182 | 182 | | | |
|
183 | 183 | o | 4 a-2: e -move-> f |
|
184 | 184 | | | |
|
185 | 185 | o | 3 a-1: d -move-> e |
|
186 | 186 | |/ |
|
187 | 187 | o 2 i-2: c -move-> d |
|
188 | 188 | | |
|
189 | 189 | o 1 i-1: a -move-> c |
|
190 | 190 | | |
|
191 | 191 | o 0 i-0 initial commit: a b h |
|
192 | 192 | |
|
193 | 193 | |
|
194 | 194 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mABm")' |
|
195 | 195 | A f |
|
196 | 196 | d |
|
197 | 197 | R d |
|
198 | 198 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBAm")' |
|
199 | 199 | A f |
|
200 | 200 | d |
|
201 | 201 | R d |
|
202 | 202 | $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mABm")' |
|
203 | 203 | M b |
|
204 | 204 | $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mBAm")' |
|
205 | 205 | M b |
|
206 | 206 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mABm")' |
|
207 | 207 | M b |
|
208 | 208 | A f |
|
209 | 209 | d |
|
210 | 210 | R d |
|
211 | 211 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBAm")' |
|
212 | 212 | M b |
|
213 | 213 | A f |
|
214 | 214 | d |
|
215 | 215 | R d |
|
216 | 216 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mABm")' |
|
217 | 217 | M b |
|
218 | 218 | A f |
|
219 | 219 | a |
|
220 | 220 | R a |
|
221 | 221 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBAm")' |
|
222 | 222 | M b |
|
223 | 223 | A f |
|
224 | 224 | a |
|
225 | 225 | R a |
|
226 | 226 | |
|
227 | 227 | merging with the side having a delete |
|
228 | 228 | ------------------------------------- |
|
229 | 229 | |
|
230 | 230 | case summary: |
|
231 | 231 | - one with change to an unrelated file |
|
232 | 232 | - one deleting the change |
|
233 | 233 | and recreate an unrelated file after the merge |
|
234 | 234 | |
|
235 | 235 | $ hg up 'desc("b-1")' |
|
236 | 236 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
237 | 237 | $ hg merge 'desc("c-1")' |
|
238 | 238 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
239 | 239 | (branch merge, don't forget to commit) |
|
240 | 240 | $ hg ci -m 'mBCm-0 simple merge - one way' |
|
241 | 241 | $ echo bar > d |
|
242 | 242 | $ hg add d |
|
243 | 243 | $ hg ci -m 'mBCm-1 re-add d' |
|
244 | 244 | $ hg up 'desc("c-1")' |
|
245 | 245 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
246 | 246 | $ hg merge 'desc("b-1")' |
|
247 | 247 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
248 | 248 | (branch merge, don't forget to commit) |
|
249 | 249 | $ hg ci -m 'mCBm-0 simple merge - the other way' |
|
250 | 250 | created new head |
|
251 | 251 | $ echo bar > d |
|
252 | 252 | $ hg add d |
|
253 | 253 | $ hg ci -m 'mCBm-1 re-add d' |
|
254 | 254 | $ hg log -G --rev '::(desc("mCBm")+desc("mBCm"))' |
|
255 | 255 | @ 16 mCBm-1 re-add d |
|
256 | 256 | | |
|
257 | 257 | o 15 mCBm-0 simple merge - the other way |
|
258 | 258 | |\ |
|
259 | 259 | | | o 14 mBCm-1 re-add d |
|
260 | 260 | | | | |
|
261 | 261 | +---o 13 mBCm-0 simple merge - one way |
|
262 | 262 | | |/ |
|
263 | 263 | | o 6 c-1 delete d |
|
264 | 264 | | | |
|
265 | 265 | o | 5 b-1: b update |
|
266 | 266 | |/ |
|
267 | 267 | o 2 i-2: c -move-> d |
|
268 | 268 | | |
|
269 | 269 | o 1 i-1: a -move-> c |
|
270 | 270 | | |
|
271 | 271 | o 0 i-0 initial commit: a b h |
|
272 | 272 | |
|
273 | 273 | - comparing from the merge |
|
274 | 274 | |
|
275 | 275 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBCm-0")' |
|
276 | 276 | R d |
|
277 | 277 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCBm-0")' |
|
278 | 278 | R d |
|
279 | 279 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBCm-0")' |
|
280 | 280 | M b |
|
281 | 281 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCBm-0")' |
|
282 | 282 | M b |
|
283 | 283 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBCm-0")' |
|
284 | 284 | M b |
|
285 | 285 | R d |
|
286 | 286 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mCBm-0")' |
|
287 | 287 | M b |
|
288 | 288 | R d |
|
289 | 289 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBCm-0")' |
|
290 | 290 | M b |
|
291 | 291 | R a |
|
292 | 292 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCBm-0")' |
|
293 | 293 | M b |
|
294 | 294 | R a |
|
295 | 295 | |
|
296 | 296 | - comparing with the merge children re-adding the file |
|
297 | 297 | |
|
298 | 298 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBCm-1")' |
|
299 | 299 | M d |
|
300 | 300 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCBm-1")' |
|
301 | 301 | M d |
|
302 | 302 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBCm-1")' |
|
303 | 303 | M b |
|
304 | 304 | A d |
|
305 | 305 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCBm-1")' |
|
306 | 306 | M b |
|
307 | 307 | A d |
|
308 | 308 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBCm-1")' |
|
309 | 309 | M b |
|
310 | 310 | M d |
|
311 | 311 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mCBm-1")' |
|
312 | 312 | M b |
|
313 | 313 | M d |
|
314 | 314 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBCm-1")' |
|
315 | 315 | M b |
|
316 | 316 | A d |
|
317 | 317 | R a |
|
318 | 318 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCBm-1")' |
|
319 | 319 | M b |
|
320 | 320 | A d |
|
321 | 321 | R a |
|
322 | 322 | |
|
323 | 323 | Comparing with a merge re-adding the file afterward |
|
324 | 324 | --------------------------------------------------- |
|
325 | 325 | |
|
326 | 326 | Merge: |
|
327 | 327 | - one with change to an unrelated file |
|
328 | 328 | - one deleting and recreating the change |
|
329 | 329 | |
|
330 | 330 | $ hg up 'desc("b-1")' |
|
331 | 331 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
332 | 332 | $ hg merge 'desc("d-2")' |
|
333 | 333 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
334 | 334 | (branch merge, don't forget to commit) |
|
335 | 335 | $ hg ci -m 'mBDm-0 simple merge - one way' |
|
336 | 336 | $ hg up 'desc("d-2")' |
|
337 | 337 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
338 | 338 | $ hg merge 'desc("b-1")' |
|
339 | 339 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
340 | 340 | (branch merge, don't forget to commit) |
|
341 | 341 | $ hg ci -m 'mDBm-0 simple merge - the other way' |
|
342 | 342 | created new head |
|
343 | 343 | $ hg log -G --rev '::(desc("mDBm")+desc("mBDm"))' |
|
344 | 344 | @ 18 mDBm-0 simple merge - the other way |
|
345 | 345 | |\ |
|
346 | 346 | +---o 17 mBDm-0 simple merge - one way |
|
347 | 347 | | |/ |
|
348 | 348 | | o 8 d-2 re-add d |
|
349 | 349 | | | |
|
350 | 350 | | o 7 d-1 delete d |
|
351 | 351 | | | |
|
352 | 352 | o | 5 b-1: b update |
|
353 | 353 | |/ |
|
354 | 354 | o 2 i-2: c -move-> d |
|
355 | 355 | | |
|
356 | 356 | o 1 i-1: a -move-> c |
|
357 | 357 | | |
|
358 | 358 | o 0 i-0 initial commit: a b h |
|
359 | 359 | |
|
360 | 360 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBDm-0")' |
|
361 | 361 | M d |
|
362 | 362 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mDBm-0")' |
|
363 | 363 | M d |
|
364 | 364 | $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mBDm-0")' |
|
365 | 365 | M b |
|
366 | 366 | $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mDBm-0")' |
|
367 | 367 | M b |
|
368 | 368 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBDm-0")' |
|
369 | 369 | M b |
|
370 | 370 | M d |
|
371 | 371 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mDBm-0")' |
|
372 | 372 | M b |
|
373 | 373 | M d |
|
374 | 374 | |
|
375 | 375 | The bugs makes recorded copy is different depending of where we started the merge from since |
|
376 | 376 | |
|
377 | 377 | $ hg manifest --debug --rev 'desc("mBDm-0")' | grep '644 d' |
|
378 | 378 | b004912a8510032a0350a74daa2803dadfb00e12 644 d |
|
379 | 379 | $ hg manifest --debug --rev 'desc("mDBm-0")' | grep '644 d' |
|
380 | 380 | b004912a8510032a0350a74daa2803dadfb00e12 644 d |
|
381 | 381 | |
|
382 | 382 | $ hg manifest --debug --rev 'desc("d-2")' | grep '644 d' |
|
383 | 383 | b004912a8510032a0350a74daa2803dadfb00e12 644 d |
|
384 | 384 | $ hg manifest --debug --rev 'desc("b-1")' | grep '644 d' |
|
385 | 385 | 01c2f5eabdc4ce2bdee42b5f86311955e6c8f573 644 d |
|
386 | 386 | $ hg debugindex d |
|
387 | 387 | rev linkrev nodeid p1 p2 |
|
388 | 388 | 0 2 01c2f5eabdc4 000000000000 000000000000 |
|
389 | 389 | 1 8 b004912a8510 000000000000 000000000000 |
|
390 | 390 | |
|
391 | 391 | Log output should not include a merge commit as it did not happen |
|
392 | 392 | |
|
393 | 393 | $ hg log -Gfr 'desc("mBDm-0")' d |
|
394 | 394 | o 8 d-2 re-add d |
|
395 | 395 | | |
|
396 | 396 | ~ |
|
397 | 397 | |
|
398 | 398 | $ hg log -Gfr 'desc("mDBm-0")' d |
|
399 | 399 | o 8 d-2 re-add d |
|
400 | 400 | | |
|
401 | 401 | ~ |
|
402 | 402 | |
|
403 | 403 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBDm-0")' |
|
404 | 404 | M b |
|
405 | 405 | A d |
|
406 | 406 | R a |
|
407 | 407 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDBm-0")' |
|
408 | 408 | M b |
|
409 | 409 | A d |
|
410 | 410 | R a |
|
411 | 411 | |
|
412 | 412 | |
|
413 | 413 | Comparing with a merge with colliding rename |
|
414 | 414 | -------------------------------------------- |
|
415 | 415 | |
|
416 | 416 | - the "e-" branch renaming b to f (through 'g') |
|
417 | 417 | - the "a-" branch renaming d to f (through e) |
|
418 | 418 | |
|
419 | 419 | $ hg up 'desc("a-2")' |
|
420 | 420 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
421 | 421 | $ hg merge 'desc("e-2")' |
|
422 | 422 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
423 | 423 | (branch merge, don't forget to commit) |
|
424 | 424 | $ hg ci -m 'mAEm-0 simple merge - one way' |
|
425 | 425 | $ hg up 'desc("e-2")' |
|
426 | 426 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
427 | 427 | $ hg merge 'desc("a-2")' |
|
428 | 428 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
429 | 429 | (branch merge, don't forget to commit) |
|
430 | 430 | $ hg ci -m 'mEAm-0 simple merge - the other way' |
|
431 | 431 | created new head |
|
432 | 432 | $ hg log -G --rev '::(desc("mAEm")+desc("mEAm"))' |
|
433 | 433 | @ 20 mEAm-0 simple merge - the other way |
|
434 | 434 | |\ |
|
435 | 435 | +---o 19 mAEm-0 simple merge - one way |
|
436 | 436 | | |/ |
|
437 | 437 | | o 10 e-2 g -move-> f |
|
438 | 438 | | | |
|
439 | 439 | | o 9 e-1 b -move-> g |
|
440 | 440 | | | |
|
441 | 441 | o | 4 a-2: e -move-> f |
|
442 | 442 | | | |
|
443 | 443 | o | 3 a-1: d -move-> e |
|
444 | 444 | |/ |
|
445 | 445 | o 2 i-2: c -move-> d |
|
446 | 446 | | |
|
447 | 447 | o 1 i-1: a -move-> c |
|
448 | 448 | | |
|
449 | 449 | o 0 i-0 initial commit: a b h |
|
450 | 450 | |
|
451 | 451 | $ hg manifest --debug --rev 'desc("mAEm-0")' | grep '644 f' |
|
452 | 452 | eb806e34ef6be4c264effd5933d31004ad15a793 644 f |
|
453 | 453 | $ hg manifest --debug --rev 'desc("mEAm-0")' | grep '644 f' |
|
454 | 454 | eb806e34ef6be4c264effd5933d31004ad15a793 644 f |
|
455 | 455 | $ hg manifest --debug --rev 'desc("a-2")' | grep '644 f' |
|
456 | 456 | 0dd616bc7ab1a111921d95d76f69cda5c2ac539c 644 f |
|
457 | 457 | $ hg manifest --debug --rev 'desc("e-2")' | grep '644 f' |
|
458 | 458 | 6da5a2eecb9c833f830b67a4972366d49a9a142c 644 f |
|
459 | 459 | $ hg debugindex f |
|
460 | 460 | rev linkrev nodeid p1 p2 |
|
461 | 461 | 0 4 0dd616bc7ab1 000000000000 000000000000 |
|
462 | 462 | 1 10 6da5a2eecb9c 000000000000 000000000000 |
|
463 | 463 | 2 19 eb806e34ef6b 0dd616bc7ab1 6da5a2eecb9c |
|
464 | 464 | |
|
465 | 465 | # Here the filelog based implementation is not looking at the rename |
|
466 | 466 | # information (because the file exist on both side). However the changelog |
|
467 | 467 | # based on works fine. We have different output. |
|
468 | 468 | |
|
469 | 469 | $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mAEm-0")' |
|
470 | 470 | M f |
|
471 | 471 | b (no-filelog !) |
|
472 | 472 | R b |
|
473 | 473 | $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mEAm-0")' |
|
474 | 474 | M f |
|
475 | 475 | b (no-filelog !) |
|
476 | 476 | R b |
|
477 | 477 | $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mAEm-0")' |
|
478 | 478 | M f |
|
479 | 479 | d (no-filelog !) |
|
480 | 480 | R d |
|
481 | 481 | $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mEAm-0")' |
|
482 | 482 | M f |
|
483 | 483 | d (no-filelog !) |
|
484 | 484 | R d |
|
485 | 485 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("a-2")' |
|
486 | 486 | A f |
|
487 | 487 | d |
|
488 | 488 | R d |
|
489 | 489 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("e-2")' |
|
490 | 490 | A f |
|
491 | 491 | b |
|
492 | 492 | R b |
|
493 | 493 | |
|
494 | 494 | # From here, we run status against revision where both source file exists. |
|
495 | 495 | # |
|
496 | 496 | # The filelog based implementation picks an arbitrary side based on revision |
|
497 | 497 | # numbers. So the same side "wins" whatever the parents order is. This is |
|
498 | 498 | # sub-optimal because depending on revision numbers means the result can be |
|
499 | 499 | # different from one repository to the next. |
|
500 | 500 | # |
|
501 | 501 | # The changeset based algorithm use the parent order to break tie on conflicting |
|
502 | 502 | # information and will have a different order depending on who is p1 and p2. |
|
503 | 503 | # That order is stable accross repositories. (data from p1 prevails) |
|
504 | 504 | |
|
505 | 505 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mAEm-0")' |
|
506 | 506 | A f |
|
507 | 507 | d |
|
508 | 508 | R b |
|
509 | 509 | R d |
|
510 | 510 | $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mEAm-0")' |
|
511 | 511 | A f |
|
512 | 512 | d (filelog !) |
|
513 | 513 | b (no-filelog !) |
|
514 | 514 | R b |
|
515 | 515 | R d |
|
516 | 516 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAEm-0")' |
|
517 | 517 | A f |
|
518 | 518 | a |
|
519 | 519 | R a |
|
520 | 520 | R b |
|
521 | 521 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEAm-0")' |
|
522 | 522 | A f |
|
523 | 523 | a (filelog !) |
|
524 | 524 | b (no-filelog !) |
|
525 | 525 | R a |
|
526 | 526 | R b |
|
527 | 527 | |
|
528 | 528 | |
|
529 | 529 | Note: |
|
530 | 530 | | In this case, one of the merge wrongly record a merge while there is none. |
|
531 | 531 | | This lead to bad copy tracing information to be dug up. |
|
532 | 532 | |
|
533 | 533 | |
|
534 | 534 | Merge: |
|
535 | 535 | - one with change to an unrelated file (b) |
|
536 | 536 | - one overwriting a file (d) with a rename (from h to i to d) |
|
537 | 537 | |
|
538 | 538 | $ hg up 'desc("i-2")' |
|
539 | 539 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
540 | 540 | $ hg mv h i |
|
541 | 541 | $ hg commit -m "f-1: rename h -> i" |
|
542 | 542 | created new head |
|
543 | 543 | $ hg mv --force i d |
|
544 | 544 | $ hg commit -m "f-2: rename i -> d" |
|
545 | 545 | $ hg debugindex d |
|
546 | 546 | rev linkrev nodeid p1 p2 |
|
547 | 547 | 0 2 01c2f5eabdc4 000000000000 000000000000 |
|
548 | 548 | 1 8 b004912a8510 000000000000 000000000000 |
|
549 | 549 | 2 22 c72365ee036f 000000000000 000000000000 |
|
550 | 550 | $ hg up 'desc("b-1")' |
|
551 | 551 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
552 | 552 | $ hg merge 'desc("f-2")' |
|
553 | 553 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
554 | 554 | (branch merge, don't forget to commit) |
|
555 | 555 | $ hg ci -m 'mBFm-0 simple merge - one way' |
|
556 | 556 | $ hg up 'desc("f-2")' |
|
557 | 557 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
558 | 558 | $ hg merge 'desc("b-1")' |
|
559 | 559 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
560 | 560 | (branch merge, don't forget to commit) |
|
561 | 561 | $ hg ci -m 'mFBm-0 simple merge - the other way' |
|
562 | 562 | created new head |
|
563 | 563 | $ hg log -G --rev '::(desc("mBFm")+desc("mFBm"))' |
|
564 | 564 | @ 24 mFBm-0 simple merge - the other way |
|
565 | 565 | |\ |
|
566 | 566 | +---o 23 mBFm-0 simple merge - one way |
|
567 | 567 | | |/ |
|
568 | 568 | | o 22 f-2: rename i -> d |
|
569 | 569 | | | |
|
570 | 570 | | o 21 f-1: rename h -> i |
|
571 | 571 | | | |
|
572 | 572 | o | 5 b-1: b update |
|
573 | 573 | |/ |
|
574 | 574 | o 2 i-2: c -move-> d |
|
575 | 575 | | |
|
576 | 576 | o 1 i-1: a -move-> c |
|
577 | 577 | | |
|
578 | 578 | o 0 i-0 initial commit: a b h |
|
579 | 579 | |
|
580 | 580 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBFm-0")' |
|
581 | 581 | M b |
|
582 | 582 | A d |
|
583 | 583 | h |
|
584 | 584 | R a |
|
585 | 585 | R h |
|
586 | 586 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFBm-0")' |
|
587 | 587 | M b |
|
588 | 588 | A d |
|
589 | 589 | h |
|
590 | 590 | R a |
|
591 | 591 | R h |
|
592 | 592 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBFm-0")' |
|
593 | 593 | M d |
|
594 | 594 | h (no-filelog !) |
|
595 | 595 | R h |
|
596 | 596 | $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mBFm-0")' |
|
597 | 597 | M b |
|
598 | 598 | $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mBFm-0")' |
|
599 | 599 | M b |
|
600 | 600 | M d |
|
601 | 601 | i (no-filelog !) |
|
602 | 602 | R i |
|
603 | 603 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mFBm-0")' |
|
604 | 604 | M d |
|
605 | 605 | h (no-filelog !) |
|
606 | 606 | R h |
|
607 | 607 | $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mFBm-0")' |
|
608 | 608 | M b |
|
609 | 609 | $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mFBm-0")' |
|
610 | 610 | M b |
|
611 | 611 | M d |
|
612 | 612 | i (no-filelog !) |
|
613 | 613 | R i |
|
614 | 614 | |
|
615 | 615 | $ hg log -Gfr 'desc("mBFm-0")' d |
|
616 | 616 | o 22 f-2: rename i -> d |
|
617 | 617 | | |
|
618 | 618 | o 21 f-1: rename h -> i |
|
619 | 619 | : |
|
620 | 620 | o 0 i-0 initial commit: a b h |
|
621 | 621 | |
|
622 | 622 | |
|
623 | 623 | $ hg log -Gfr 'desc("mFBm-0")' d |
|
624 | 624 | o 22 f-2: rename i -> d |
|
625 | 625 | | |
|
626 | 626 | o 21 f-1: rename h -> i |
|
627 | 627 | : |
|
628 | 628 | o 0 i-0 initial commit: a b h |
|
629 | 629 | |
|
630 | 630 | |
|
631 | 631 | |
|
632 | 632 | Merge: |
|
633 | 633 | - one with change to a file |
|
634 | 634 | - one deleting and recreating the file |
|
635 | 635 | |
|
636 | 636 | Unlike in the 'BD/DB' cases, an actual merge happened here. So we should |
|
637 | 637 | consider history and rename on both branch of the merge. |
|
638 | 638 | |
|
639 | 639 | $ hg up 'desc("i-2")' |
|
640 | 640 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
641 | 641 | $ echo "some update" >> d |
|
642 | 642 | $ hg commit -m "g-1: update d" |
|
643 | 643 | created new head |
|
644 | 644 | $ hg up 'desc("d-2")' |
|
645 | 645 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
646 | 646 | $ hg merge 'desc("g-1")' --tool :union |
|
647 | 647 | merging d |
|
648 | 648 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
649 | 649 | (branch merge, don't forget to commit) |
|
650 | 650 | $ hg ci -m 'mDGm-0 simple merge - one way' |
|
651 | 651 | $ hg up 'desc("g-1")' |
|
652 | 652 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
653 | 653 | $ hg merge 'desc("d-2")' --tool :union |
|
654 | 654 | merging d |
|
655 | 655 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
656 | 656 | (branch merge, don't forget to commit) |
|
657 | 657 | $ hg ci -m 'mGDm-0 simple merge - the other way' |
|
658 | 658 | created new head |
|
659 | 659 | $ hg log -G --rev '::(desc("mDGm")+desc("mGDm"))' |
|
660 | 660 | @ 27 mGDm-0 simple merge - the other way |
|
661 | 661 | |\ |
|
662 | 662 | +---o 26 mDGm-0 simple merge - one way |
|
663 | 663 | | |/ |
|
664 | 664 | | o 25 g-1: update d |
|
665 | 665 | | | |
|
666 | 666 | o | 8 d-2 re-add d |
|
667 | 667 | | | |
|
668 | 668 | o | 7 d-1 delete d |
|
669 | 669 | |/ |
|
670 | 670 | o 2 i-2: c -move-> d |
|
671 | 671 | | |
|
672 | 672 | o 1 i-1: a -move-> c |
|
673 | 673 | | |
|
674 | 674 | o 0 i-0 initial commit: a b h |
|
675 | 675 | |
|
676 | 676 | One side of the merge have a long history with rename. The other side of the |
|
677 | 677 | merge point to a new file with a smaller history. Each side is "valid". |
|
678 | 678 | |
|
679 | 679 | (and again the filelog based algorithm only explore one, with a pick based on |
|
680 | 680 | revision numbers) |
|
681 | 681 | |
|
682 | 682 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDGm-0")' |
|
683 | 683 | A d |
|
684 | 684 | a (filelog !) |
|
685 | 685 | R a |
|
686 | 686 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGDm-0")' |
|
687 | 687 | A d |
|
688 | 688 | a |
|
689 | 689 | R a |
|
690 | 690 | $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mDGm-0")' |
|
691 | 691 | M d |
|
692 | 692 | $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mGDm-0")' |
|
693 | 693 | M d |
|
694 | 694 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mDGm-0")' |
|
695 | 695 | M d |
|
696 | 696 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGDm-0")' |
|
697 | 697 | M d |
|
698 | 698 | |
|
699 | 699 | $ hg log -Gfr 'desc("mDGm-0")' d |
|
700 | 700 | o 26 mDGm-0 simple merge - one way |
|
701 | 701 | |\ |
|
702 | 702 | | o 25 g-1: update d |
|
703 | 703 | | | |
|
704 | 704 | o | 8 d-2 re-add d |
|
705 | 705 | |/ |
|
706 | 706 | o 2 i-2: c -move-> d |
|
707 | 707 | | |
|
708 | 708 | o 1 i-1: a -move-> c |
|
709 | 709 | | |
|
710 | 710 | o 0 i-0 initial commit: a b h |
|
711 | 711 | |
|
712 | 712 | |
|
713 | 713 | |
|
714 | 714 | $ hg log -Gfr 'desc("mDGm-0")' d |
|
715 | 715 | o 26 mDGm-0 simple merge - one way |
|
716 | 716 | |\ |
|
717 | 717 | | o 25 g-1: update d |
|
718 | 718 | | | |
|
719 | 719 | o | 8 d-2 re-add d |
|
720 | 720 | |/ |
|
721 | 721 | o 2 i-2: c -move-> d |
|
722 | 722 | | |
|
723 | 723 | o 1 i-1: a -move-> c |
|
724 | 724 | | |
|
725 | 725 | o 0 i-0 initial commit: a b h |
|
726 | 726 | |
|
727 | 727 | |
|
728 | 728 | |
|
729 | 729 | Merge: |
|
730 | 730 | - one with change to a file (d) |
|
731 | 731 | - one overwriting that file with a rename (from h to i, to d) |
|
732 | 732 | |
|
733 | 733 | This case is similar to BF/FB, but an actual merge happens, so both side of the |
|
734 | 734 | history are relevant. |
|
735 | 735 | |
|
736 | 736 | Note: |
|
737 | 737 | | In this case, the merge get conflicting information since on one side we have |
|
738 | 738 | | "a -> c -> d". and one the other one we have "h -> i -> d". |
|
739 | 739 | | |
|
740 | 740 | | The current code arbitrarily pick one side |
|
741 | 741 | |
|
742 | 742 | $ hg up 'desc("f-2")' |
|
743 | 743 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
744 | 744 | $ hg merge 'desc("g-1")' --tool :union |
|
745 | 745 | merging d |
|
746 | 746 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
747 | 747 | (branch merge, don't forget to commit) |
|
748 | 748 | $ hg ci -m 'mFGm-0 simple merge - one way' |
|
749 | 749 | created new head |
|
750 | 750 | $ hg up 'desc("g-1")' |
|
751 | 751 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
752 | 752 | $ hg merge 'desc("f-2")' --tool :union |
|
753 | 753 | merging d |
|
754 | 754 | 0 files updated, 1 files merged, 1 files removed, 0 files unresolved |
|
755 | 755 | (branch merge, don't forget to commit) |
|
756 | 756 | $ hg ci -m 'mGFm-0 simple merge - the other way' |
|
757 | 757 | created new head |
|
758 | 758 | $ hg log -G --rev '::(desc("mGFm")+desc("mFGm"))' |
|
759 | 759 | @ 29 mGFm-0 simple merge - the other way |
|
760 | 760 | |\ |
|
761 | 761 | +---o 28 mFGm-0 simple merge - one way |
|
762 | 762 | | |/ |
|
763 | 763 | | o 25 g-1: update d |
|
764 | 764 | | | |
|
765 | 765 | o | 22 f-2: rename i -> d |
|
766 | 766 | | | |
|
767 | 767 | o | 21 f-1: rename h -> i |
|
768 | 768 | |/ |
|
769 | 769 | o 2 i-2: c -move-> d |
|
770 | 770 | | |
|
771 | 771 | o 1 i-1: a -move-> c |
|
772 | 772 | | |
|
773 | 773 | o 0 i-0 initial commit: a b h |
|
774 | 774 | |
|
775 | 775 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFGm-0")' |
|
776 | 776 | A d |
|
777 | 777 | h (no-filelog !) |
|
778 | 778 | a (filelog !) |
|
779 | 779 | R a |
|
780 | 780 | R h |
|
781 | 781 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGFm-0")' |
|
782 | 782 | A d |
|
783 | 783 | a |
|
784 | 784 | R a |
|
785 | 785 | R h |
|
786 | 786 | $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mFGm-0")' |
|
787 | 787 | M d |
|
788 | 788 | $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mGFm-0")' |
|
789 | 789 | M d |
|
790 | 790 | $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mFGm-0")' |
|
791 | 791 | M d |
|
792 | 792 | i (no-filelog !) |
|
793 | 793 | R i |
|
794 | 794 | $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mGFm-0")' |
|
795 | 795 | M d |
|
796 | 796 | i (no-filelog !) |
|
797 | 797 | R i |
|
798 | 798 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mFGm-0")' |
|
799 | 799 | M d |
|
800 | 800 | h (no-filelog !) |
|
801 | 801 | R h |
|
802 | 802 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGFm-0")' |
|
803 | 803 | M d |
|
804 | 804 | h (no-filelog !) |
|
805 | 805 | R h |
|
806 | 806 | |
|
807 | 807 | $ hg log -Gfr 'desc("mFGm-0")' d |
|
808 | 808 | o 28 mFGm-0 simple merge - one way |
|
809 | 809 | |\ |
|
810 | 810 | | o 25 g-1: update d |
|
811 | 811 | | | |
|
812 | 812 | o | 22 f-2: rename i -> d |
|
813 | 813 | | | |
|
814 | 814 | o | 21 f-1: rename h -> i |
|
815 | 815 | |/ |
|
816 | 816 | o 2 i-2: c -move-> d |
|
817 | 817 | | |
|
818 | 818 | o 1 i-1: a -move-> c |
|
819 | 819 | | |
|
820 | 820 | o 0 i-0 initial commit: a b h |
|
821 | 821 | |
|
822 | 822 | |
|
823 | 823 | $ hg log -Gfr 'desc("mGFm-0")' d |
|
824 | 824 | @ 29 mGFm-0 simple merge - the other way |
|
825 | 825 | |\ |
|
826 | 826 | | o 25 g-1: update d |
|
827 | 827 | | | |
|
828 | 828 | o | 22 f-2: rename i -> d |
|
829 | 829 | | | |
|
830 | 830 | o | 21 f-1: rename h -> i |
|
831 | 831 | |/ |
|
832 | 832 | o 2 i-2: c -move-> d |
|
833 | 833 | | |
|
834 | 834 | o 1 i-1: a -move-> c |
|
835 | 835 | | |
|
836 | 836 | o 0 i-0 initial commit: a b h |
|
837 | 837 | |
|
838 | 838 | |
|
839 | 839 | |
|
840 | 840 | Comparing with merging with a deletion (and keeping the file) |
|
841 | 841 | ------------------------------------------------------------- |
|
842 | 842 | |
|
843 | 843 | Merge: |
|
844 | 844 | - one removing a file (d) |
|
845 | 845 | - one updating that file |
|
846 | 846 | - the merge keep the modified version of the file (canceling the delete) |
|
847 | 847 | |
|
848 | 848 | In this case, the file keep on living after the merge. So we should not drop its |
|
849 | 849 | copy tracing chain. |
|
850 | 850 | |
|
851 | 851 | $ hg up 'desc("c-1")' |
|
852 | 852 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
853 | 853 | $ hg merge 'desc("g-1")' |
|
854 | 854 | file 'd' was deleted in local [working copy] but was modified in other [merge rev]. |
|
855 | 855 | You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved. |
|
856 | 856 | What do you want to do? u |
|
857 | 857 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
858 | 858 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
|
859 | 859 | [1] |
|
860 | 860 | $ hg resolve -t :other d |
|
861 | 861 | (no more unresolved files) |
|
862 | 862 | $ hg ci -m "mCGm-0" |
|
863 | 863 | created new head |
|
864 | 864 | |
|
865 | 865 | $ hg up 'desc("g-1")' |
|
866 | 866 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
867 | 867 | $ hg merge 'desc("c-1")' |
|
868 | 868 | file 'd' was deleted in other [merge rev] but was modified in local [working copy]. |
|
869 | 869 | You can use (c)hanged version, (d)elete, or leave (u)nresolved. |
|
870 | 870 | What do you want to do? u |
|
871 | 871 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
872 | 872 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
|
873 | 873 | [1] |
|
874 | 874 | $ hg resolve -t :local d |
|
875 | 875 | (no more unresolved files) |
|
876 | 876 | $ hg ci -m "mGCm-0" |
|
877 | 877 | created new head |
|
878 | 878 | |
|
879 | 879 | $ hg log -G --rev '::(desc("mCGm")+desc("mGCm"))' |
|
880 | 880 | @ 31 mGCm-0 |
|
881 | 881 | |\ |
|
882 | 882 | +---o 30 mCGm-0 |
|
883 | 883 | | |/ |
|
884 | 884 | | o 25 g-1: update d |
|
885 | 885 | | | |
|
886 | 886 | o | 6 c-1 delete d |
|
887 | 887 | |/ |
|
888 | 888 | o 2 i-2: c -move-> d |
|
889 | 889 | | |
|
890 | 890 | o 1 i-1: a -move-> c |
|
891 | 891 | | |
|
892 | 892 | o 0 i-0 initial commit: a b h |
|
893 | 893 | |
|
894 | 894 | |
|
895 | 895 | BROKEN: 'a' should be the the source of 'd' in the changeset centric algorithm too |
|
896 | 896 | |
|
897 | 897 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCGm-0")' |
|
898 | 898 | A d |
|
899 | 899 | a (filelog !) |
|
900 | 900 | R a |
|
901 | 901 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGCm-0")' |
|
902 | 902 | A d |
|
903 | 903 | a (filelog !) |
|
904 | 904 | R a |
|
905 | 905 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCGm-0")' |
|
906 | 906 | A d |
|
907 | 907 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mGCm-0")' |
|
908 | 908 | A d |
|
909 | 909 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mCGm-0")' |
|
910 | 910 | $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGCm-0")' |
|
911 | 911 | |
|
912 | 912 | |
|
913 | 913 | Comparing with merge restoring an untouched deleted file |
|
914 | 914 | -------------------------------------------------------- |
|
915 | 915 | |
|
916 | 916 | Merge: |
|
917 | 917 | - one removing a file (d) |
|
918 | 918 | - one leaving the file untouched |
|
919 | 919 | - the merge actively restore the file to the same content. |
|
920 | 920 | |
|
921 | 921 | In this case, the file keep on living after the merge. So we should not drop its |
|
922 | 922 | copy tracing chain. |
|
923 | 923 | |
|
924 | 924 | $ hg up 'desc("c-1")' |
|
925 | 925 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
926 | 926 | $ hg merge 'desc("b-1")' |
|
927 | 927 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
928 | 928 | (branch merge, don't forget to commit) |
|
929 | 929 | $ hg revert --rev 'desc("b-1")' d |
|
930 | 930 | $ hg ci -m "mCB-revert-m-0" |
|
931 | 931 | created new head |
|
932 | 932 | |
|
933 | 933 | $ hg up 'desc("b-1")' |
|
934 | 934 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
935 | 935 | $ hg merge 'desc("c-1")' |
|
936 | 936 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
937 | 937 | (branch merge, don't forget to commit) |
|
938 | 938 | $ hg revert --rev 'desc("b-1")' d |
|
939 | 939 | $ hg ci -m "mBC-revert-m-0" |
|
940 | 940 | created new head |
|
941 | 941 | |
|
942 | 942 | $ hg log -G --rev '::(desc("mCB-revert-m")+desc("mBC-revert-m"))' |
|
943 | 943 | @ 33 mBC-revert-m-0 |
|
944 | 944 | |\ |
|
945 | 945 | +---o 32 mCB-revert-m-0 |
|
946 | 946 | | |/ |
|
947 | 947 | | o 6 c-1 delete d |
|
948 | 948 | | | |
|
949 | 949 | o | 5 b-1: b update |
|
950 | 950 | |/ |
|
951 | 951 | o 2 i-2: c -move-> d |
|
952 | 952 | | |
|
953 | 953 | o 1 i-1: a -move-> c |
|
954 | 954 | | |
|
955 | 955 | o 0 i-0 initial commit: a b h |
|
956 | 956 | |
|
957 | 957 | |
|
958 | 958 | BROKEN: 'a' should be the the source of 'd' in the changeset centric algorithm too |
|
959 | 959 | |
|
960 | 960 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-revert-m-0")' |
|
961 | 961 | M b |
|
962 | 962 | A d |
|
963 | 963 | a (filelog !) |
|
964 | 964 | R a |
|
965 | 965 | $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC-revert-m-0")' |
|
966 | 966 | M b |
|
967 | 967 | A d |
|
968 | 968 | a (filelog !) |
|
969 | 969 | R a |
|
970 | 970 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCB-revert-m-0")' |
|
971 | 971 | M b |
|
972 | 972 | A d |
|
973 | 973 | $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBC-revert-m-0")' |
|
974 | 974 | M b |
|
975 | 975 | A d |
|
976 | 976 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCB-revert-m-0")' |
|
977 | 977 | $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBC-revert-m-0")' |
|
978 | 978 | |
|
979 | 979 | |
|
980 | 980 | Test that sidedata computations during upgrades ares correct |
|
981 | 981 | ============================================================ |
|
982 | 982 | |
|
983 | 983 | We upgrade a repository that is not using sidedata (the filelog case) and |
|
984 | 984 | check that the same side data have been generated as if they were computed at |
|
985 | 985 | commit time. |
|
986 | 986 | |
|
987 | 987 | |
|
988 | 988 | #if filelog |
|
989 | 989 | $ cat >> $HGRCPATH << EOF |
|
990 | 990 | > [format] |
|
991 | 991 | > exp-use-side-data = yes |
|
992 | 992 | > exp-use-copies-side-data-changeset = yes |
|
993 | 993 | > EOF |
|
994 | 994 | $ hg debugformat -v |
|
995 | 995 | format-variant repo config default |
|
996 | 996 | fncache: yes yes yes |
|
997 | 997 | dotencode: yes yes yes |
|
998 | 998 | generaldelta: yes yes yes |
|
999 | 999 | sparserevlog: yes yes yes |
|
1000 | 1000 | sidedata: no yes no |
|
1001 | 1001 | persistent-nodemap: no no no |
|
1002 | 1002 | copies-sdc: no yes no |
|
1003 | 1003 | plain-cl-delta: yes yes yes |
|
1004 | 1004 | compression: * (glob) |
|
1005 | 1005 | compression-level: default default default |
|
1006 | 1006 | $ hg debugupgraderepo --run --quiet |
|
1007 | 1007 | upgrade will perform the following actions: |
|
1008 | 1008 | |
|
1009 | 1009 | requirements |
|
1010 | 1010 | preserved: * (glob) |
|
1011 | 1011 | added: exp-copies-sidedata-changeset, exp-sidedata-flag |
|
1012 | 1012 | |
|
1013 | 1013 | #endif |
|
1014 | 1014 | |
|
1015 | 1015 | |
|
1016 | 1016 | #if no-compatibility |
|
1017 | 1017 | |
|
1018 | 1018 | $ for rev in `hg log --rev 'all()' -T '{rev}\n'`; do |
|
1019 | 1019 | > echo "##### revision $rev #####" |
|
1020 | 1020 | > hg debugsidedata -c -v -- $rev |
|
1021 | 1021 | > hg debugchangedfiles $rev |
|
1022 | 1022 | > done |
|
1023 | 1023 | ##### revision 0 ##### |
|
1024 | 1024 | 1 sidedata entries |
|
1025 | 1025 | entry-0014 size 34 |
|
1026 | 1026 | '\x00\x00\x00\x03\x04\x00\x00\x00\x01\x00\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00\x00abh' |
|
1027 | 1027 | added : a, ; |
|
1028 | 1028 | added : b, ; |
|
1029 | 1029 | added : h, ; |
|
1030 | 1030 | ##### revision 1 ##### |
|
1031 | 1031 | 1 sidedata entries |
|
1032 | 1032 | entry-0014 size 24 |
|
1033 | 1033 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00ac' |
|
1034 | 1034 | removed : a, ; |
|
1035 | 1035 | added p1: c, a; |
|
1036 | 1036 | ##### revision 2 ##### |
|
1037 | 1037 | 1 sidedata entries |
|
1038 | 1038 | entry-0014 size 24 |
|
1039 | 1039 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00cd' |
|
1040 | 1040 | removed : c, ; |
|
1041 | 1041 | added p1: d, c; |
|
1042 | 1042 | ##### revision 3 ##### |
|
1043 | 1043 | 1 sidedata entries |
|
1044 | 1044 | entry-0014 size 24 |
|
1045 | 1045 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00de' |
|
1046 | 1046 | removed : d, ; |
|
1047 | 1047 | added p1: e, d; |
|
1048 | 1048 | ##### revision 4 ##### |
|
1049 | 1049 | 1 sidedata entries |
|
1050 | 1050 | entry-0014 size 24 |
|
1051 | 1051 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00ef' |
|
1052 | 1052 | removed : e, ; |
|
1053 | 1053 | added p1: f, e; |
|
1054 | 1054 | ##### revision 5 ##### |
|
1055 | 1055 | 1 sidedata entries |
|
1056 | 1056 | entry-0014 size 14 |
|
1057 | 1057 | '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00b' |
|
1058 | 1058 | touched : b, ; |
|
1059 | 1059 | ##### revision 6 ##### |
|
1060 | 1060 | 1 sidedata entries |
|
1061 | 1061 | entry-0014 size 14 |
|
1062 | 1062 | '\x00\x00\x00\x01\x0c\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1063 | 1063 | removed : d, ; |
|
1064 | 1064 | ##### revision 7 ##### |
|
1065 | 1065 | 1 sidedata entries |
|
1066 | 1066 | entry-0014 size 14 |
|
1067 | 1067 | '\x00\x00\x00\x01\x0c\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1068 | 1068 | removed : d, ; |
|
1069 | 1069 | ##### revision 8 ##### |
|
1070 | 1070 | 1 sidedata entries |
|
1071 | 1071 | entry-0014 size 14 |
|
1072 | 1072 | '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1073 | 1073 | added : d, ; |
|
1074 | 1074 | ##### revision 9 ##### |
|
1075 | 1075 | 1 sidedata entries |
|
1076 | 1076 | entry-0014 size 24 |
|
1077 | 1077 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00bg' |
|
1078 | 1078 | removed : b, ; |
|
1079 | 1079 | added p1: g, b; |
|
1080 | 1080 | ##### revision 10 ##### |
|
1081 | 1081 | 1 sidedata entries |
|
1082 | 1082 | entry-0014 size 24 |
|
1083 | 1083 | '\x00\x00\x00\x02\x06\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00fg' |
|
1084 | 1084 | added p1: f, g; |
|
1085 | 1085 | removed : g, ; |
|
1086 | 1086 | ##### revision 11 ##### |
|
1087 | 1087 | 1 sidedata entries |
|
1088 | 1088 | entry-0014 size 4 |
|
1089 | 1089 | '\x00\x00\x00\x00' |
|
1090 | 1090 | ##### revision 12 ##### |
|
1091 | 1091 | 1 sidedata entries |
|
1092 | 1092 | entry-0014 size 4 |
|
1093 | 1093 | '\x00\x00\x00\x00' |
|
1094 | 1094 | ##### revision 13 ##### |
|
1095 | 1095 | 1 sidedata entries |
|
1096 | 1096 | entry-0014 size 4 |
|
1097 | 1097 | '\x00\x00\x00\x00' |
|
1098 | 1098 | ##### revision 14 ##### |
|
1099 | 1099 | 1 sidedata entries |
|
1100 | 1100 | entry-0014 size 14 |
|
1101 | 1101 | '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1102 | 1102 | added : d, ; |
|
1103 | 1103 | ##### revision 15 ##### |
|
1104 | 1104 | 1 sidedata entries |
|
1105 | 1105 | entry-0014 size 4 |
|
1106 | 1106 | '\x00\x00\x00\x00' |
|
1107 | 1107 | ##### revision 16 ##### |
|
1108 | 1108 | 1 sidedata entries |
|
1109 | 1109 | entry-0014 size 14 |
|
1110 | 1110 | '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1111 | 1111 | added : d, ; |
|
1112 | 1112 | ##### revision 17 ##### |
|
1113 | 1113 | 1 sidedata entries |
|
1114 | 1114 | entry-0014 size 4 |
|
1115 | 1115 | '\x00\x00\x00\x00' |
|
1116 | 1116 | ##### revision 18 ##### |
|
1117 | 1117 | 1 sidedata entries |
|
1118 | 1118 | entry-0014 size 4 |
|
1119 | 1119 | '\x00\x00\x00\x00' |
|
1120 | 1120 | ##### revision 19 ##### |
|
1121 | 1121 | 1 sidedata entries |
|
1122 | 1122 | entry-0014 size 14 |
|
1123 | 1123 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f' |
|
1124 | 1124 | merged : f, ; |
|
1125 | 1125 | ##### revision 20 ##### |
|
1126 | 1126 | 1 sidedata entries |
|
1127 | 1127 | entry-0014 size 14 |
|
1128 | 1128 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f' |
|
1129 | 1129 | merged : f, ; |
|
1130 | 1130 | ##### revision 21 ##### |
|
1131 | 1131 | 1 sidedata entries |
|
1132 | 1132 | entry-0014 size 24 |
|
1133 | 1133 | '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00hi' |
|
1134 | 1134 | removed : h, ; |
|
1135 | 1135 | added p1: i, h; |
|
1136 | 1136 | ##### revision 22 ##### |
|
1137 | 1137 | 1 sidedata entries |
|
1138 | 1138 | entry-0014 size 24 |
|
1139 | 1139 | '\x00\x00\x00\x02\x16\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00di' |
|
1140 | 1140 | touched p1: d, i; |
|
1141 | 1141 | removed : i, ; |
|
1142 | 1142 | ##### revision 23 ##### |
|
1143 | 1143 | 1 sidedata entries |
|
1144 | 1144 | entry-0014 size 4 |
|
1145 | 1145 | '\x00\x00\x00\x00' |
|
1146 | 1146 | ##### revision 24 ##### |
|
1147 | 1147 | 1 sidedata entries |
|
1148 | 1148 | entry-0014 size 4 |
|
1149 | 1149 | '\x00\x00\x00\x00' |
|
1150 | 1150 | ##### revision 25 ##### |
|
1151 | 1151 | 1 sidedata entries |
|
1152 | 1152 | entry-0014 size 14 |
|
1153 | 1153 | '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1154 | 1154 | touched : d, ; |
|
1155 | 1155 | ##### revision 26 ##### |
|
1156 | 1156 | 1 sidedata entries |
|
1157 | 1157 | entry-0014 size 14 |
|
1158 | 1158 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1159 | 1159 | merged : d, ; |
|
1160 | 1160 | ##### revision 27 ##### |
|
1161 | 1161 | 1 sidedata entries |
|
1162 | 1162 | entry-0014 size 14 |
|
1163 | 1163 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1164 | 1164 | merged : d, ; |
|
1165 | 1165 | ##### revision 28 ##### |
|
1166 | 1166 | 1 sidedata entries |
|
1167 | 1167 | entry-0014 size 14 |
|
1168 | 1168 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1169 | 1169 | merged : d, ; |
|
1170 | 1170 | ##### revision 29 ##### |
|
1171 | 1171 | 1 sidedata entries |
|
1172 | 1172 | entry-0014 size 14 |
|
1173 | 1173 | '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d' |
|
1174 | 1174 | merged : d, ; |
|
1175 | 1175 | ##### revision 30 ##### |
|
1176 | 1176 | 1 sidedata entries |
|
1177 | entry-0014 size 4 | |
|
1178 | '\x00\x00\x00\x00' | |
|
1177 | entry-0014 size 14 | |
|
1178 | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | |
|
1179 | salvaged : d, ; | |
|
1179 | 1180 | ##### revision 31 ##### |
|
1180 | 1181 | 1 sidedata entries |
|
1181 | entry-0014 size 4 | |
|
1182 | '\x00\x00\x00\x00' | |
|
1182 | entry-0014 size 14 | |
|
1183 | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | |
|
1184 | salvaged : d, ; | |
|
1183 | 1185 | ##### revision 32 ##### |
|
1184 | 1186 | 1 sidedata entries |
|
1185 | entry-0014 size 4 | |
|
1186 | '\x00\x00\x00\x00' | |
|
1187 | entry-0014 size 14 | |
|
1188 | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | |
|
1189 | salvaged : d, ; | |
|
1187 | 1190 | ##### revision 33 ##### |
|
1188 | 1191 | 1 sidedata entries |
|
1189 | entry-0014 size 4 | |
|
1190 | '\x00\x00\x00\x00' | |
|
1192 | entry-0014 size 14 | |
|
1193 | '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d' | |
|
1194 | salvaged : d, ; | |
|
1191 | 1195 | |
|
1192 | 1196 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now