Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/simplemerge.py @ 14328:3c65cdcf3ba6 stable
simplemerge: do not allow binary files to abort an entire merge
When used as the default merge tool, or used as a --tool override,
the simplemerge script should not be allowed to raise a util.Abort
just because one of the files being merged is binary. Instead, return
1 and mark the file unresolved.
author | Steve Borho <steve@borho.org> |
---|---|
date | Fri, 13 May 2011 19:46:36 -0500 |
parents | 4cdaf1adafc8 |
children | abaacdab38f6 |
comparison
equal
deleted
inserted
replaced
14275:2a6ee654655e | 14328:3c65cdcf3ba6 |
---|---|
405 f = open(filename, "rb") | 405 f = open(filename, "rb") |
406 text = f.read() | 406 text = f.read() |
407 f.close() | 407 f.close() |
408 if util.binary(text): | 408 if util.binary(text): |
409 msg = _("%s looks like a binary file.") % filename | 409 msg = _("%s looks like a binary file.") % filename |
410 if not opts.get('quiet'): | |
411 ui.warn(_('warning: %s\n') % msg) | |
410 if not opts.get('text'): | 412 if not opts.get('text'): |
411 raise util.Abort(msg) | 413 raise util.Abort(msg) |
412 elif not opts.get('quiet'): | |
413 ui.warn(_('warning: %s\n') % msg) | |
414 return text | 414 return text |
415 | 415 |
416 name_a = local | 416 name_a = local |
417 name_b = other | 417 name_b = other |
418 labels = opts.get('label', []) | 418 labels = opts.get('label', []) |
421 if labels: | 421 if labels: |
422 name_b = labels.pop(0) | 422 name_b = labels.pop(0) |
423 if labels: | 423 if labels: |
424 raise util.Abort(_("can only specify two labels.")) | 424 raise util.Abort(_("can only specify two labels.")) |
425 | 425 |
426 localtext = readfile(local) | 426 try: |
427 basetext = readfile(base) | 427 localtext = readfile(local) |
428 othertext = readfile(other) | 428 basetext = readfile(base) |
429 othertext = readfile(other) | |
430 except util.Abort: | |
431 return 1 | |
429 | 432 |
430 local = os.path.realpath(local) | 433 local = os.path.realpath(local) |
431 if not opts.get('print'): | 434 if not opts.get('print'): |
432 opener = util.opener(os.path.dirname(local)) | 435 opener = util.opener(os.path.dirname(local)) |
433 out = opener(os.path.basename(local), "w", atomictemp=True) | 436 out = opener(os.path.basename(local), "w", atomictemp=True) |