Commit 22309de5 authored by Kai Willadsen's avatar Kai Willadsen

meld.vc: Fix caching API to disallow inadventantly discarding data

The caching API that VCs needed to implement suggested that it would be
fine to try and cache a subdirectory independently. This never worked.

Now you can only call cache without args, and it will (shoudl) always
cache the location under the VC. Updating the cache is left for other
methods.
parent df658ae0
...@@ -197,7 +197,7 @@ class Vc(object): ...@@ -197,7 +197,7 @@ class Vc(object):
def _get_tree_cache(self, directory): def _get_tree_cache(self, directory):
if not self._tree_cache: if not self._tree_cache:
self._tree_cache = self.cache_tree(directory) self._tree_cache = self.cache_tree()
return self._tree_cache return self._tree_cache
def update_file_state(self, path): def update_file_state(self, path):
......
...@@ -142,7 +142,7 @@ class Vc(_vc.Vc): ...@@ -142,7 +142,7 @@ class Vc(_vc.Vc):
if os.path.isdir(p): if os.path.isdir(p):
# FIXME: This used to be self._lookup_files(p), which # FIXME: This used to be self._lookup_files(p), which
# definitely didn't do what we wanted. # definitely didn't do what we wanted.
entries = self.cache_tree(p) entries = self.cache_tree()
names = [ names = [
x for x, y in entries.items() if y in self.commit_statuses] x for x, y in entries.items() if y in self.commit_statuses]
files.extend(names) files.extend(names)
...@@ -150,9 +150,10 @@ class Vc(_vc.Vc): ...@@ -150,9 +150,10 @@ class Vc(_vc.Vc):
files.append(os.path.relpath(p, self.root)) files.append(os.path.relpath(p, self.root))
return sorted(list(set(files))) return sorted(list(set(files)))
def cache_tree(self, rootdir): def cache_tree(self):
branch_root = _vc.popen( branch_root = _vc.popen(
[self.CMD] + self.CMDARGS + ["root", rootdir]).read().rstrip('\n') [self.CMD] + self.CMDARGS + ["root", "./"],
cwd=self.location).read().rstrip('\n')
entries = [] entries = []
while 1: while 1:
try: try:
......
...@@ -367,8 +367,7 @@ class Vc(_vc.Vc): ...@@ -367,8 +367,7 @@ class Vc(_vc.Vc):
for path in unversioned_entries: for path in unversioned_entries:
tree_state[get_real_path(path)] = _vc.STATE_NONE tree_state[get_real_path(path)] = _vc.STATE_NONE
def cache_tree(self, rootdir): def cache_tree(self):
# Get a list of all files in rootdir, as well as their status
tree_state = {} tree_state = {}
self._update_tree_state_cache("./", tree_state) self._update_tree_state_cache("./", tree_state)
return tree_state return tree_state
......
...@@ -122,11 +122,9 @@ class Vc(_vc.Vc): ...@@ -122,11 +122,9 @@ class Vc(_vc.Vc):
state = self.state_map.get(statekey.strip(), _vc.STATE_NONE) state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
tree_state[path] = state tree_state[path] = state
def cache_tree(self, rootdir): def cache_tree(self):
# Get a list of all files in rootdir, as well as their status
tree_state = {} tree_state = {}
self._update_tree_state_cache("./", tree_state) self._update_tree_state_cache("./", tree_state)
return tree_state return tree_state
def update_file_state(self, path): def update_file_state(self, path):
......
...@@ -185,8 +185,10 @@ class Vc(_vc.Vc): ...@@ -185,8 +185,10 @@ class Vc(_vc.Vc):
def _update_tree_state_cache(self, path, tree_state): def _update_tree_state_cache(self, path, tree_state):
while 1: while 1:
try: try:
status_cmd = [self.CMD, "status", "-v", "--xml", path] proc = _vc.popen(
tree = ElementTree.parse(_vc.popen(status_cmd)) [self.CMD, "status", "-v", "--xml", path],
cwd=self.location)
tree = ElementTree.parse(proc)
break break
except OSError as e: except OSError as e:
if e.errno != errno.EAGAIN: if e.errno != errno.EAGAIN:
...@@ -214,10 +216,9 @@ class Vc(_vc.Vc): ...@@ -214,10 +216,9 @@ class Vc(_vc.Vc):
tree_state[mydir] = {} tree_state[mydir] = {}
tree_state[mydir][name] = (item, rev) tree_state[mydir][name] = (item, rev)
def cache_tree(self, rootdir): def cache_tree(self):
# Get a list of all files in rootdir, as well as their status
tree_state = {} tree_state = {}
self._update_tree_state_cache(rootdir, tree_state) self._update_tree_state_cache('./', tree_state)
return tree_state return tree_state
def update_file_state(self, path): def update_file_state(self, path):
......
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