equal
deleted
inserted
replaced
1005 changed = {} |
1005 changed = {} |
1006 afile = "" |
1006 afile = "" |
1007 bfile = "" |
1007 bfile = "" |
1008 state = None |
1008 state = None |
1009 hunknum = 0 |
1009 hunknum = 0 |
1010 emitfile = False |
1010 emitfile = newfile = False |
1011 git = False |
1011 git = False |
1012 |
1012 |
1013 # our states |
1013 # our states |
1014 BFILE = 1 |
1014 BFILE = 1 |
1015 context = None |
1015 context = None |
1016 lr = linereader(fp) |
1016 lr = linereader(fp) |
1017 |
1017 |
1018 while True: |
1018 while True: |
1019 newfile = newgitfile = False |
|
1020 x = lr.readline() |
1019 x = lr.readline() |
1021 if not x: |
1020 if not x: |
1022 break |
1021 break |
1023 if (state == BFILE and ((not context and x[0] == '@') or |
1022 if (state == BFILE and ((not context and x[0] == '@') or |
1024 ((context is not False) and x.startswith('***************')))): |
1023 ((context is not False) and x.startswith('***************')))): |
1056 # copy/rename + modify should modify target, not source |
1055 # copy/rename + modify should modify target, not source |
1057 gp = changed.get(bfile) |
1056 gp = changed.get(bfile) |
1058 if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') |
1057 if gp and (gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') |
1059 or gp.mode): |
1058 or gp.mode): |
1060 afile = bfile |
1059 afile = bfile |
1061 newgitfile = True |
1060 newfile = True |
1062 elif x.startswith('---'): |
1061 elif x.startswith('---'): |
1063 # check for a unified diff |
1062 # check for a unified diff |
1064 l2 = lr.readline() |
1063 l2 = lr.readline() |
1065 if not l2.startswith('+++'): |
1064 if not l2.startswith('+++'): |
1066 lr.push(l2) |
1065 lr.push(l2) |
1083 newfile = True |
1082 newfile = True |
1084 context = True |
1083 context = True |
1085 afile = parsefilename(x) |
1084 afile = parsefilename(x) |
1086 bfile = parsefilename(l2) |
1085 bfile = parsefilename(l2) |
1087 |
1086 |
1088 if newgitfile or newfile: |
1087 if newfile: |
|
1088 newfile = False |
1089 emitfile = True |
1089 emitfile = True |
1090 state = BFILE |
1090 state = BFILE |
1091 hunknum = 0 |
1091 hunknum = 0 |
1092 |
1092 |
1093 def applydiff(ui, fp, changed, strip=1, eolmode='strict'): |
1093 def applydiff(ui, fp, changed, strip=1, eolmode='strict'): |