##// END OF EJS Templates
scmutil: convert status data object from a tuple to an attrs (API)...
Augie Fackler -
r44053:c5548b0b default
parent child Browse files
Show More
@@ -27,7 +27,7 b' from .node import ('
27 wdirrev,
27 wdirrev,
28 )
28 )
29 from .pycompat import getattr
29 from .pycompat import getattr
30
30 from .thirdparty import attr
31 from . import (
31 from . import (
32 copies as copiesmod,
32 copies as copiesmod,
33 encoding,
33 encoding,
@@ -62,58 +62,32 b" parsers = policy.importmod('parsers')"
62 termsize = scmplatform.termsize
62 termsize = scmplatform.termsize
63
63
64
64
65 class status(tuple):
65 @attr.s(slots=True, repr=False)
66 '''Named tuple with a list of files per status. The 'deleted', 'unknown'
66 class status(object):
67 and 'ignored' properties are only relevant to the working copy.
67 '''Struct with a list of files per status.
68
69 The 'deleted', 'unknown' and 'ignored' properties are only
70 relevant to the working copy.
68 '''
71 '''
69
72
70 __slots__ = ()
73 modified = attr.ib(default=list)
71
74 added = attr.ib(default=list)
72 def __new__(
75 removed = attr.ib(default=list)
73 cls, modified, added, removed, deleted, unknown, ignored, clean
76 deleted = attr.ib(default=list)
74 ):
77 unknown = attr.ib(default=list)
75 return tuple.__new__(
78 ignored = attr.ib(default=list)
76 cls, (modified, added, removed, deleted, unknown, ignored, clean)
79 clean = attr.ib(default=list)
77 )
78
79 @property
80 def modified(self):
81 '''files that have been modified'''
82 return self[0]
83
84 @property
85 def added(self):
86 '''files that have been added'''
87 return self[1]
88
89 @property
90 def removed(self):
91 '''files that have been removed'''
92 return self[2]
93
80
94 @property
81 def __iter__(self):
95 def deleted(self):
82 yield self.modified
96 '''files that are in the dirstate, but have been deleted from the
83 yield self.added
97 working copy (aka "missing")
84 yield self.removed
98 '''
85 yield self.deleted
99 return self[3]
86 yield self.unknown
100
87 yield self.ignored
101 @property
88 yield self.clean
102 def unknown(self):
103 '''files not in the dirstate that are not ignored'''
104 return self[4]
105
89
106 @property
90 def __repr__(self):
107 def ignored(self):
108 '''files not in the dirstate that are ignored (by _dirignore())'''
109 return self[5]
110
111 @property
112 def clean(self):
113 '''files that have not been modified'''
114 return self[6]
115
116 def __repr__(self, *args, **kwargs):
117 return (
91 return (
118 r'<status modified=%s, added=%s, removed=%s, deleted=%s, '
92 r'<status modified=%s, added=%s, removed=%s, deleted=%s, '
119 r'unknown=%s, ignored=%s, clean=%s>'
93 r'unknown=%s, ignored=%s, clean=%s>'
General Comments 0
You need to be logged in to leave comments. Login now