[meld/VersionControlRework: 63/123] vc._vc: Unify the file and directory state updating



commit 35294bafd3332d990343500bff53d74f15575d3f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Mar 29 13:27:49 2015 +1000

    vc._vc: Unify the file and directory state updating

 meld/vc/_vc.py |   19 ++++++++++---------
 meld/vcview.py |    4 ++--
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 54df5aa..b02dee3 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -186,18 +186,19 @@ class Vc(object):
     def get_working_directory(self, workdir):
         return workdir
 
-    def refresh_files(self):
-        self._tree_cache = {}
-        self._update_tree_state_cache("./")
+    def refresh_vc_state(self, path=None):
+        """Update cached version control state
 
-    def update_file_state(self, path):
-        """Update the cached version control state of the given path.
+        If a path is provided, for example when a file has been modified
+        and saved in the file comparison view and needs its state
+        refreshed, then only that path will be updated.
 
-        After a file has been modified and saved, for example by
-        editing in the file comparison view, its state may be out of
-        date and require updating. The method updates the version
-        control object's internal cache of file state.
+        If no path is provided then the version control tree rooted at
+        its `location` will be recursively refreshed.
         """
+        if path is None:
+            self._tree_cache = {}
+            path = './'
         self._update_tree_state_cache(path)
 
     def get_entries(self, base):
diff --git a/meld/vcview.py b/meld/vcview.py
index d5158a5..9d7c07d 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -391,7 +391,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         except NotImplementedError:
             pass
 
-        self.scheduler.add_task(self.vc.refresh_files)
+        self.scheduler.add_task(self.vc.refresh_vc_state)
         self.scheduler.add_task(self._search_recursively_iter(root))
         self.scheduler.add_task(self.on_treeview_selection_changed)
         self.scheduler.add_task(self.on_treeview_cursor_changed)
@@ -820,7 +820,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         it = self.find_iter_by_name(filename)
         if it:
             path = self.model.value_path(it, 0)
-            self.vc.update_file_state(path)
+            self.vc.refresh_vc_state(path)
             entry = self.vc.get_entry(path)
             prefixlen = 1 + len(self.model.value_path(self.model.get_iter_first(), 0))
             self._update_item_state(it, entry, entry.parent[prefixlen:])


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