Show More
@@ -152,6 +152,29 b' def snapshot(ui, repo, files, node, tmpr' | |||||
152 | fnsandstat.append((dest, repo.wjoin(fn), os.lstat(dest))) |
|
152 | fnsandstat.append((dest, repo.wjoin(fn), os.lstat(dest))) | |
153 | return dirname, fnsandstat |
|
153 | return dirname, fnsandstat | |
154 |
|
154 | |||
|
155 | def formatcmdline(cmdline, repo_root, do3way, | |||
|
156 | parent1, plabel1, parent2, plabel2, child, clabel): | |||
|
157 | # Function to quote file/dir names in the argument string. | |||
|
158 | # When not operating in 3-way mode, an empty string is | |||
|
159 | # returned for parent2 | |||
|
160 | replace = {'parent': parent1, 'parent1': parent1, 'parent2': parent2, | |||
|
161 | 'plabel1': plabel1, 'plabel2': plabel2, | |||
|
162 | 'child': child, 'clabel': clabel, | |||
|
163 | 'root': repo_root} | |||
|
164 | def quote(match): | |||
|
165 | pre = match.group(2) | |||
|
166 | key = match.group(3) | |||
|
167 | if not do3way and key == 'parent2': | |||
|
168 | return pre | |||
|
169 | return pre + procutil.shellquote(replace[key]) | |||
|
170 | ||||
|
171 | # Match parent2 first, so 'parent1?' will match both parent1 and parent | |||
|
172 | regex = (br'''(['"]?)([^\s'"$]*)''' | |||
|
173 | br'\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1') | |||
|
174 | if not do3way and not re.search(regex, cmdline): | |||
|
175 | cmdline += ' $parent1 $child' | |||
|
176 | return re.sub(regex, quote, cmdline) | |||
|
177 | ||||
155 | def dodiff(ui, repo, cmdline, pats, opts): |
|
178 | def dodiff(ui, repo, cmdline, pats, opts): | |
156 | '''Do the actual diff: |
|
179 | '''Do the actual diff: | |
157 |
|
180 | |||
@@ -281,28 +304,14 b' def dodiff(ui, repo, cmdline, pats, opts' | |||||
281 | label1b = None |
|
304 | label1b = None | |
282 | fnsandstat = [] |
|
305 | fnsandstat = [] | |
283 |
|
306 | |||
284 | # Function to quote file/dir names in the argument string. |
|
307 | # Run the external tool on the 2 temp directories or the patches | |
285 | # When not operating in 3-way mode, an empty string is |
|
308 | cmdline = formatcmdline( | |
286 | # returned for parent2 |
|
309 | cmdline, repo.root, do3way=do3way, | |
287 | replace = {'parent': dir1a, 'parent1': dir1a, 'parent2': dir1b, |
|
310 | parent1=dir1a, plabel1=label1a, | |
288 |
|
|
311 | parent2=dir1b, plabel2=label1b, | |
289 | 'clabel': label2, 'child': dir2, |
|
312 | child=dir2, clabel=label2) | |
290 | 'root': repo.root} |
|
313 | ui.debug('running %r in %s\n' % (pycompat.bytestr(cmdline), | |
291 | def quote(match): |
|
314 | tmproot)) | |
292 | pre = match.group(2) |
|
|||
293 | key = match.group(3) |
|
|||
294 | if not do3way and key == 'parent2': |
|
|||
295 | return pre |
|
|||
296 | return pre + procutil.shellquote(replace[key]) |
|
|||
297 |
|
||||
298 | # Match parent2 first, so 'parent1?' will match both parent1 and parent |
|
|||
299 | regex = (br'''(['"]?)([^\s'"$]*)''' |
|
|||
300 | br'\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1') |
|
|||
301 | if not do3way and not re.search(regex, cmdline): |
|
|||
302 | cmdline += ' $parent1 $child' |
|
|||
303 | cmdline = re.sub(regex, quote, cmdline) |
|
|||
304 |
|
||||
305 | ui.debug('running %r in %s\n' % (pycompat.bytestr(cmdline), tmproot)) |
|
|||
306 | ui.system(cmdline, cwd=tmproot, blockedtag='extdiff') |
|
315 | ui.system(cmdline, cwd=tmproot, blockedtag='extdiff') | |
307 |
|
316 | |||
308 | for copy_fn, working_fn, st in fnsandstat: |
|
317 | for copy_fn, working_fn, st in fnsandstat: |
General Comments 0
You need to be logged in to leave comments.
Login now