80
80
def _subst_filename(args, filename):
82
u'base': filename + u'.BASE',
83
u'this': filename + u'.THIS',
84
u'other': filename + u'.OTHER',
82
'base': filename + u'.BASE',
83
'this': filename + u'.THIS',
84
'other': filename + u'.OTHER',
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)
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
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'])
102
113
def subprocess_invoker(executable, args, cleanup):
103
114
retcode = subprocess.call([executable] + args)