/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/mergetools.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
)
34
34
""")
35
35
 
36
 
from .sixish import text_type
37
 
 
38
36
 
39
37
known_merge_tools = {
40
38
    'bcompare': 'bcompare {this} {other} {base} {result}',
58
56
                    for s in os.getenv('PATHEXT', '').split(os.pathsep)]
59
57
        return os.path.exists(exe) and ext in path_ext
60
58
    else:
61
 
        return (os.access(exe, os.X_OK)
62
 
                or osutils.find_executable_on_path(exe) is not None)
 
59
        return (os.access(exe, os.X_OK) or
 
60
                osutils.find_executable_on_path(exe) is not None)
63
61
 
64
62
 
65
63
def invoke(command_line, filename, invoker=None):
75
73
    if exe is not None:
76
74
        cmd_list[0] = exe
77
75
    args, tmp_file = _subst_filename(cmd_list, filename)
 
76
 
78
77
    def cleanup(retcode):
79
78
        if tmp_file is not None:
80
 
            if retcode == 0: # on success, replace file with temp file
 
79
            if retcode == 0:  # on success, replace file with temp file
81
80
                shutil.move(tmp_file, filename)
82
 
            else: # otherwise, delete temp file
 
81
            else:  # otherwise, delete temp file
83
82
                os.remove(tmp_file)
84
83
    return invoker(args[0], args[1:], cleanup)
85
84
 
100
99
    tmp_file = None
101
100
    subst_args = []
102
101
    for arg in args:
103
 
        if '{this_temp}' in arg and not 'this_temp' in subst_names:
 
102
        if '{this_temp}' in arg and 'this_temp' not in subst_names:
104
103
            fh, tmp_file = tempfile.mkstemp(u"_bzr_mergetools_%s.THIS" %
105
104
                                            os.path.basename(filename))
106
105
            trace.mutter('fh=%r, tmp_file=%r', fh, tmp_file)