comparison mercurial/copies.py @ 26657:1ae898cfe857

copies: move _makegetfctx calls into checkcopies
author Matt Mackall <mpm@selenic.com>
date Wed, 19 Aug 2015 15:26:08 -0500
parents 3e3d783b0d59
children aabfa0fb7e3e
comparison
equal deleted inserted replaced
26656:3e3d783b0d59 26657:1ae898cfe857
326 addedinm1 = m1.filesnotin(ma) 326 addedinm1 = m1.filesnotin(ma)
327 addedinm2 = m2.filesnotin(ma) 327 addedinm2 = m2.filesnotin(ma)
328 u1, u2 = _computenonoverlap(repo, c1, c2, addedinm1, addedinm2) 328 u1, u2 = _computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
329 329
330 for f in u1: 330 for f in u1:
331 getfctx = _makegetfctx(c1) 331 checkcopies(c1, f, m1, m2, ca, limit, diverge, copy1, fullcopy1)
332 checkcopies(getfctx, f, m1, m2, ca, limit, diverge, copy1, fullcopy1)
333 332
334 for f in u2: 333 for f in u2:
335 getfctx = _makegetfctx(c2) 334 checkcopies(c2, f, m2, m1, ca, limit, diverge, copy2, fullcopy2)
336 checkcopies(getfctx, f, m2, m1, ca, limit, diverge, copy2, fullcopy2)
337 335
338 copy = dict(copy1.items() + copy2.items()) 336 copy = dict(copy1.items() + copy2.items())
339 movewithdir = dict(movewithdir1.items() + movewithdir2.items()) 337 movewithdir = dict(movewithdir1.items() + movewithdir2.items())
340 fullcopy = dict(fullcopy1.items() + fullcopy2.items()) 338 fullcopy = dict(fullcopy1.items() + fullcopy2.items())
341 339
357 if bothnew: 355 if bothnew:
358 repo.ui.debug(" unmatched files new in both:\n %s\n" 356 repo.ui.debug(" unmatched files new in both:\n %s\n"
359 % "\n ".join(bothnew)) 357 % "\n ".join(bothnew))
360 bothdiverge, _copy, _fullcopy = {}, {}, {} 358 bothdiverge, _copy, _fullcopy = {}, {}, {}
361 for f in bothnew: 359 for f in bothnew:
362 getfctx = _makegetfctx(c1) 360 checkcopies(c1, f, m1, m2, ca, limit, bothdiverge, _copy, _fullcopy)
363 checkcopies(getfctx, f, m1, m2, ca, limit, bothdiverge, 361 checkcopies(c2, f, m2, m1, ca, limit, bothdiverge, _copy, _fullcopy)
364 _copy, _fullcopy)
365 getfctx = _makegetfctx(c2)
366 checkcopies(getfctx, f, m2, m1, ca, limit, bothdiverge,
367 _copy, _fullcopy)
368 for of, fl in bothdiverge.items(): 362 for of, fl in bothdiverge.items():
369 if len(fl) == 2 and fl[0] == fl[1]: 363 if len(fl) == 2 and fl[0] == fl[1]:
370 copy[fl[0]] = of # not actually divergent, just matching renames 364 copy[fl[0]] = of # not actually divergent, just matching renames
371 365
372 if fullcopy and repo.ui.debugflag: 366 if fullcopy and repo.ui.debugflag:
442 "dst: '%s'\n") % (f, df)) 436 "dst: '%s'\n") % (f, df))
443 break 437 break
444 438
445 return copy, movewithdir, diverge, renamedelete 439 return copy, movewithdir, diverge, renamedelete
446 440
447 def checkcopies(getfctx, f, m1, m2, ca, limit, diverge, copy, fullcopy): 441 def checkcopies(ctx, f, m1, m2, ca, limit, diverge, copy, fullcopy):
448 """ 442 """
449 check possible copies of f from m1 to m2 443 check possible copies of f from m1 to m2
450 444
451 getfctx = function accepting (filename, node) that returns a filectx. 445 ctx = starting context for f in m1
452 f = the filename to check 446 f = the filename to check
453 m1 = the source manifest 447 m1 = the source manifest
454 m2 = the destination manifest 448 m2 = the destination manifest
455 ca = the changectx of the common ancestor 449 ca = the changectx of the common ancestor
456 limit = the rev number to not search beyond 450 limit = the rev number to not search beyond
458 copy = record all non-divergent copies in this dict 452 copy = record all non-divergent copies in this dict
459 fullcopy = record all copies in this dict 453 fullcopy = record all copies in this dict
460 """ 454 """
461 455
462 ma = ca.manifest() 456 ma = ca.manifest()
457 getfctx = _makegetfctx(ctx)
463 458
464 def _related(f1, f2, limit): 459 def _related(f1, f2, limit):
465 # Walk back to common ancestor to see if the two files originate 460 # Walk back to common ancestor to see if the two files originate
466 # from the same file. Since workingfilectx's rev() is None it messes 461 # from the same file. Since workingfilectx's rev() is None it messes
467 # up the integer comparison logic, hence the pre-step check for 462 # up the integer comparison logic, hence the pre-step check for