mercurial/changelog.py
changeset 48946 642e31cb55f0
parent 48875 6000f5b25c9b
child 50316 87f0155d68aa
equal deleted inserted replaced
48945:55d132525155 48946:642e31cb55f0
    89 def stripdesc(desc):
    89 def stripdesc(desc):
    90     """strip trailing whitespace and leading and trailing empty lines"""
    90     """strip trailing whitespace and leading and trailing empty lines"""
    91     return b'\n'.join([l.rstrip() for l in desc.splitlines()]).strip(b'\n')
    91     return b'\n'.join([l.rstrip() for l in desc.splitlines()]).strip(b'\n')
    92 
    92 
    93 
    93 
    94 class appender(object):
    94 class appender:
    95     """the changelog index must be updated last on disk, so we use this class
    95     """the changelog index must be updated last on disk, so we use this class
    96     to delay writes to it"""
    96     to delay writes to it"""
    97 
    97 
    98     def __init__(self, vfs, name, mode, buf):
    98     def __init__(self, vfs, name, mode, buf):
    99         self.data = buf
    99         self.data = buf
   159 
   159 
   160     def __exit__(self, *args):
   160     def __exit__(self, *args):
   161         return self.fp.__exit__(*args)
   161         return self.fp.__exit__(*args)
   162 
   162 
   163 
   163 
   164 class _divertopener(object):
   164 class _divertopener:
   165     def __init__(self, opener, target):
   165     def __init__(self, opener, target):
   166         self._opener = opener
   166         self._opener = opener
   167         self._target = target
   167         self._target = target
   168 
   168 
   169     def __call__(self, name, mode=b'r', checkambig=False, **kwargs):
   169     def __call__(self, name, mode=b'r', checkambig=False, **kwargs):
   186 
   186 
   187     return _delay
   187     return _delay
   188 
   188 
   189 
   189 
   190 @attr.s
   190 @attr.s
   191 class _changelogrevision(object):
   191 class _changelogrevision:
   192     # Extensions might modify _defaultextra, so let the constructor below pass
   192     # Extensions might modify _defaultextra, so let the constructor below pass
   193     # it in
   193     # it in
   194     extra = attr.ib()
   194     extra = attr.ib()
   195     manifest = attr.ib()
   195     manifest = attr.ib()
   196     user = attr.ib(default=b'')
   196     user = attr.ib(default=b'')
   202     p2copies = attr.ib(default=None)
   202     p2copies = attr.ib(default=None)
   203     description = attr.ib(default=b'')
   203     description = attr.ib(default=b'')
   204     branchinfo = attr.ib(default=(_defaultextra[b'branch'], False))
   204     branchinfo = attr.ib(default=(_defaultextra[b'branch'], False))
   205 
   205 
   206 
   206 
   207 class changelogrevision(object):
   207 class changelogrevision:
   208     """Holds results of a parsed changelog revision.
   208     """Holds results of a parsed changelog revision.
   209 
   209 
   210     Changelog revisions consist of multiple pieces of data, including
   210     Changelog revisions consist of multiple pieces of data, including
   211     the manifest node, user, and date. This object exposes a view into
   211     the manifest node, user, and date. This object exposes a view into
   212     the parsed object.
   212     the parsed object.