/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: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Utility functions for managing external merge tools such as kdiff3."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import os
20
22
import shutil
21
23
import subprocess
50
52
        if exe is None:
51
53
            return False
52
54
        base, ext = os.path.splitext(exe)
53
 
        path_ext = [s.lower()
 
55
        path_ext = [unicode(s.lower())
54
56
                    for s in os.getenv('PATHEXT', '').split(os.pathsep)]
55
57
        return os.path.exists(exe) and ext in path_ext
56
58
    else:
57
 
        return (os.access(exe, os.X_OK) or
58
 
                osutils.find_executable_on_path(exe) is not None)
 
59
        return (os.access(exe, os.X_OK)
 
60
                or osutils.find_executable_on_path(exe) is not None)
59
61
 
60
62
 
61
63
def invoke(command_line, filename, invoker=None):
71
73
    if exe is not None:
72
74
        cmd_list[0] = exe
73
75
    args, tmp_file = _subst_filename(cmd_list, filename)
74
 
 
75
76
    def cleanup(retcode):
76
77
        if tmp_file is not None:
77
 
            if retcode == 0:  # on success, replace file with temp file
 
78
            if retcode == 0: # on success, replace file with temp file
78
79
                shutil.move(tmp_file, filename)
79
 
            else:  # otherwise, delete temp file
 
80
            else: # otherwise, delete temp file
80
81
                os.remove(tmp_file)
81
82
    return invoker(args[0], args[1:], cleanup)
82
83
 
97
98
    tmp_file = None
98
99
    subst_args = []
99
100
    for arg in args:
100
 
        if '{this_temp}' in arg and 'this_temp' not in subst_names:
 
101
        if '{this_temp}' in arg and not 'this_temp' in subst_names:
101
102
            fh, tmp_file = tempfile.mkstemp(u"_bzr_mergetools_%s.THIS" %
102
103
                                            os.path.basename(filename))
103
104
            trace.mutter('fh=%r, tmp_file=%r', fh, tmp_file)