Show More
@@ -357,98 +357,96 b' def _combine_changeset_copies(' | |||||
357 | alwaysmatch = match.always() |
|
357 | alwaysmatch = match.always() | |
358 |
|
358 | |||
359 | if rustmod is not None and alwaysmatch: |
|
359 | if rustmod is not None and alwaysmatch: | |
360 |
|
|
360 | final_copies = rustmod.combine_changeset_copies( | |
361 | list(revs), children_count, targetrev, revinfo, isancestor |
|
361 | list(revs), children_count, targetrev, revinfo, isancestor | |
362 | ) |
|
362 | ) | |
363 |
|
363 | else: | ||
364 | isancestor = cached_is_ancestor(isancestor) |
|
364 | isancestor = cached_is_ancestor(isancestor) | |
365 |
|
||||
366 | all_copies = {} |
|
|||
367 | # iterate over all the "children" side of copy tracing "edge" |
|
|||
368 | for current_rev in revs: |
|
|||
369 | p1, p2, changes = revinfo(current_rev) |
|
|||
370 | current_copies = None |
|
|||
371 |
|
365 | |||
372 | # iterate over all parents to chain the existing data with the |
|
366 | all_copies = {} | |
373 | # data from the parent β child edge. |
|
367 | # iterate over all the "children" side of copy tracing "edge" | |
374 |
for |
|
368 | for current_rev in revs: | |
375 | if parent_rev == nullrev: |
|
369 | p1, p2, changes = revinfo(current_rev) | |
376 | continue |
|
370 | current_copies = None | |
377 | remaining_children = children_count.get(parent_rev) |
|
371 | # iterate over all parents to chain the existing data with the | |
378 | if remaining_children is None: |
|
372 | # data from the parent β child edge. | |
379 | continue |
|
373 | for parent, parent_rev in ((1, p1), (2, p2)): | |
380 | remaining_children -= 1 |
|
374 | if parent_rev == nullrev: | |
381 | children_count[parent_rev] = remaining_children |
|
375 | continue | |
382 |
|
|
376 | remaining_children = children_count.get(parent_rev) | |
383 | copies = all_copies.get(parent_rev, None) |
|
377 | if remaining_children is None: | |
384 | else: |
|
378 | continue | |
385 | copies = all_copies.pop(parent_rev, None) |
|
379 | remaining_children -= 1 | |
|
380 | children_count[parent_rev] = remaining_children | |||
|
381 | if remaining_children: | |||
|
382 | copies = all_copies.get(parent_rev, None) | |||
|
383 | else: | |||
|
384 | copies = all_copies.pop(parent_rev, None) | |||
386 |
|
385 | |||
387 | if copies is None: |
|
386 | if copies is None: | |
388 | # this is a root |
|
387 | # this is a root | |
389 | copies = {} |
|
388 | copies = {} | |
390 |
|
389 | |||
391 | newcopies = copies |
|
390 | newcopies = copies | |
392 | # chain the data in the edge with the existing data |
|
391 | # chain the data in the edge with the existing data | |
393 | if changes is not None: |
|
392 | if changes is not None: | |
394 | childcopies = {} |
|
393 | childcopies = {} | |
395 | if parent == 1: |
|
394 | if parent == 1: | |
396 | childcopies = changes.copied_from_p1 |
|
395 | childcopies = changes.copied_from_p1 | |
397 | elif parent == 2: |
|
396 | elif parent == 2: | |
398 | childcopies = changes.copied_from_p2 |
|
397 | childcopies = changes.copied_from_p2 | |
399 |
|
398 | |||
400 | if not alwaysmatch: |
|
399 | if not alwaysmatch: | |
401 | childcopies = { |
|
400 | childcopies = { | |
402 | dst: src |
|
401 | dst: src | |
403 | for dst, src in childcopies.items() |
|
402 | for dst, src in childcopies.items() | |
404 | if match(dst) |
|
403 | if match(dst) | |
405 | } |
|
404 | } | |
406 | if childcopies: |
|
405 | if childcopies: | |
407 | newcopies = copies.copy() |
|
|||
408 | for dest, source in pycompat.iteritems(childcopies): |
|
|||
409 | prev = copies.get(source) |
|
|||
410 | if prev is not None and prev[1] is not None: |
|
|||
411 | source = prev[1] |
|
|||
412 | newcopies[dest] = (current_rev, source) |
|
|||
413 | assert newcopies is not copies |
|
|||
414 | if changes.removed: |
|
|||
415 | if newcopies is copies: |
|
|||
416 | newcopies = copies.copy() |
|
406 | newcopies = copies.copy() | |
417 | for f in changes.removed: |
|
407 | for dest, source in pycompat.iteritems(childcopies): | |
418 |
|
|
408 | prev = copies.get(source) | |
419 |
if |
|
409 | if prev is not None and prev[1] is not None: | |
420 | # copy on write to avoid affecting potential other |
|
410 | source = prev[1] | |
421 | # branches. when there are no other branches, this |
|
411 | newcopies[dest] = (current_rev, source) | |
422 | # could be avoided. |
|
412 | assert newcopies is not copies | |
423 | newcopies = copies.copy() |
|
413 | if changes.removed: | |
424 |
|
|
414 | if newcopies is copies: | |
|
415 | newcopies = copies.copy() | |||
|
416 | for f in changes.removed: | |||
|
417 | if f in newcopies: | |||
|
418 | if newcopies is copies: | |||
|
419 | # copy on write to avoid affecting potential other | |||
|
420 | # branches. when there are no other branches, this | |||
|
421 | # could be avoided. | |||
|
422 | newcopies = copies.copy() | |||
|
423 | newcopies[f] = (current_rev, None) | |||
|
424 | # check potential need to combine the data from another parent (for | |||
|
425 | # that child). See comment below for details. | |||
|
426 | if current_copies is None: | |||
|
427 | current_copies = newcopies | |||
|
428 | elif current_copies is newcopies: | |||
|
429 | # nothing to merge: | |||
|
430 | pass | |||
|
431 | else: | |||
|
432 | # we are the second parent to work on c, we need to merge our | |||
|
433 | # work with the other. | |||
|
434 | # | |||
|
435 | # In case of conflict, parent 1 take precedence over parent 2. | |||
|
436 | # This is an arbitrary choice made anew when implementing | |||
|
437 | # changeset based copies. It was made without regards with | |||
|
438 | # potential filelog related behavior. | |||
|
439 | assert parent == 2 | |||
|
440 | current_copies = _merge_copies_dict( | |||
|
441 | newcopies, current_copies, isancestor, changes | |||
|
442 | ) | |||
|
443 | all_copies[current_rev] = current_copies | |||
425 |
|
444 | |||
426 | # check potential need to combine the data from another parent (for |
|
445 | # filter out internal details and return a {dest: source mapping} | |
427 | # that child). See comment below for details. |
|
446 | final_copies = {} | |
428 | if current_copies is None: |
|
447 | for dest, (tt, source) in all_copies[targetrev].items(): | |
429 | current_copies = newcopies |
|
448 | if source is not None: | |
430 | elif current_copies is newcopies: |
|
449 | final_copies[dest] = source | |
431 | # nothing to merge: |
|
|||
432 | pass |
|
|||
433 | else: |
|
|||
434 | # we are the second parent to work on c, we need to merge our |
|
|||
435 | # work with the other. |
|
|||
436 | # |
|
|||
437 | # In case of conflict, parent 1 take precedence over parent 2. |
|
|||
438 | # This is an arbitrary choice made anew when implementing |
|
|||
439 | # changeset based copies. It was made without regards with |
|
|||
440 | # potential filelog related behavior. |
|
|||
441 | assert parent == 2 |
|
|||
442 | current_copies = _merge_copies_dict( |
|
|||
443 | newcopies, current_copies, isancestor, changes |
|
|||
444 | ) |
|
|||
445 | all_copies[current_rev] = current_copies |
|
|||
446 |
|
||||
447 | # filter out internal details and return a {dest: source mapping} |
|
|||
448 | final_copies = {} |
|
|||
449 | for dest, (tt, source) in all_copies[targetrev].items(): |
|
|||
450 | if source is not None: |
|
|||
451 | final_copies[dest] = source |
|
|||
452 | return final_copies |
|
450 | return final_copies | |
453 |
|
451 | |||
454 |
|
452 |
General Comments 0
You need to be logged in to leave comments.
Login now