Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
3e3d783b
Commit
3e3d783b
authored
9 years ago
by
Matt Mackall
Browse files
Options
Downloads
Patches
Plain Diff
copies: factor out setupctx into _makegetfctx
This reduces the scope of mergecopies a bit
parent
f3c6540f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mercurial/copies.py
+39
-40
39 additions, 40 deletions
mercurial/copies.py
with
39 additions
and
40 deletions
mercurial/copies.py
+
39
−
40
View file @
3e3d783b
...
...
@@ -237,6 +237,41 @@
%
"
\n
"
.
join
(
u2
))
return
u1
,
u2
def
_makegetfctx
(
ctx
):
"""
return a
'
getfctx
'
function suitable for checkcopies usage
We have to re-setup the function building
'
filectx
'
for each
'
checkcopies
'
to ensure the linkrev adjustement is properly setup for
each. Linkrev adjustment is important to avoid bug in rename
detection. Moreover, having a proper
'
_ancestrycontext
'
setup ensures
the performance impact of this adjustment is kept limited. Without it,
each file could do a full dag traversal making the time complexity of
the operation explode (see issue4537).
This function exists here mostly to limit the impact on stable. Feel
free to refactor on default.
"""
rev
=
ctx
.
rev
()
repo
=
ctx
.
_repo
ac
=
getattr
(
ctx
,
'
_ancestrycontext
'
,
None
)
if
ac
is
None
:
revs
=
[
rev
]
if
rev
is
None
:
revs
=
[
p
.
rev
()
for
p
in
ctx
.
parents
()]
ac
=
repo
.
changelog
.
ancestors
(
revs
,
inclusive
=
True
)
ctx
.
_ancestrycontext
=
ac
def
makectx
(
f
,
n
):
if
len
(
n
)
!=
20
:
# in a working context?
if
ctx
.
rev
()
is
None
:
return
ctx
.
filectx
(
f
)
return
repo
[
None
][
f
]
fctx
=
repo
.
filectx
(
f
,
fileid
=
n
)
# setup only needed for filectx not create from a changectx
fctx
.
_ancestrycontext
=
ac
fctx
.
_descendantrev
=
rev
return
fctx
return
util
.
lrucachefunc
(
makectx
)
def
mergecopies
(
repo
,
c1
,
c2
,
ca
):
"""
Find moves and copies between context c1 and c2 that are relevant
...
...
@@ -283,42 +318,6 @@
m2
=
c2
.
manifest
()
ma
=
ca
.
manifest
()
def
setupctx
(
ctx
):
"""
return a
'
getfctx
'
function suitable for checkcopies usage
We have to re-setup the function building
'
filectx
'
for each
'
checkcopies
'
to ensure the linkrev adjustement is properly setup for
each. Linkrev adjustment is important to avoid bug in rename
detection. Moreover, having a proper
'
_ancestrycontext
'
setup ensures
the performance impact of this adjustment is kept limited. Without it,
each file could do a full dag traversal making the time complexity of
the operation explode (see issue4537).
This function exists here mostly to limit the impact on stable. Feel
free to refactor on default.
"""
rev
=
ctx
.
rev
()
ac
=
getattr
(
ctx
,
'
_ancestrycontext
'
,
None
)
repo
=
ctx
.
_repo
if
ac
is
None
:
revs
=
[
rev
]
if
rev
is
None
:
revs
=
[
p
.
rev
()
for
p
in
ctx
.
parents
()]
ac
=
ctx
.
_repo
.
changelog
.
ancestors
(
revs
,
inclusive
=
True
)
ctx
.
_ancestrycontext
=
ac
def
makectx
(
f
,
n
):
if
len
(
n
)
!=
20
:
# in a working context?
if
ctx
.
rev
()
is
None
:
return
ctx
.
filectx
(
f
)
return
repo
[
None
][
f
]
fctx
=
repo
.
filectx
(
f
,
fileid
=
n
)
# setup only needed for filectx not create from a changectx
fctx
.
_ancestrycontext
=
ac
fctx
.
_descendantrev
=
rev
return
fctx
return
util
.
lrucachefunc
(
makectx
)
copy1
,
copy2
,
=
{},
{}
movewithdir1
,
movewithdir2
=
{},
{}
fullcopy1
,
fullcopy2
=
{},
{}
...
...
@@ -329,7 +328,7 @@
u1
,
u2
=
_computenonoverlap
(
repo
,
c1
,
c2
,
addedinm1
,
addedinm2
)
for
f
in
u1
:
getfctx
=
setup
ctx
(
c1
)
getfctx
=
_makegetf
ctx
(
c1
)
checkcopies
(
getfctx
,
f
,
m1
,
m2
,
ca
,
limit
,
diverge
,
copy1
,
fullcopy1
)
for
f
in
u2
:
...
...
@@ -333,7 +332,7 @@
checkcopies
(
getfctx
,
f
,
m1
,
m2
,
ca
,
limit
,
diverge
,
copy1
,
fullcopy1
)
for
f
in
u2
:
getfctx
=
setup
ctx
(
c2
)
getfctx
=
_makegetf
ctx
(
c2
)
checkcopies
(
getfctx
,
f
,
m2
,
m1
,
ca
,
limit
,
diverge
,
copy2
,
fullcopy2
)
copy
=
dict
(
copy1
.
items
()
+
copy2
.
items
())
...
...
@@ -360,6 +359,6 @@
%
"
\n
"
.
join
(
bothnew
))
bothdiverge
,
_copy
,
_fullcopy
=
{},
{},
{}
for
f
in
bothnew
:
getfctx
=
setup
ctx
(
c1
)
getfctx
=
_makegetf
ctx
(
c1
)
checkcopies
(
getfctx
,
f
,
m1
,
m2
,
ca
,
limit
,
bothdiverge
,
_copy
,
_fullcopy
)
...
...
@@ -364,6 +363,6 @@
checkcopies
(
getfctx
,
f
,
m1
,
m2
,
ca
,
limit
,
bothdiverge
,
_copy
,
_fullcopy
)
getfctx
=
setup
ctx
(
c2
)
getfctx
=
_makegetf
ctx
(
c2
)
checkcopies
(
getfctx
,
f
,
m2
,
m1
,
ca
,
limit
,
bothdiverge
,
_copy
,
_fullcopy
)
for
of
,
fl
in
bothdiverge
.
items
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment