comparison mercurial/patch.py @ 3702:70c3ee224c08

Don't generate git patches that rename a file to multiple destinations With this patch, instead of generating N renames, we'll generate 1 rename and N-1 copies. Ideally the rename should come after the copies instead of before them, but that'd be harder to do.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 20 Nov 2006 19:32:46 -0200
parents 05c8704a3743
children ab5600428b08
comparison
equal deleted inserted replaced
3701:05c8704a3743 3702:70c3ee224c08
545 copied[f] = src 545 copied[f] = src
546 srcs = [x[1][0] for x in copied.items()] 546 srcs = [x[1][0] for x in copied.items()]
547 547
548 all = modified + added + removed 548 all = modified + added + removed
549 all.sort() 549 all.sort()
550 gone = {}
550 for f in all: 551 for f in all:
551 to = None 552 to = None
552 tn = None 553 tn = None
553 dodiff = True 554 dodiff = True
554 header = [] 555 header = []
572 mode = gitmode(util.is_exec(repo.wjoin(f), None)) 573 mode = gitmode(util.is_exec(repo.wjoin(f), None))
573 if f in copied: 574 if f in copied:
574 a, arev = copied[f] 575 a, arev = copied[f]
575 omode = gitmode(mmap.execf(a)) 576 omode = gitmode(mmap.execf(a))
576 addmodehdr(header, omode, mode) 577 addmodehdr(header, omode, mode)
577 op = a in removed and 'rename' or 'copy' 578 if a in removed and a not in gone:
579 op = 'rename'
580 gone[a] = 1
581 else:
582 op = 'copy'
578 header.append('%s from %s\n' % (op, a)) 583 header.append('%s from %s\n' % (op, a))
579 header.append('%s to %s\n' % (op, f)) 584 header.append('%s to %s\n' % (op, f))
580 to = getfile(a).read(arev) 585 to = getfile(a).read(arev)
581 else: 586 else:
582 header.append('new file mode %s\n' % mode) 587 header.append('new file mode %s\n' % mode)