comparison mercurial/patch.py @ 10747:b010d899665e stable

patch: differentiate start of file with diff --git vs '--- '
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 20 Mar 2010 21:16:22 +0100
parents d94832c4a31d
children fb06e357e698
comparison
equal deleted inserted replaced
10745:d94832c4a31d 10747:b010d899665e
1017 # performed already for the current file. Useful when the file 1017 # performed already for the current file. Useful when the file
1018 # section may have no hunk. 1018 # section may have no hunk.
1019 gitworkdone = False 1019 gitworkdone = False
1020 1020
1021 while True: 1021 while True:
1022 newfile = False 1022 newfile = newgitfile = False
1023 x = lr.readline() 1023 x = lr.readline()
1024 if not x: 1024 if not x:
1025 break 1025 break
1026 if current_hunk: 1026 if current_hunk:
1027 if x.startswith('\ '): 1027 if x.startswith('\ '):
1068 # copy/rename + modify should modify target, not source 1068 # copy/rename + modify should modify target, not source
1069 gp = changed.get(bfile) 1069 gp = changed.get(bfile)
1070 if gp and gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD'): 1070 if gp and gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD'):
1071 afile = bfile 1071 afile = bfile
1072 gitworkdone = True 1072 gitworkdone = True
1073 newfile = True 1073 newgitfile = True
1074 elif x.startswith('---'): 1074 elif x.startswith('---'):
1075 # check for a unified diff 1075 # check for a unified diff
1076 l2 = lr.readline() 1076 l2 = lr.readline()
1077 if not l2.startswith('+++'): 1077 if not l2.startswith('+++'):
1078 lr.push(l2) 1078 lr.push(l2)
1095 newfile = True 1095 newfile = True
1096 context = True 1096 context = True
1097 afile = parsefilename(x) 1097 afile = parsefilename(x)
1098 bfile = parsefilename(l2) 1098 bfile = parsefilename(l2)
1099 1099
1100 if newfile: 1100 if newgitfile or newfile:
1101 emitfile = True 1101 emitfile = True
1102 state = BFILE 1102 state = BFILE
1103 hunknum = 0 1103 hunknum = 0
1104 if current_hunk: 1104 if current_hunk:
1105 if current_hunk.complete(): 1105 if current_hunk.complete():