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

copies: extract data extraction into a `revinfo` function

The function is build once at the beginning of the algorithm and used fetch
appropriate information for each revision.

This abstracts some implementation details from the main algorithm and will help
us to access the data more efficiently in future changesets.

Differential Revision: https://phab.mercurial-scm.org/D7070
parent 181d28ba
No related branches found
No related tags found
No related merge requests found
......@@ -178,9 +178,31 @@
return cm
def _revinfogetter(repo):
"""return a function that return multiple data given a <rev>"i
* p1: revision number of first parent
* p2: revision number of first parent
* p1copies: mapping of copies from p1
* p2copies: mapping of copies from p2
* removed: a list of removed files
"""
cl = repo.changelog
parents = cl.parentrevs
def revinfo(rev):
p1, p2 = parents(rev)
ctx = repo[rev]
p1copies, p2copies = ctx._copies
removed = ctx.filesremoved()
return p1, p2, p1copies, p2copies, removed
return revinfo
def _changesetforwardcopies(a, b, match):
if a.rev() in (node.nullrev, b.rev()):
return {}
repo = a.repo()
children = {}
......@@ -181,9 +203,11 @@
def _changesetforwardcopies(a, b, match):
if a.rev() in (node.nullrev, b.rev()):
return {}
repo = a.repo()
children = {}
revinfo = _revinfogetter(repo)
cl = repo.changelog
missingrevs = cl.findmissingrevs(common=[a.rev()], heads=[b.rev()])
for r in missingrevs:
......@@ -206,9 +230,7 @@
if r == b.rev():
return copies
for i, c in enumerate(children[r]):
childctx = repo[c]
p1, p2 = cl.parentrevs(c)
p1copies, p2copies = childctx._copies
p1, p2, p1copies, p2copies, removed = revinfo(c)
if r == p1:
parent = 1
childcopies = p1copies
......@@ -227,7 +249,7 @@
newcopies = copies
if childcopies:
newcopies = _chain(newcopies, childcopies)
for f in childctx.filesremoved():
for f in removed:
if f in newcopies:
del newcopies[f]
othercopies = all_copies.get(c)
......
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