[meld] vc.git: Split remerging logic out for reuse
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] vc.git: Split remerging logic out for reuse
- Date: Sun, 4 Oct 2015 03:06:01 +0000 (UTC)
commit f0f6bb4730059812d3174a89182f9ff53385e730
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Jul 23 06:26:20 2013 +1000
vc.git: Split remerging logic out for reuse
meld/vc/git.py | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 4aad25f..2754e2f 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -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":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]