##// END OF EJS Templates
mergecopies: reuse ancestry context when traversing file history (issue4537)...
Pierre-Yves David -
r24412:9372180b stable
parent child Browse files
Show More
@@ -246,14 +246,41 b' def mergecopies(repo, c1, c2, ca):'
246 246 m2 = c2.manifest()
247 247 ma = ca.manifest()
248 248
249 def makectx(f, n):
250 if len(n) != 20: # in a working context?
251 if c1.rev() is None:
252 return c1.filectx(f)
253 return c2.filectx(f)
254 return repo.filectx(f, fileid=n)
249
250 def setupctx(ctx):
251 """return a 'makectx' function suitable for checkcopies usage from ctx
252
253 We have to re-setup the function building 'filectx' for each
254 'checkcopies' to ensure the linkrev adjustement is properly setup for
255 each. Linkrev adjustment is important to avoid bug in rename
256 detection. Moreover, having a proper '_ancestrycontext' setup ensures
257 the performance impact of this adjustment is kept limited. Without it,
258 each file could do a full dag traversal making the time complexity of
259 the operation explode (see issue4537).
255 260
256 ctx = util.lrucachefunc(makectx)
261 This function exists here mostly to limit the impact on stable. Feel
262 free to refactor on default.
263 """
264 rev = ctx.rev()
265 ac = getattr(ctx, '_ancestrycontext', None)
266 if ac is None:
267 revs = [rev]
268 if rev is None:
269 revs = [p.rev() for p in ctx.parents()]
270 ac = ctx._repo.changelog.ancestors(revs, inclusive=True)
271 ctx._ancestrycontext = ac
272 def makectx(f, n):
273 if len(n) != 20: # in a working context?
274 if c1.rev() is None:
275 return c1.filectx(f)
276 return c2.filectx(f)
277 fctx = repo.filectx(f, fileid=n)
278 # setup only needed for filectx not create from a changectx
279 fctx._ancestrycontext = ac
280 fctx._descendantrev = rev
281 return fctx
282 return util.lrucachefunc(makectx)
283
257 284 copy = {}
258 285 movewithdir = {}
259 286 fullcopy = {}
@@ -272,9 +299,11 b' def mergecopies(repo, c1, c2, ca):'
272 299 % "\n ".join(u2))
273 300
274 301 for f in u1:
302 ctx = setupctx(c1)
275 303 checkcopies(ctx, f, m1, m2, ca, limit, diverge, copy, fullcopy)
276 304
277 305 for f in u2:
306 ctx = setupctx(c2)
278 307 checkcopies(ctx, f, m2, m1, ca, limit, diverge, copy, fullcopy)
279 308
280 309 renamedelete = {}
@@ -297,7 +326,9 b' def mergecopies(repo, c1, c2, ca):'
297 326 % "\n ".join(bothnew))
298 327 bothdiverge, _copy, _fullcopy = {}, {}, {}
299 328 for f in bothnew:
329 ctx = setupctx(c1)
300 330 checkcopies(ctx, f, m1, m2, ca, limit, bothdiverge, _copy, _fullcopy)
331 ctx = setupctx(c2)
301 332 checkcopies(ctx, f, m2, m1, ca, limit, bothdiverge, _copy, _fullcopy)
302 333 for of, fl in bothdiverge.items():
303 334 if len(fl) == 2 and fl[0] == fl[1]:
General Comments 0
You need to be logged in to leave comments. Login now