##// END OF EJS Templates
changelog: use attrs instead of namedtuple...
Siddharth Agarwal -
r34399:e51c8ffa default
parent child Browse files
Show More
@@ -7,14 +7,15 b''
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import collections
11
12 from .i18n import _
10 from .i18n import _
13 from .node import (
11 from .node import (
14 bin,
12 bin,
15 hex,
13 hex,
16 nullid,
14 nullid,
17 )
15 )
16 from .thirdparty import (
17 attr,
18 )
18
19
19 from . import (
20 from . import (
20 encoding,
21 encoding,
@@ -142,10 +143,16 b' def _delayopener(opener, target, buf):'
142 return appender(opener, name, mode, buf)
143 return appender(opener, name, mode, buf)
143 return _delay
144 return _delay
144
145
145 _changelogrevision = collections.namedtuple(u'changelogrevision',
146 @attr.s
146 (u'manifest', u'user', u'date',
147 class _changelogrevision(object):
147 u'files', u'description',
148 # Extensions might modify _defaultextra, so let the constructor below pass
148 u'extra'))
149 # it in
150 extra = attr.ib()
151 manifest = attr.ib(default=nullid)
152 user = attr.ib(default='')
153 date = attr.ib(default=(0, 0))
154 files = attr.ib(default=[])
155 description = attr.ib(default='')
149
156
150 class changelogrevision(object):
157 class changelogrevision(object):
151 """Holds results of a parsed changelog revision.
158 """Holds results of a parsed changelog revision.
@@ -162,14 +169,7 b' class changelogrevision(object):'
162
169
163 def __new__(cls, text):
170 def __new__(cls, text):
164 if not text:
171 if not text:
165 return _changelogrevision(
172 return _changelogrevision(extra=_defaultextra)
166 manifest=nullid,
167 user='',
168 date=(0, 0),
169 files=[],
170 description='',
171 extra=_defaultextra,
172 )
173
173
174 self = super(changelogrevision, cls).__new__(cls)
174 self = super(changelogrevision, cls).__new__(cls)
175 # We could return here and implement the following as an __init__.
175 # We could return here and implement the following as an __init__.
General Comments 0
You need to be logged in to leave comments. Login now