[meld/VersionControlRework: 4/123] meld.vc: All remaining VCs are 'cached', for what it's worth
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/VersionControlRework: 4/123] meld.vc: All remaining VCs are 'cached', for what it's worth
- Date: Sun, 19 Apr 2015 20:06:19 +0000 (UTC)
commit b1af7f9b4bd188ef763edde6913b32d68ee634e4
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Mar 21 14:03:44 2015 +1000
meld.vc: All remaining VCs are 'cached', for what it's worth
meld/vc/_vc.py | 36 ++++++++++++------------------------
meld/vc/bzr.py | 2 +-
meld/vc/git.py | 2 +-
meld/vc/mercurial.py | 2 +-
meld/vc/svn.py | 2 +-
5 files changed, 16 insertions(+), 28 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 94740e9..eeb5f60 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -128,6 +128,7 @@ class Vc(object):
self.root, self.location = self.is_in_repo(path)
if not self.root:
raise ValueError
+ self._tree_cache = None
def commit_command(self, message):
raise NotImplementedError()
@@ -201,11 +202,19 @@ class Vc(object):
def get_working_directory(self, workdir):
return workdir
- def cache_inventory(self, topdir):
- pass
+ def cache_inventory(self, directory):
+ self._tree_cache = self._lookup_tree_cache(directory)
def uncache_inventory(self):
- pass
+ self._tree_cache = None
+
+ def _lookup_tree_cache(self, directory):
+ raise NotImplementedError()
+
+ def _get_tree_cache(self, directory):
+ if self._tree_cache is None:
+ self.cache_inventory(directory)
+ return self._tree_cache
def update_file_state(self, path):
""" Update the state of a specific file. For example after a file
@@ -293,27 +302,6 @@ class Vc(object):
raise NotImplementedError
-class CachedVc(Vc):
-
- def __init__(self, location):
- super(CachedVc, self).__init__(location)
- self._tree_cache = None
-
- def cache_inventory(self, directory):
- self._tree_cache = self._lookup_tree_cache(directory)
-
- def uncache_inventory(self):
- self._tree_cache = None
-
- def _lookup_tree_cache(self, directory):
- raise NotImplementedError()
-
- def _get_tree_cache(self, directory):
- if self._tree_cache is None:
- self.cache_inventory(directory)
- return self._tree_cache
-
-
class InvalidVCPath(ValueError):
"""Raised when a VC module is passed an invalid (or not present) path."""
diff --git a/meld/vc/bzr.py b/meld/vc/bzr.py
index f07fc5f..93de89d 100644
--- a/meld/vc/bzr.py
+++ b/meld/vc/bzr.py
@@ -34,7 +34,7 @@ import tempfile
from . import _vc
-class Vc(_vc.CachedVc):
+class Vc(_vc.Vc):
CMD = "bzr"
CMDARGS = ["--no-aliases", "--no-plugins"]
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 23f982e..00c4bc2 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -38,7 +38,7 @@ from meld.conf import _, ngettext
from . import _vc
-class Vc(_vc.CachedVc):
+class Vc(_vc.Vc):
CMD = "git"
NAME = "Git"
diff --git a/meld/vc/mercurial.py b/meld/vc/mercurial.py
index fb839a5..b45e95f 100644
--- a/meld/vc/mercurial.py
+++ b/meld/vc/mercurial.py
@@ -30,7 +30,7 @@ import tempfile
from . import _vc
-class Vc(_vc.CachedVc):
+class Vc(_vc.Vc):
CMD = "hg"
NAME = "Mercurial"
diff --git a/meld/vc/svn.py b/meld/vc/svn.py
index d48ebbf..d639141 100644
--- a/meld/vc/svn.py
+++ b/meld/vc/svn.py
@@ -33,7 +33,7 @@ import subprocess
from . import _vc
-class Vc(_vc.CachedVc):
+class Vc(_vc.Vc):
CMD = "svn"
NAME = "Subversion"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]