mercurial/formatter.py
changeset 29324 b501579147f1
parent 28957 d813132ea361
child 29690 c3a9cd78b151
equal deleted inserted replaced
29321:de4a80a2b45c 29324:b501579147f1
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import cPickle
       
    11 import os
    10 import os
    12 
    11 
    13 from .i18n import _
    12 from .i18n import _
    14 from .node import (
    13 from .node import (
    15     hex,
    14     hex,
    18 
    17 
    19 from . import (
    18 from . import (
    20     encoding,
    19     encoding,
    21     error,
    20     error,
    22     templater,
    21     templater,
       
    22     util,
    23 )
    23 )
       
    24 
       
    25 pickle = util.pickle
    24 
    26 
    25 class baseformatter(object):
    27 class baseformatter(object):
    26     def __init__(self, ui, topic, opts):
    28     def __init__(self, ui, topic, opts):
    27         self._ui = ui
    29         self._ui = ui
    28         self._topic = topic
    30         self._topic = topic
   105         self._data = []
   107         self._data = []
   106     def _showitem(self):
   108     def _showitem(self):
   107         self._data.append(self._item)
   109         self._data.append(self._item)
   108     def end(self):
   110     def end(self):
   109         baseformatter.end(self)
   111         baseformatter.end(self)
   110         self._ui.write(cPickle.dumps(self._data))
   112         self._ui.write(pickle.dumps(self._data))
   111 
   113 
   112 def _jsonifyobj(v):
   114 def _jsonifyobj(v):
   113     if isinstance(v, tuple):
   115     if isinstance(v, tuple):
   114         return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
   116         return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
   115     elif v is None:
   117     elif v is None: