[meld/VersionControlRework: 38/123] meld.vc: Remove Dir and File subclasses, and use Entry everywhere
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/VersionControlRework: 38/123] meld.vc: Remove Dir and File subclasses, and use Entry everywhere
- Date: Sun, 19 Apr 2015 20:09:11 +0000 (UTC)
commit e0aa6c3ed14060d4efbcb6aaa6ca2e4f9c722da6
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Mar 22 14:16:16 2015 +1000
meld.vc: Remove Dir and File subclasses, and use Entry everywhere
meld/vc/_null.py | 8 ++++++--
meld/vc/_vc.py | 26 +++++---------------------
2 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/meld/vc/_null.py b/meld/vc/_null.py
index 8dc5672..eb31da9 100644
--- a/meld/vc/_null.py
+++ b/meld/vc/_null.py
@@ -35,8 +35,12 @@ class Vc(_vc.Vc):
VC_DIR = "."
def lookup_files(self, dirs, files, directory=None):
- dirs = [_vc.Dir(d[1], d[0], _vc.STATE_NONE) for d in dirs]
- files = [_vc.File(f[1], f[0], _vc.STATE_NONE) for f in files]
+ dirs = [
+ _vc.Entry(path, name, _vc.STATE_NONE, isdir=True)
+ for name, path in dirs]
+ files = [
+ _vc.Entry(path, name, _vc.STATE_NONE, isdir=False)
+ for name, path in files]
return dirs, files
def get_path_for_repo_file(self, path, commit=None):
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index f894d6b..08e7124 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -77,10 +77,11 @@ class Entry(object):
STATE_NONEXIST: _("Not present"),
}
- def __init__(self, path, name, state, options=None):
+ def __init__(self, path, name, state, isdir, options=None):
self.path = path
self.state = state
self.parent, self.name = os.path.split(path.rstrip("/"))
+ self.isdir = isdir
self.options = options
def __str__(self):
@@ -94,21 +95,6 @@ class Entry(object):
def get_status(self):
return self.state_names[self.state]
- @staticmethod
- def make_entry(path, name, state, isdir, options=None):
- if isdir:
- return Dir(path, name, state, options)
- else:
- return File(path, name, state, options)
-
-
-class Dir(Entry):
- isdir = True
-
-
-class File(Entry):
- isdir = False
-
class Vc(object):
@@ -243,7 +229,7 @@ class Vc(object):
meta = self._tree_meta_cache.get(path, "")
if isinstance(meta, list):
meta = ','.join(meta)
- return Entry.make_entry(path, name, state, isdir, options=meta)
+ return Entry(path, name, state, isdir, options=meta)
retfiles = [make_entry(name, path, False) for name, path in files]
retdirs = [make_entry(name, path, True) for name, path in dirs]
@@ -253,10 +239,8 @@ class Vc(object):
if state in (STATE_REMOVED, STATE_MISSING):
folder, name = os.path.split(path)
if folder == base:
- meta = self._tree_meta_cache.get(path, "")
- if isinstance(meta, list):
- meta = ','.join(meta)
- retfiles.append(File(path, name, state, options=meta))
+ retfiles.append(make_entry(name, path, False))
+
return retdirs, retfiles
def get_entry(self, path):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]