##// 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 m2 = c2.manifest()
246 m2 = c2.manifest()
247 ma = ca.manifest()
247 ma = ca.manifest()
248
248
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).
260
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
249 def makectx(f, n):
272 def makectx(f, n):
250 if len(n) != 20: # in a working context?
273 if len(n) != 20: # in a working context?
251 if c1.rev() is None:
274 if c1.rev() is None:
252 return c1.filectx(f)
275 return c1.filectx(f)
253 return c2.filectx(f)
276 return c2.filectx(f)
254 return repo.filectx(f, fileid=n)
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)
255
283
256 ctx = util.lrucachefunc(makectx)
257 copy = {}
284 copy = {}
258 movewithdir = {}
285 movewithdir = {}
259 fullcopy = {}
286 fullcopy = {}
@@ -272,9 +299,11 b' def mergecopies(repo, c1, c2, ca):'
272 % "\n ".join(u2))
299 % "\n ".join(u2))
273
300
274 for f in u1:
301 for f in u1:
302 ctx = setupctx(c1)
275 checkcopies(ctx, f, m1, m2, ca, limit, diverge, copy, fullcopy)
303 checkcopies(ctx, f, m1, m2, ca, limit, diverge, copy, fullcopy)
276
304
277 for f in u2:
305 for f in u2:
306 ctx = setupctx(c2)
278 checkcopies(ctx, f, m2, m1, ca, limit, diverge, copy, fullcopy)
307 checkcopies(ctx, f, m2, m1, ca, limit, diverge, copy, fullcopy)
279
308
280 renamedelete = {}
309 renamedelete = {}
@@ -297,7 +326,9 b' def mergecopies(repo, c1, c2, ca):'
297 % "\n ".join(bothnew))
326 % "\n ".join(bothnew))
298 bothdiverge, _copy, _fullcopy = {}, {}, {}
327 bothdiverge, _copy, _fullcopy = {}, {}, {}
299 for f in bothnew:
328 for f in bothnew:
329 ctx = setupctx(c1)
300 checkcopies(ctx, f, m1, m2, ca, limit, bothdiverge, _copy, _fullcopy)
330 checkcopies(ctx, f, m1, m2, ca, limit, bothdiverge, _copy, _fullcopy)
331 ctx = setupctx(c2)
301 checkcopies(ctx, f, m2, m1, ca, limit, bothdiverge, _copy, _fullcopy)
332 checkcopies(ctx, f, m2, m1, ca, limit, bothdiverge, _copy, _fullcopy)
302 for of, fl in bothdiverge.items():
333 for of, fl in bothdiverge.items():
303 if len(fl) == 2 and fl[0] == fl[1]:
334 if len(fl) == 2 and fl[0] == fl[1]:
General Comments 0
You need to be logged in to leave comments. Login now