[meld] Add is_temp return to 'get_path_for_conflict' for non-temporary files



commit fa2098d8d43244dbc6141b12db343073a80997f7
Author: Psykar <psyker7 gmail com>
Date:   Tue Mar 26 22:52:06 2013 +1100

    Add is_temp return to 'get_path_for_conflict' for non-temporary files
    
    Depending on the VC, we sometimes create new temporary files using
    direct VC calls, and sometimes reuse existing files from the conflict.
    This patch adds an boolean return to get_path_from_conflict to
    indicate whether the returned file is temporary and should be cleaned
    up, or whether we should leave it alone.

 meld/vc/bzr.py |    3 ++-
 meld/vc/git.py |    5 +++--
 meld/vcview.py |    4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/meld/vc/bzr.py b/meld/vc/bzr.py
index 7cef538..8350204 100644
--- a/meld/vc/bzr.py
+++ b/meld/vc/bzr.py
@@ -180,4 +180,5 @@ class Vc(_vc.CachedVc):
         if not path.startswith(self.root + os.path.sep):
             raise _vc.InvalidVCPath(self, path, "Path not in repository")
 
-        return "%s%s" % (path, self.conflict_map[conflict])
+        # bzr paths are all temporary files
+        return "%s%s" % (path, self.conflict_map[conflict]), False
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 610b3da..98e9bfb 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -94,7 +94,8 @@ class Vc(_vc.CachedVc):
 
         if conflict == _vc.CONFLICT_MERGED:
             # Special case: no way to get merged result from git directly
-            return path
+            return path, False
+
         path = path[len(self.root) + 1:]
 
         args = ["git", "show", ":%s:%s" % (self.conflict_map[conflict], path)]
@@ -110,7 +111,7 @@ class Vc(_vc.CachedVc):
                                 prefix='meld-tmp-%s-' % _vc.conflicts[conflict],
                                 delete=False) as f:
             shutil.copyfileobj(vc_file, f)
-        return f.name
+        return f.name, True
 
     def get_path_for_repo_file(self, path, commit=None):
         if commit is None:
diff --git a/meld/vcview.py b/meld/vcview.py
index cdb1a5d..762181a 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -481,9 +481,9 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                     diffs = [self.vc.get_path_for_conflict(path, conflict=c)
                              for c in conflicts]
 
-                    for conflict_path in diffs:
+                    for conflict_path, is_temp in diffs:
                         # If this is the actual file, don't touch it.
-                        if conflict_path != path:
+                        if conflict_path != path and is_temp:
                             os.chmod(conflict_path, 0o444)
                             _temp_files.append(conflict_path)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]