comparison mercurial/patch.py @ 4496:b79cdb7f0597

patch.diff: avoid calling workingctx().manifest() Right now, to generate the manifest of the working dir, we have to perform a full walk of the working dir, which will be very slow, especially if we're interested in only a small part of it. Since we use the manifest only to find out the mode of files for git patches, manually build an execf function to do it. This should fix issue567.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 03 Jun 2007 14:38:52 -0300
parents c927c568a5ad
children 96d8a56d4ef9
comparison
equal deleted inserted replaced
4495:fc20fa9f2dfd 4496:b79cdb7f0597
493 if not modified and not added and not removed: 493 if not modified and not added and not removed:
494 return 494 return
495 495
496 if node2: 496 if node2:
497 ctx2 = context.changectx(repo, node2) 497 ctx2 = context.changectx(repo, node2)
498 execf2 = ctx2.manifest().execf
498 else: 499 else:
499 ctx2 = context.workingctx(repo) 500 ctx2 = context.workingctx(repo)
500 man2 = ctx2.manifest() 501 execf2 = util.execfunc(repo.root, None)
502 if execf2 is None:
503 execf2 = ctx2.parents()[0].manifest().copy().execf
501 504
502 # returns False if there was no rename between ctx1 and ctx2 505 # returns False if there was no rename between ctx1 and ctx2
503 # returns None if the file was created between ctx1 and ctx2 506 # returns None if the file was created between ctx1 and ctx2
504 # returns the (file, node) present in ctx1 that was renamed to f in ctx2 507 # returns the (file, node) present in ctx1 that was renamed to f in ctx2
505 def renamed(f): 508 def renamed(f):
561 header.append('old mode %s\n' % omode) 564 header.append('old mode %s\n' % omode)
562 header.append('new mode %s\n' % nmode) 565 header.append('new mode %s\n' % nmode)
563 566
564 a, b = f, f 567 a, b = f, f
565 if f in added: 568 if f in added:
566 mode = gitmode(man2.execf(f)) 569 mode = gitmode(execf2(f))
567 if f in copied: 570 if f in copied:
568 a = copied[f] 571 a = copied[f]
569 omode = gitmode(man1.execf(a)) 572 omode = gitmode(man1.execf(a))
570 addmodehdr(header, omode, mode) 573 addmodehdr(header, omode, mode)
571 if a in removed and a not in gone: 574 if a in removed and a not in gone:
586 else: 589 else:
587 mode = gitmode(man1.execf(f)) 590 mode = gitmode(man1.execf(f))
588 header.append('deleted file mode %s\n' % mode) 591 header.append('deleted file mode %s\n' % mode)
589 else: 592 else:
590 omode = gitmode(man1.execf(f)) 593 omode = gitmode(man1.execf(f))
591 nmode = gitmode(man2.execf(f)) 594 nmode = gitmode(execf2(f))
592 addmodehdr(header, omode, nmode) 595 addmodehdr(header, omode, nmode)
593 if util.binary(to) or util.binary(tn): 596 if util.binary(to) or util.binary(tn):
594 dodiff = 'binary' 597 dodiff = 'binary'
595 r = None 598 r = None
596 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b)) 599 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))