[meld/VersionControlRework: 23/123] meld.vc: Remove cache selection argument to cache updating



commit 096cb61b58624b6d4f9f0da882bc3a97f50c8637
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Mar 22 08:13:10 2015 +1000

    meld.vc: Remove cache selection argument to cache updating

 meld/vc/_vc.py       |    2 +-
 meld/vc/bzr.py       |    5 +++--
 meld/vc/git.py       |   23 +++++++++++------------
 meld/vc/mercurial.py |   19 +++++++++----------
 meld/vc/svn.py       |   11 +++++------
 5 files changed, 29 insertions(+), 31 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index c8b87b6..d6ab453 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -194,7 +194,7 @@ class Vc(object):
 
     def _get_tree_cache(self):
         if not self._tree_cache:
-            self._update_tree_state_cache("./", self._tree_cache)
+            self._update_tree_state_cache("./")
         return self._tree_cache
 
     def update_file_state(self, path):
diff --git a/meld/vc/bzr.py b/meld/vc/bzr.py
index 22b0936..d709c27 100644
--- a/meld/vc/bzr.py
+++ b/meld/vc/bzr.py
@@ -147,7 +147,7 @@ class Vc(_vc.Vc):
                 files.append(os.path.relpath(p, self.root))
         return sorted(list(set(files)))
 
-    def _update_tree_state_cache(self, path, tree_state):
+    def _update_tree_state_cache(self, path):
         # FIXME: This actually clears out state information, because the
         # current API doesn't have any state outside of _tree_cache.
         branch_root = _vc.popen(
@@ -219,7 +219,8 @@ class Vc(_vc.Vc):
                 del tree_meta_cache[old]
             self._reverse_rename_cache[new] = old
 
-        tree_state.update(dict((x, max(y)) for x, y in tree_cache.items()))
+        self._tree_cache.update(
+            dict((x, max(y)) for x, y in tree_cache.items()))
 
     def _get_dirsandfiles(self, directory, dirs, files):
         tree = self._get_tree_cache()
diff --git a/meld/vc/git.py b/meld/vc/git.py
index b429e41..1dc0d6f 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -303,8 +303,8 @@ class Vc(_vc.Vc):
 
         return entries
 
-    def _update_tree_state_cache(self, path, tree_state):
-        """ Update the state of the file(s) at tree_state['path'] """
+    def _update_tree_state_cache(self, path):
+        """ Update the state of the file(s) at self._tree_cache['path'] """
         while 1:
             try:
                 entries = self._get_modified_files(path)
@@ -343,32 +343,31 @@ class Vc(_vc.Vc):
 
         if len(entries) == 0 and os.path.isfile(path):
             # If we're just updating a single file there's a chance that it
-            # was it was previously modified, and now has been edited
-            # so that it is un-modified.  This will result in an empty
-            # 'entries' list, and tree_state['path'] will still contain stale
-            # data.  When this corner case occurs we force tree_state['path']
+            # was it was previously modified, and now has been edited so that
+            # it is un-modified.  This will result in an empty 'entries' list,
+            # and self._tree_cache['path'] will still contain stale data.
+            # When this corner case occurs we force self._tree_cache['path']
             # to STATE_NORMAL.
-            tree_state[get_real_path(path)] = _vc.STATE_NORMAL
+            self._tree_cache[get_real_path(path)] = _vc.STATE_NORMAL
         else:
             for entry in entries:
                 columns = self.DIFF_RE.search(entry).groups()
                 old_mode, new_mode, statekey, path = columns
                 state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
-                tree_state[get_real_path(path)] = state
+                self._tree_cache[get_real_path(path)] = state
                 if old_mode != new_mode:
                     msg = _("Mode changed from %s to %s" %
                             (old_mode, new_mode))
                     self._tree_meta_cache[path] = msg
 
             for path in ignored_entries:
-                tree_state[get_real_path(path)] = _vc.STATE_IGNORED
+                self._tree_cache[get_real_path(path)] = _vc.STATE_IGNORED
 
             for path in unversioned_entries:
-                tree_state[get_real_path(path)] = _vc.STATE_NONE
+                self._tree_cache[get_real_path(path)] = _vc.STATE_NONE
 
     def update_file_state(self, path):
-        tree_state = self._get_tree_cache()
-        self._update_tree_state_cache(path, tree_state)
+        self._update_tree_state_cache(path)
 
     def _get_dirsandfiles(self, directory, dirs, files):
 
diff --git a/meld/vc/mercurial.py b/meld/vc/mercurial.py
index 529729c..f8ede30 100644
--- a/meld/vc/mercurial.py
+++ b/meld/vc/mercurial.py
@@ -88,8 +88,8 @@ class Vc(_vc.Vc):
             shutil.copyfileobj(process.stdout, f)
         return f.name
 
-    def _update_tree_state_cache(self, path, tree_state):
-        """ Update the state of the file(s) at tree_state['path'] """
+    def _update_tree_state_cache(self, path):
+        """ Update the state of the file(s) at self._tree_cache['path'] """
         while 1:
             try:
                 # Get the status of modified files
@@ -107,12 +107,12 @@ class Vc(_vc.Vc):
 
         if len(entries) == 0 and os.path.isfile(path):
             # If we're just updating a single file there's a chance that it
-            # was it was previously modified, and now has been edited
-            # so that it is un-modified.  This will result in an empty
-            # 'entries' list, and tree_state['path'] will still contain stale
-            # data.  When this corner case occurs we force tree_state['path']
+            # was it was previously modified, and now has been edited so that
+            # it is un-modified.  This will result in an empty 'entries' list,
+            # and self._tree_cache['path'] will still contain stale data.
+            # When this corner case occurs we force self._tree_cache['path']
             # to STATE_NORMAL.
-            tree_state[path] = _vc.STATE_NORMAL
+            self._tree_cache[path] = _vc.STATE_NORMAL
         else:
             # There are 1 or more modified files, parse their state
             for entry in entries:
@@ -120,11 +120,10 @@ class Vc(_vc.Vc):
                 statekey, name = entry.split(" ", 1)
                 path = os.path.join(self.location, name.strip())
                 state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
-                tree_state[path] = state
+                self._tree_cache[path] = state
 
     def update_file_state(self, path):
-        tree_state = self._get_tree_cache()
-        self._update_tree_state_cache(path, tree_state)
+        self._update_tree_state_cache(path)
 
     def _get_dirsandfiles(self, directory, dirs, files):
 
diff --git a/meld/vc/svn.py b/meld/vc/svn.py
index 37e1d63..bb31189 100644
--- a/meld/vc/svn.py
+++ b/meld/vc/svn.py
@@ -182,7 +182,7 @@ class Vc(_vc.Vc):
 
         return cls._repo_version_support(repo_version)
 
-    def _update_tree_state_cache(self, path, tree_state):
+    def _update_tree_state_cache(self, path):
         while 1:
             try:
                 proc = _vc.popen(
@@ -212,13 +212,12 @@ class Vc(_vc.Vc):
                     if "revision" in status.attrib:
                         rev = status.attrib["revision"]
                     mydir, name = os.path.split(path)
-                    if mydir not in tree_state:
-                        tree_state[mydir] = {}
-                    tree_state[mydir][name] = (item, rev)
+                    if mydir not in self._tree_cache:
+                        self._tree_cache[mydir] = {}
+                    self._tree_cache[mydir][name] = (item, rev)
 
     def update_file_state(self, path):
-        tree_state = self._get_tree_cache()
-        self._update_tree_state_cache(path, tree_state)
+        self._update_tree_state_cache(path)
 
     def _get_dirsandfiles(self, directory, dirs, files):
         tree = self._get_tree_cache()


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