Show More
@@ -357,98 +357,96 b' def _combine_changeset_copies(' | |||
|
357 | 357 | alwaysmatch = match.always() |
|
358 | 358 | |
|
359 | 359 | if rustmod is not None and alwaysmatch: |
|
360 |
|
|
|
360 | final_copies = rustmod.combine_changeset_copies( | |
|
361 | 361 | list(revs), children_count, targetrev, revinfo, isancestor |
|
362 | 362 | ) |
|
363 | ||
|
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 | |
|
363 | else: | |
|
364 | isancestor = cached_is_ancestor(isancestor) | |
|
371 | 365 | |
|
372 | # iterate over all parents to chain the existing data with the | |
|
373 | # data from the parent β child edge. | |
|
374 |
for |
|
|
375 | if parent_rev == nullrev: | |
|
376 | continue | |
|
377 | remaining_children = children_count.get(parent_rev) | |
|
378 | if remaining_children is None: | |
|
379 | continue | |
|
380 | remaining_children -= 1 | |
|
381 | children_count[parent_rev] = remaining_children | |
|
382 |
|
|
|
383 | copies = all_copies.get(parent_rev, None) | |
|
384 | else: | |
|
385 | copies = all_copies.pop(parent_rev, None) | |
|
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 | # iterate over all parents to chain the existing data with the | |
|
372 | # data from the parent β child edge. | |
|
373 | for parent, parent_rev in ((1, p1), (2, p2)): | |
|
374 | if parent_rev == nullrev: | |
|
375 | continue | |
|
376 | remaining_children = children_count.get(parent_rev) | |
|
377 | if remaining_children is None: | |
|
378 | continue | |
|
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: | |
|
388 | # this is a root | |
|
389 | copies = {} | |
|
386 | if copies is None: | |
|
387 | # this is a root | |
|
388 | copies = {} | |
|
390 | 389 | |
|
391 | newcopies = copies | |
|
392 | # chain the data in the edge with the existing data | |
|
393 | if changes is not None: | |
|
394 | childcopies = {} | |
|
395 | if parent == 1: | |
|
396 | childcopies = changes.copied_from_p1 | |
|
397 | elif parent == 2: | |
|
398 | childcopies = changes.copied_from_p2 | |
|
390 | newcopies = copies | |
|
391 | # chain the data in the edge with the existing data | |
|
392 | if changes is not None: | |
|
393 | childcopies = {} | |
|
394 | if parent == 1: | |
|
395 | childcopies = changes.copied_from_p1 | |
|
396 | elif parent == 2: | |
|
397 | childcopies = changes.copied_from_p2 | |
|
399 | 398 | |
|
400 | if not alwaysmatch: | |
|
401 | childcopies = { | |
|
402 | dst: src | |
|
403 | for dst, src in childcopies.items() | |
|
404 | if match(dst) | |
|
405 | } | |
|
406 | 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: | |
|
399 | if not alwaysmatch: | |
|
400 | childcopies = { | |
|
401 | dst: src | |
|
402 | for dst, src in childcopies.items() | |
|
403 | if match(dst) | |
|
404 | } | |
|
405 | if childcopies: | |
|
416 | 406 | newcopies = copies.copy() |
|
417 | for f in changes.removed: | |
|
418 |
|
|
|
419 |
if |
|
|
420 | # copy on write to avoid affecting potential other | |
|
421 | # branches. when there are no other branches, this | |
|
422 | # could be avoided. | |
|
423 | newcopies = copies.copy() | |
|
424 |
|
|
|
407 | for dest, source in pycompat.iteritems(childcopies): | |
|
408 | prev = copies.get(source) | |
|
409 | if prev is not None and prev[1] is not None: | |
|
410 | source = prev[1] | |
|
411 | newcopies[dest] = (current_rev, source) | |
|
412 | assert newcopies is not copies | |
|
413 | if changes.removed: | |
|
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 | |
|
427 | # that child). See comment below for details. | |
|
428 | if current_copies is None: | |
|
429 | current_copies = newcopies | |
|
430 | elif current_copies is newcopies: | |
|
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 | |
|
445 | # filter out internal details and return a {dest: source mapping} | |
|
446 | final_copies = {} | |
|
447 | for dest, (tt, source) in all_copies[targetrev].items(): | |
|
448 | if source is not None: | |
|
449 | final_copies[dest] = source | |
|
452 | 450 | return final_copies |
|
453 | 451 | |
|
454 | 452 |
General Comments 0
You need to be logged in to leave comments.
Login now