Commit f0f6bb47 authored by Kai Willadsen's avatar Kai Willadsen

vc.git: Split remerging logic out for reuse

parent bc802709
......@@ -185,6 +185,19 @@ class Vc(_vc.Vc):
command = [self.CMD, 'add']
runner(command, files, refresh=True, working_dir=self.root)
def remerge_with_ancestor(self, local, base, remote):
args = [self.CMD, "merge-file", "-p", "--diff3", local, base, remote]
process = subprocess.Popen(args, cwd=self.location,
stdout=subprocess.PIPE)
vc_file = StringIO.StringIO(
_vc.base_from_diff3(process.stdout.read()))
prefix = 'meld-tmp-%s-' % _vc.CONFLICT_MERGED
with tempfile.NamedTemporaryFile(prefix=prefix, delete=False) as f:
shutil.copyfileobj(vc_file, f)
return f.name, True
def get_path_for_conflict(self, path, conflict):
if not path.startswith(self.root + os.path.sep):
raise _vc.InvalidVCPath(self, path, "Path not in repository")
......@@ -199,23 +212,14 @@ class Vc(_vc.Vc):
raise _vc.InvalidVCPath(self, path,
"Couldn't access conflict parents")
args = [self.CMD, "merge-file", "-p", "--diff3", local, base,
remote]
process = subprocess.Popen(args, cwd=self.location,
stdout=subprocess.PIPE)
vc_file = StringIO.StringIO(
_vc.base_from_diff3(process.stdout.read()))
prefix = 'meld-tmp-%s-' % _vc.conflicts[conflict]
with tempfile.NamedTemporaryFile(prefix=prefix, delete=False) as f:
shutil.copyfileobj(vc_file, f)
filename, is_temp = self.remerge_with_ancestor(local, base, remote)
for temp_file in (local, base, remote):
if os.name == "nt":
os.chmod(temp_file, stat.S_IWRITE)
os.remove(temp_file)
return f.name, True
return filename, is_temp
path = path[len(self.root) + 1:]
if os.name == "nt":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment