Show More
@@ -114,6 +114,10 b' def extract(ui, fileobj):' | |||||
114 | return None, message, user, date |
|
114 | return None, message, user, date | |
115 | return tmpname, message, user, date |
|
115 | return tmpname, message, user, date | |
116 |
|
116 | |||
|
117 | GP_PATCH = 1 << 0 # we have to run patch | |||
|
118 | GP_FILTER = 1 << 1 # there's some copy/rename operation | |||
|
119 | GP_BINARY = 1 << 2 # there's a binary patch | |||
|
120 | ||||
117 | def readgitpatch(patchname): |
|
121 | def readgitpatch(patchname): | |
118 | """extract git-style metadata about patches from <patchname>""" |
|
122 | """extract git-style metadata about patches from <patchname>""" | |
119 | class gitpatch: |
|
123 | class gitpatch: | |
@@ -133,7 +137,7 b' def readgitpatch(patchname):' | |||||
133 | gp = None |
|
137 | gp = None | |
134 | gitpatches = [] |
|
138 | gitpatches = [] | |
135 | # Can have a git patch with only metadata, causing patch to complain |
|
139 | # Can have a git patch with only metadata, causing patch to complain | |
136 |
dopatch = |
|
140 | dopatch = 0 | |
137 |
|
141 | |||
138 | lineno = 0 |
|
142 | lineno = 0 | |
139 | for line in pf: |
|
143 | for line in pf: | |
@@ -150,11 +154,10 b' def readgitpatch(patchname):' | |||||
150 | if line.startswith('--- '): |
|
154 | if line.startswith('--- '): | |
151 | if gp.op in ('COPY', 'RENAME'): |
|
155 | if gp.op in ('COPY', 'RENAME'): | |
152 | gp.copymod = True |
|
156 | gp.copymod = True | |
153 |
dopatch = |
|
157 | dopatch |= GP_FILTER | |
154 | gitpatches.append(gp) |
|
158 | gitpatches.append(gp) | |
155 | gp = None |
|
159 | gp = None | |
156 |
|
|
160 | dopatch |= GP_PATCH | |
157 | dopatch = True |
|
|||
158 | continue |
|
161 | continue | |
159 | if line.startswith('rename from '): |
|
162 | if line.startswith('rename from '): | |
160 | gp.op = 'RENAME' |
|
163 | gp.op = 'RENAME' | |
@@ -174,14 +177,13 b' def readgitpatch(patchname):' | |||||
174 | elif line.startswith('new mode '): |
|
177 | elif line.startswith('new mode '): | |
175 | gp.mode = int(line.rstrip()[-3:], 8) |
|
178 | gp.mode = int(line.rstrip()[-3:], 8) | |
176 | elif line.startswith('GIT binary patch'): |
|
179 | elif line.startswith('GIT binary patch'): | |
177 |
|
|
180 | dopatch |= GP_BINARY | |
178 | dopatch = 'binary' |
|
|||
179 | gp.binary = True |
|
181 | gp.binary = True | |
180 | if gp: |
|
182 | if gp: | |
181 | gitpatches.append(gp) |
|
183 | gitpatches.append(gp) | |
182 |
|
184 | |||
183 | if not gitpatches: |
|
185 | if not gitpatches: | |
184 |
dopatch = |
|
186 | dopatch = GP_PATCH | |
185 |
|
187 | |||
186 | return (dopatch, gitpatches) |
|
188 | return (dopatch, gitpatches) | |
187 |
|
189 | |||
@@ -312,13 +314,14 b' def patch(patchname, ui, strip=1, cwd=No' | |||||
312 |
|
314 | |||
313 | fuzz = False |
|
315 | fuzz = False | |
314 | if dopatch: |
|
316 | if dopatch: | |
315 | if dopatch in ('filter', 'binary'): |
|
317 | filterpatch = dopatch & (GP_FILTER | GP_BINARY) | |
|
318 | if filterpatch: | |||
316 | patchname = dogitpatch(patchname, gitpatches, cwd=cwd) |
|
319 | patchname = dogitpatch(patchname, gitpatches, cwd=cwd) | |
317 | try: |
|
320 | try: | |
318 |
if dopatch |
|
321 | if dopatch & GP_PATCH: | |
319 | fuzz = __patch(patchname) |
|
322 | fuzz = __patch(patchname) | |
320 | finally: |
|
323 | finally: | |
321 |
if |
|
324 | if filterpatch: | |
322 | os.unlink(patchname) |
|
325 | os.unlink(patchname) | |
323 |
|
326 | |||
324 | return fuzz |
|
327 | return fuzz |
@@ -143,3 +143,22 b' hg locate rename2 rename3 rename3-2' | |||||
143 | hg cat rename3 |
|
143 | hg cat rename3 | |
144 | echo |
|
144 | echo | |
145 | hg cat rename3-2 |
|
145 | hg cat rename3-2 | |
|
146 | ||||
|
147 | echo foo > foo | |||
|
148 | hg add foo | |||
|
149 | hg ci -m 'add foo' | |||
|
150 | echo % binary files and regular patch hunks | |||
|
151 | hg import -m binaryregular - <<EOF | |||
|
152 | diff --git a/binary b/binary | |||
|
153 | new file mode 100644 | |||
|
154 | index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 | |||
|
155 | GIT binary patch | |||
|
156 | literal 4 | |||
|
157 | Lc\${NkU|;|M00aO5 | |||
|
158 | ||||
|
159 | diff --git a/foo b/foo2 | |||
|
160 | rename from foo | |||
|
161 | rename to foo2 | |||
|
162 | EOF | |||
|
163 | cat foo2 | |||
|
164 | hg manifest | grep binary |
General Comments 0
You need to be logged in to leave comments.
Login now