##// END OF EJS Templates
formatter: add pickle format...
Matt Mackall -
r22430:968247e8 default
parent child Browse files
Show More
@@ -5,6 +5,7 b''
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 import cPickle
8 from i18n import _
9 from i18n import _
9 import encoding, util
10 import encoding, util
10
11
@@ -77,6 +78,16 b' class debugformatter(baseformatter):'
77 baseformatter.end(self)
78 baseformatter.end(self)
78 self._ui.write("]\n")
79 self._ui.write("]\n")
79
80
81 class pickleformatter(baseformatter):
82 def __init__(self, ui, topic, opts):
83 baseformatter.__init__(self, ui, topic, opts)
84 self._data = []
85 def _showitem(self):
86 self._data.append(self._item)
87 def end(self):
88 baseformatter.end(self)
89 self._ui.write(cPickle.dumps(self._data))
90
80 class jsonformatter(baseformatter):
91 class jsonformatter(baseformatter):
81 def __init__(self, ui, topic, opts):
92 def __init__(self, ui, topic, opts):
82 baseformatter.__init__(self, ui, topic, opts)
93 baseformatter.__init__(self, ui, topic, opts)
@@ -108,6 +119,8 b' def formatter(ui, topic, opts):'
108 template = opts.get("template", "")
119 template = opts.get("template", "")
109 if template == "json":
120 if template == "json":
110 return jsonformatter(ui, topic, opts)
121 return jsonformatter(ui, topic, opts)
122 elif template == "pickle":
123 return pickleformatter(ui, topic, opts)
111 elif template == "debug":
124 elif template == "debug":
112 return debugformatter(ui, topic, opts)
125 return debugformatter(ui, topic, opts)
113 elif template != "":
126 elif template != "":
@@ -128,4 +128,14 b' Issue294: hg remove --after dir fails wh'
128 ../t.h (glob)
128 ../t.h (glob)
129 ../t/e.h (glob)
129 ../t/e.h (glob)
130
130
131 $ hg files
132 ../b
133 ../dir.h/foo
134 ../t.h
135 ../t/b
136 ../t/e.h
137 ../t/x
138 $ hg files .
139 [1]
140
131 $ cd ../..
141 $ cd ../..
@@ -202,6 +202,12 b' hg status -A:'
202 }
202 }
203 ]
203 ]
204
204
205 $ hg status -A -Tpickle > pickle
206 >>> import pickle
207 >>> print sorted((x['status'], x['path']) for x in pickle.load(open("pickle")))
208 [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
209 $ rm pickle
210
205 $ echo "^ignoreddir$" > .hgignore
211 $ echo "^ignoreddir$" > .hgignore
206 $ mkdir ignoreddir
212 $ mkdir ignoreddir
207 $ touch ignoreddir/file
213 $ touch ignoreddir/file
General Comments 0
You need to be logged in to leave comments. Login now