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