Commit 961deacb authored by Kai Willadsen's avatar Kai Willadsen

vc: Add common _get_dirsandfiles implementation for generalisation

parent dbfcaa43
......@@ -228,7 +228,25 @@ class Vc(object):
return self._get_dirsandfiles(directory, dirs, files)
def _get_dirsandfiles(self, directory, dirs, files):
raise NotImplementedError()
tree = self._get_tree_cache()
retfiles = []
retdirs = []
for name, path in files:
state = tree.get(path, STATE_NORMAL)
meta = self._tree_meta_cache.get(path, "")
retfiles.append(File(path, name, state, options=meta))
for name, path in dirs:
state = tree.get(path, STATE_NORMAL)
retdirs.append(Dir(path, name, state))
for path, state in tree.items():
# removed files are not in the filesystem, so must be added here
if state in (STATE_REMOVED, STATE_MISSING):
folder, name = os.path.split(path)
if folder == directory:
retfiles.append(File(path, name, state))
return retdirs, retfiles
def get_entry(self, path):
"""Return the entry associated with the given path in this VC
......
......@@ -361,24 +361,3 @@ class Vc(_vc.Vc):
for path in unversioned_entries:
self._tree_cache[get_real_path(path)] = _vc.STATE_NONE
def _get_dirsandfiles(self, directory, dirs, files):
tree = self._get_tree_cache()
retfiles = []
retdirs = []
for name, path in files:
state = tree.get(path, _vc.STATE_NORMAL)
meta = self._tree_meta_cache.get(path, "")
retfiles.append(_vc.File(path, name, state, options=meta))
for name, path in dirs:
state = tree.get(path, _vc.STATE_NORMAL)
retdirs.append(_vc.Dir(path, name, state))
for path, state in tree.items():
# removed files are not in the filesystem, so must be added here
if state in (_vc.STATE_REMOVED, _vc.STATE_MISSING):
folder, name = os.path.split(path)
if folder == directory:
retfiles.append(_vc.File(path, name, state))
return retdirs, retfiles
......@@ -121,23 +121,3 @@ class Vc(_vc.Vc):
path = os.path.join(self.location, name.strip())
state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
self._tree_cache[path] = state
def _get_dirsandfiles(self, directory, dirs, files):
tree = self._get_tree_cache()
retfiles = []
retdirs = []
for name, path in files:
state = tree.get(path, _vc.STATE_NORMAL)
retfiles.append(_vc.File(path, name, state))
for name, path in dirs:
# mercurial does not operate on dirs, just files
retdirs.append(_vc.Dir(path, name, _vc.STATE_NORMAL))
for path, state in tree.items():
# removed files are not in the filesystem, so must be added here
if state in (_vc.STATE_REMOVED, _vc.STATE_MISSING):
folder, name = os.path.split(path)
if folder == directory:
retfiles.append(_vc.File(path, name, state))
return retdirs, retfiles
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