Commit 096cb61b authored by Kai Willadsen's avatar Kai Willadsen

meld.vc: Remove cache selection argument to cache updating

parent e466a2bd
......@@ -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):
......
......@@ -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()
......
......@@ -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):
......
......@@ -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):
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment