~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mergetools.py

  • Committer: Gordon Tyler
  • Date: 2011-01-21 23:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 5632.
  • Revision ID: gordon@doxxx.net-20110121235115-9sdqamejot1h0481
Replace usage of format function from python 2.6 with our own very simple formatting function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
def _subst_filename(args, filename):
81
81
    subst_names = {
82
 
        u'base': filename + u'.BASE',
83
 
        u'this': filename + u'.THIS',
84
 
        u'other': filename + u'.OTHER',
85
 
        u'result': filename,
 
82
        'base': filename + u'.BASE',
 
83
        'this': filename + u'.THIS',
 
84
        'other': filename + u'.OTHER',
 
85
        'result': filename,
86
86
    }
87
87
    tmp_file = None
88
88
    subst_args = []
89
89
    for arg in args:
90
 
        if u'{this_temp}' in arg and not 'this_temp' in subst_names:
 
90
        if '{this_temp}' in arg and not 'this_temp' in subst_names:
91
91
            fh, tmp_file = tempfile.mkstemp(u"_bzr_mergetools_%s.THIS" %
92
92
                                            os.path.basename(filename))
93
93
            trace.mutter('fh=%r, tmp_file=%r', fh, tmp_file)
94
94
            os.close(fh)
95
95
            shutil.copy(filename + u".THIS", tmp_file)
96
96
            subst_names['this_temp'] = tmp_file
97
 
        arg = arg.format(**subst_names)
 
97
        arg = _format_arg(arg, subst_names)
98
98
        subst_args.append(arg)
99
99
    return subst_args, tmp_file
100
100
 
101
101
 
 
102
# This would be better implemented using format() from python 2.6
 
103
def _format_arg(arg, subst_names):
 
104
    arg = arg.replace('{base}', subst_names['base'])
 
105
    arg = arg.replace('{this}', subst_names['this'])
 
106
    arg = arg.replace('{other}', subst_names['other'])
 
107
    arg = arg.replace('{result}', subst_names['result'])
 
108
    if subst_names.has_key('this_temp'):
 
109
        arg = arg.replace('{this_temp}', subst_names['this_temp'])
 
110
    return arg
 
111
 
 
112
 
102
113
def subprocess_invoker(executable, args, cleanup):
103
114
    retcode = subprocess.call([executable] + args)
104
115
    cleanup(retcode)