Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 12915:df1b65f8b4d4
patch: remove unused gitworkdone variable from iterhunks()
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 03 Nov 2010 21:11:05 +0100 |
parents | 61f48581d8ef |
children | cfedc529e4a1 |
comparison
equal
deleted
inserted
replaced
12914:27bc21814e9c | 12915:df1b65f8b4d4 |
---|---|
993 | 993 |
994 # our states | 994 # our states |
995 BFILE = 1 | 995 BFILE = 1 |
996 context = None | 996 context = None |
997 lr = linereader(fp) | 997 lr = linereader(fp) |
998 # gitworkdone is True if a git operation (copy, rename, ...) was | |
999 # performed already for the current file. Useful when the file | |
1000 # section may have no hunk. | |
1001 gitworkdone = False | |
1002 | 998 |
1003 while True: | 999 while True: |
1004 newfile = newgitfile = False | 1000 newfile = newgitfile = False |
1005 x = lr.readline() | 1001 x = lr.readline() |
1006 if not x: | 1002 if not x: |
1030 yield 'file', ('a/' + afile, 'b/' + bfile, current_hunk) | 1026 yield 'file', ('a/' + afile, 'b/' + bfile, current_hunk) |
1031 current_hunk.extract(lr) | 1027 current_hunk.extract(lr) |
1032 elif x.startswith('diff --git'): | 1028 elif x.startswith('diff --git'): |
1033 # check for git diff, scanning the whole patch file if needed | 1029 # check for git diff, scanning the whole patch file if needed |
1034 m = gitre.match(x) | 1030 m = gitre.match(x) |
1035 gitworkdone = False | |
1036 if m: | 1031 if m: |
1037 afile, bfile = m.group(1, 2) | 1032 afile, bfile = m.group(1, 2) |
1038 if not git: | 1033 if not git: |
1039 git = True | 1034 git = True |
1040 gitpatches = scangitpatch(lr, x) | 1035 gitpatches = scangitpatch(lr, x) |
1045 # copy/rename + modify should modify target, not source | 1040 # copy/rename + modify should modify target, not source |
1046 gp = changed.get(bfile) | 1041 gp = changed.get(bfile) |
1047 if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') | 1042 if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') |
1048 or gp.mode): | 1043 or gp.mode): |
1049 afile = bfile | 1044 afile = bfile |
1050 gitworkdone = True | |
1051 newgitfile = True | 1045 newgitfile = True |
1052 elif x.startswith('---'): | 1046 elif x.startswith('---'): |
1053 # check for a unified diff | 1047 # check for a unified diff |
1054 l2 = lr.readline() | 1048 l2 = lr.readline() |
1055 if not l2.startswith('+++'): | 1049 if not l2.startswith('+++'): |
1072 continue | 1066 continue |
1073 newfile = True | 1067 newfile = True |
1074 context = True | 1068 context = True |
1075 afile = parsefilename(x) | 1069 afile = parsefilename(x) |
1076 bfile = parsefilename(l2) | 1070 bfile = parsefilename(l2) |
1077 | |
1078 if newfile: | |
1079 gitworkdone = False | |
1080 | 1071 |
1081 if newgitfile or newfile: | 1072 if newgitfile or newfile: |
1082 emitfile = True | 1073 emitfile = True |
1083 state = BFILE | 1074 state = BFILE |
1084 hunknum = 0 | 1075 hunknum = 0 |