[meld/VersionControlRework: 118/123] vcview, vc._vc: Move Entry filtering logic to a more suitable place
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/VersionControlRework: 118/123] vcview, vc._vc: Move Entry filtering logic to a more suitable place
- Date: Sun, 19 Apr 2015 20:15:55 +0000 (UTC)
commit 1c58f30b48c97be861a01760b568bd0754a46c31
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Apr 19 07:35:34 2015 +1000
vcview, vc._vc: Move Entry filtering logic to a more suitable place
meld/vc/_vc.py | 30 +++++++++++++++++-------------
meld/vcview.py | 17 +++++------------
2 files changed, 22 insertions(+), 25 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 24476e3..1f48d4c 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -101,19 +101,23 @@ class Entry(object):
"""Should this Entry actually be present on the file system"""
return self.state not in (STATE_REMOVED, STATE_MISSING)
- def is_modified(self):
- return self.state >= STATE_NEW or (
- self.isdir and (self.state > STATE_NONE))
-
- def is_normal(self):
- return self.state == STATE_NORMAL
-
- def is_nonvc(self):
- return self.state == STATE_NONE or (
- self.isdir and (self.state > STATE_IGNORED))
-
- def is_ignored(self):
- return self.state == STATE_IGNORED or self.isdir
+ @staticmethod
+ def is_modified(entry):
+ return entry.state >= STATE_NEW or (
+ entry.isdir and (entry.state > STATE_NONE))
+
+ @staticmethod
+ def is_normal(entry):
+ return entry.state == STATE_NORMAL
+
+ @staticmethod
+ def is_nonvc(entry):
+ return entry.state == STATE_NONE or (
+ entry.isdir and (entry.state > STATE_IGNORED))
+
+ @staticmethod
+ def is_ignored(entry):
+ return entry.state == STATE_IGNORED or entry.isdir
class Vc(object):
diff --git a/meld/vcview.py b/meld/vcview.py
index 71ae3f9..ebeb35b 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -38,6 +38,7 @@ from . import misc
from . import recent
from . import tree
from . import vc
+from meld.vc._vc import Entry
from .ui import gnomeglade
from .ui import vcdialogs
@@ -117,14 +118,6 @@ class VcTreeStore(tree.DiffTreeStore):
def __init__(self):
tree.DiffTreeStore.__init__(self, 1, [str] * 5)
-################################################################################
-# filters
-################################################################################
-entry_modified = lambda x: (x.state >= tree.STATE_NEW) or (x.isdir and (x.state > tree.STATE_NONE))
-entry_normal = lambda x: (x.state == tree.STATE_NORMAL)
-entry_nonvc = lambda x: (x.state == tree.STATE_NONE) or (x.isdir and (x.state > tree.STATE_IGNORED))
-entry_ignored = lambda x: (x.state == tree.STATE_IGNORED) or x.isdir
-
class VcView(melddoc.MeldDoc, gnomeglade.Component):
@@ -151,10 +144,10 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
state_actions = {
"flatten": ("VcFlatten", None),
- "modified": ("VcShowModified", entry_modified),
- "normal": ("VcShowNormal", entry_normal),
- "unknown": ("VcShowNonVC", entry_nonvc),
- "ignored": ("VcShowIgnored", entry_ignored),
+ "modified": ("VcShowModified", Entry.is_modified),
+ "normal": ("VcShowNormal", Entry.is_normal),
+ "unknown": ("VcShowNonVC", Entry.is_nonvc),
+ "ignored": ("VcShowIgnored", Entry.is_ignored),
}
def __init__(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]