Skip to content
Snippets Groups Projects
Commit 70a9eb899637 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

copies: document the current algorithm step

We are about to reorganise everything and we document the "old" way to clarify
the change that leads to the "new way".

Differential Revision: https://phab.mercurial-scm.org/D9581
parent d109dda4a3e7
No related branches found
No related tags found
No related merge requests found
# coding: utf8
# copies.py - copy detection for Mercurial
#
# Copyright 2008 Matt Mackall <mpm@selenic.com>
......@@ -351,4 +352,5 @@
isancestor = cached_is_ancestor(isancestor)
all_copies = {}
# iterate over all the "parent" side of copy tracing "edge"
for r in revs:
......@@ -354,5 +356,6 @@
for r in revs:
# fetch potential previously computed data for that parent
copies = all_copies.pop(r, None)
if copies is None:
# this is a root
copies = {}
......@@ -355,7 +358,10 @@
copies = all_copies.pop(r, None)
if copies is None:
# this is a root
copies = {}
# iterate over all known children to chain the existing data with the
# data from the parent → child edge.
for i, c in enumerate(children[r]):
p1, p2, changes = revinfo(c)
childcopies = {}
......@@ -359,6 +365,8 @@
for i, c in enumerate(children[r]):
p1, p2, changes = revinfo(c)
childcopies = {}
# select the right parent → child edge
if r == p1:
parent = 1
if changes is not None:
......@@ -372,6 +380,8 @@
childcopies = {
dst: src for dst, src in childcopies.items() if match(dst)
}
# chain the data in the edge with the existing data
newcopies = copies
if childcopies:
newcopies = copies.copy()
......@@ -392,6 +402,9 @@
# could be avoided.
newcopies = copies.copy()
newcopies[f] = (c, None)
# check potential need to combine the data from another parent (for
# that child). See comment below for details.
othercopies = all_copies.get(c)
if othercopies is None:
all_copies[c] = newcopies
......@@ -418,6 +431,7 @@
copies = _merge_copies_dict(minor, major, isancestor, changes)
all_copies[c] = copies
# filter out internal details and return a {dest: source mapping}
final_copies = {}
for dest, (tt, source) in all_copies[targetrev].items():
if source is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment