[meld] svn: Update a file's status after its been modified



commit 68f0a967ea5828a472fbb8cbba047e1e60afeef3
Author: Peter Tyser <ptyser gmail com>
Date:   Sun Jan 16 15:34:53 2011 -0600

    svn: Update a file's status after its been modified
    
    This commit is very similar to 15dadb2bbc0c0da116fdd6e920306268f1cf37d5,
    but resolves the bug for subversion which was recently modified to use
    CachedVC.
    
    Previously, a VcView diff of a subversion-controlled directory could
    easily become out of date.  For example, if the file 'AUTHORS' was a
    version controlled file in a svn repository:
      > echo "asdf" >> AUTHORS
      > meld ./
      # Double click on the AUTHORS file to view its diff.
      # Save the AUTHORS file.  This will cause meld to cache its current
        state (modified).
      # Remove the "asdf" at the bottom of the file and save it.
      # Close the AUTHORS tab.
      # The state of the AUTHORS file will still show up as modified, even
        though it is now unmodified.
    
    Signed-off-by: Peter Tyser <ptyser gmail com>

 meld/vc/svn.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/meld/vc/svn.py b/meld/vc/svn.py
index a3d7b01..2ebbc48 100644
--- a/meld/vc/svn.py
+++ b/meld/vc/svn.py
@@ -73,18 +73,16 @@ class Vc(_vc.CachedVc):
     def switch_to_external_diff(self):
         self.external_diff = "diff"
 
-    def _lookup_tree_cache(self, rootdir):
+    def _update_tree_state_cache(self, path, tree_state):
         while 1:
             try:
-                status_cmd = [self.CMD, "status", "-v", "--xml", rootdir]
+                status_cmd = [self.CMD, "status", "-v", "--xml", path]
                 tree = ElementTree.parse(_vc.popen(status_cmd))
                 break
             except OSError, e:
                 if e.errno != errno.EAGAIN:
                     raise
 
-        tree_state = {}
-
         for target in tree.findall("target"):
             for entry in (t for t in target.getchildren() if t.tag == "entry"):
                 path = entry.attrib["path"]
@@ -103,8 +101,16 @@ class Vc(_vc.CachedVc):
                         tree_state[mydir] = {}
                     tree_state[mydir][name] = (item, rev)
 
+    def _lookup_tree_cache(self, rootdir):
+        # Get a list of all files in rootdir, as well as their status
+        tree_state = {}
+        self._update_tree_state_cache(rootdir, tree_state)
         return tree_state
 
+    def update_file_state(self, path):
+        tree_state = self._get_tree_cache(os.path.dirname(path))
+        self._update_tree_state_cache(path, tree_state)
+
     def _get_dirsandfiles(self, directory, dirs, files):
         tree = self._get_tree_cache(directory)
 



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