##// END OF EJS Templates
copytrace: move the default copytracing algorithm in a new function...
Pulkit Goyal -
r34080:b4b19609 default
parent child Browse files
Show More
@@ -306,9 +306,13 b' def _combinecopies(copyfrom, copyto, fin'
306 306
307 307 def mergecopies(repo, c1, c2, base):
308 308 """
309 The basic algorithm for copytracing. Copytracing is used in commands like
310 rebase, merge, unshelve, etc to merge files that were moved/ copied in one
311 merge parent and modified in another. For example:
309 The function calling different copytracing algorithms on the basis of config
310 which find moves and copies between context c1 and c2 that are relevant for
311 merging. 'base' will be used as the merge base.
312
313 Copytracing is used in commands like rebase, merge, unshelve, etc to merge
314 files that were moved/ copied in one merge parent and modified in another.
315 For example:
312 316
313 317 o ---> 4 another commit
314 318 |
@@ -324,13 +328,6 b' def mergecopies(repo, c1, c2, base):'
324 328
325 329 ```other changed <file> which local deleted```
326 330
327 If copytrace is enabled, this function finds all the new files that were
328 added from merge base up to the top commit (here 4), and for each file it
329 checks if this file was copied from another file (a.txt in the above case).
330
331 Find moves and copies between context c1 and c2 that are relevant
332 for merging. 'base' will be used as the merge base.
333
334 331 Returns five dicts: "copy", "movewithdir", "diverge", "renamedelete" and
335 332 "dirmove".
336 333
@@ -360,12 +357,24 b' def mergecopies(repo, c1, c2, base):'
360 357 if c2.node() is None and c1.node() == repo.dirstate.p1():
361 358 return repo.dirstate.copies(), {}, {}, {}, {}
362 359
360 copytracing = repo.ui.config('experimental', 'copytrace')
361
363 362 # Copy trace disabling is explicitly below the node == p1 logic above
364 363 # because the logic above is required for a simple copy to be kept across a
365 364 # rebase.
366 if repo.ui.config('experimental', 'copytrace') == 'off':
365 if copytracing == 'off':
367 366 return {}, {}, {}, {}, {}
367 else:
368 return _fullcopytracing(repo, c1, c2, base)
368 369
370 def _fullcopytracing(repo, c1, c2, base):
371 """ The full copytracing algorithm which finds all the new files that were
372 added from merge base up to the top commit and for each file it checks if
373 this file was copied from another file.
374
375 This is pretty slow when a lot of changesets are involved but will track all
376 the copies.
377 """
369 378 # In certain scenarios (e.g. graft, update or rebase), base can be
370 379 # overridden We still need to know a real common ancestor in this case We
371 380 # can't just compute _c1.ancestor(_c2) and compare it to ca, because there
@@ -1,3 +1,6 b''
1 Test for the full copytracing algorithm
2 =======================================
3
1 4 $ hg init t
2 5 $ cd t
3 6
General Comments 0
You need to be logged in to leave comments. Login now