hgext/journal.py
changeset 36666 d79d68bb9f7c
parent 36653 2f7a3c90c0d7
child 36667 bcfc4e3b6548
equal deleted inserted replaced
36665:6276cbc704a6 36666:d79d68bb9f7c
    22 
    22 
    23 from mercurial import (
    23 from mercurial import (
    24     bookmarks,
    24     bookmarks,
    25     cmdutil,
    25     cmdutil,
    26     dispatch,
    26     dispatch,
       
    27     encoding,
    27     error,
    28     error,
    28     extensions,
    29     extensions,
    29     hg,
    30     hg,
    30     localrepo,
    31     localrepo,
    31     lock,
    32     lock,
   217         newhashes = tuple(node.bin(hash) for hash in newhashes.split(','))
   218         newhashes = tuple(node.bin(hash) for hash in newhashes.split(','))
   218         return cls(
   219         return cls(
   219             (timestamp, tz), user, command, namespace, name,
   220             (timestamp, tz), user, command, namespace, name,
   220             oldhashes, newhashes)
   221             oldhashes, newhashes)
   221 
   222 
   222     def __str__(self):
   223     def __bytes__(self):
   223         """String representation for storage"""
   224         """bytes representation for storage"""
   224         time = ' '.join(map(str, self.timestamp))
   225         time = ' '.join(map(str, self.timestamp))
   225         oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes])
   226         oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes])
   226         newhashes = ','.join([node.hex(hash) for hash in self.newhashes])
   227         newhashes = ','.join([node.hex(hash) for hash in self.newhashes])
   227         return '\n'.join((
   228         return '\n'.join((
   228             time, self.user, self.command, self.namespace, self.name,
   229             time, self.user, self.command, self.namespace, self.name,
   229             oldhashes, newhashes))
   230             oldhashes, newhashes))
       
   231 
       
   232     __str__ = encoding.strmethod(__bytes__)
   230 
   233 
   231 class journalstorage(object):
   234 class journalstorage(object):
   232     """Storage for journal entries
   235     """Storage for journal entries
   233 
   236 
   234     Entries are divided over two files; one with entries that pertain to the
   237     Entries are divided over two files; one with entries that pertain to the