Show More
@@ -42,7 +42,7 def scanpatch(fp): | |||||
42 | line = lr.readline() |
|
42 | line = lr.readline() | |
43 | if not line: |
|
43 | if not line: | |
44 | break |
|
44 | break | |
45 | if line.startswith('diff --git a/'): |
|
45 | if line.startswith('diff --git a/') or line.startswith('diff -r '): | |
46 | def notheader(line): |
|
46 | def notheader(line): | |
47 | s = line.split(None, 1) |
|
47 | s = line.split(None, 1) | |
48 | return not s or s[0] not in ('---', 'diff') |
|
48 | return not s or s[0] not in ('---', 'diff') | |
@@ -70,7 +70,8 class header(object): | |||||
70 |
|
70 | |||
71 | XXX shoudn't we move this to mercurial/patch.py ? |
|
71 | XXX shoudn't we move this to mercurial/patch.py ? | |
72 | """ |
|
72 | """ | |
73 | diff_re = re.compile('diff --git a/(.*) b/(.*)$') |
|
73 | diffgit_re = re.compile('diff --git a/(.*) b/(.*)$') | |
|
74 | diff_re = re.compile('diff -r .* (.*)$') | |||
74 | allhunks_re = re.compile('(?:index|new file|deleted file) ') |
|
75 | allhunks_re = re.compile('(?:index|new file|deleted file) ') | |
75 | pretty_re = re.compile('(?:new file|deleted file) ') |
|
76 | pretty_re = re.compile('(?:new file|deleted file) ') | |
76 | special_re = re.compile('(?:index|new|deleted|copy|rename) ') |
|
77 | special_re = re.compile('(?:index|new|deleted|copy|rename) ') | |
@@ -110,10 +111,14 class header(object): | |||||
110 | return True |
|
111 | return True | |
111 |
|
112 | |||
112 | def files(self): |
|
113 | def files(self): | |
113 |
|
|
114 | match = self.diffgit_re.match(self.header[0]) | |
|
115 | if match: | |||
|
116 | fromfile, tofile = match.groups() | |||
114 | if fromfile == tofile: |
|
117 | if fromfile == tofile: | |
115 | return [fromfile] |
|
118 | return [fromfile] | |
116 | return [fromfile, tofile] |
|
119 | return [fromfile, tofile] | |
|
120 | else: | |||
|
121 | return self.diff_re.match(self.header[0]).groups() | |||
117 |
|
122 | |||
118 | def filename(self): |
|
123 | def filename(self): | |
119 | return self.files()[-1] |
|
124 | return self.files()[-1] |
General Comments 0
You need to be logged in to leave comments.
Login now