Show More
@@ -9,7 +9,7 b' from demandload import demandload' | |||
|
9 | 9 | from node import * |
|
10 | 10 | from i18n import gettext as _ |
|
11 | 11 | demandload(globals(), 'os sys') |
|
12 |
demandload(globals(), 'mdiff util templater |
|
|
12 | demandload(globals(), 'mdiff util templater patch') | |
|
13 | 13 | |
|
14 | 14 | revrangesep = ':' |
|
15 | 15 | |
@@ -196,45 +196,6 b' def addremove(repo, pats=[], opts={}, wl' | |||
|
196 | 196 | if not dry_run: |
|
197 | 197 | repo.copy(old, new, wlock=wlock) |
|
198 | 198 | |
|
199 | class uibuffer(object): | |
|
200 | # Implement and delegate some ui protocol. Save hunks of | |
|
201 | # output for later display in the desired order. | |
|
202 | def __init__(self, ui): | |
|
203 | self.ui = ui | |
|
204 | self.hunk = {} | |
|
205 | self.header = {} | |
|
206 | self.quiet = ui.quiet | |
|
207 | self.verbose = ui.verbose | |
|
208 | self.debugflag = ui.debugflag | |
|
209 | self.lastheader = None | |
|
210 | def note(self, *args): | |
|
211 | if self.verbose: | |
|
212 | self.write(*args) | |
|
213 | def status(self, *args): | |
|
214 | if not self.quiet: | |
|
215 | self.write(*args) | |
|
216 | def debug(self, *args): | |
|
217 | if self.debugflag: | |
|
218 | self.write(*args) | |
|
219 | def write(self, *args): | |
|
220 | self.hunk.setdefault(self.rev, []).extend(args) | |
|
221 | def write_header(self, *args): | |
|
222 | self.header.setdefault(self.rev, []).extend(args) | |
|
223 | def mark(self, rev): | |
|
224 | self.rev = rev | |
|
225 | def flush(self, rev): | |
|
226 | if rev in self.header: | |
|
227 | h = "".join(self.header[rev]) | |
|
228 | if h != self.lastheader: | |
|
229 | self.lastheader = h | |
|
230 | self.ui.write(h) | |
|
231 | del self.header[rev] | |
|
232 | if rev in self.hunk: | |
|
233 | self.ui.write("".join(self.hunk[rev])) | |
|
234 | del self.hunk[rev] | |
|
235 | return 1 | |
|
236 | return 0 | |
|
237 | ||
|
238 | 199 | class changeset_printer(object): |
|
239 | 200 | '''show changeset information when templating not requested.''' |
|
240 | 201 | |
@@ -244,16 +205,33 b' class changeset_printer(object):' | |||
|
244 | 205 | self.buffered = buffered |
|
245 | 206 | self.patch = patch |
|
246 | 207 | self.brinfo = brinfo |
|
247 | if buffered: | |
|
248 |
|
|
|
208 | self.header = {} | |
|
209 | self.hunk = {} | |
|
210 | self.lastheader = None | |
|
249 | 211 | |
|
250 | 212 | def flush(self, rev): |
|
251 |
|
|
|
213 | if rev in self.header: | |
|
214 | h = self.header[rev] | |
|
215 | if h != self.lastheader: | |
|
216 | self.lastheader = h | |
|
217 | self.ui.write(h) | |
|
218 | del self.header[rev] | |
|
219 | if rev in self.hunk: | |
|
220 | self.ui.write(self.hunk[rev]) | |
|
221 | del self.hunk[rev] | |
|
222 | return 1 | |
|
223 | return 0 | |
|
252 | 224 | |
|
253 | def show(self, rev=0, changenode=None, copies=None): | |
|
225 | def show(self, rev=0, changenode=None, copies=None, **props): | |
|
226 | if self.buffered: | |
|
227 | self.ui.pushbuffer() | |
|
228 | self._show(rev, changenode, copies, props) | |
|
229 | self.hunk[rev] = self.ui.popbuffer() | |
|
230 | else: | |
|
231 | self._show(rev, changenode, copies, props) | |
|
232 | ||
|
233 | def _show(self, rev, changenode, copies, props): | |
|
254 | 234 | '''show a single changeset or file revision''' |
|
255 | if self.buffered: | |
|
256 | self.ui.mark(rev) | |
|
257 | 235 | log = self.repo.changelog |
|
258 | 236 | if changenode is None: |
|
259 | 237 | changenode = log.node(rev) |
@@ -352,10 +330,8 b' class changeset_templater(changeset_prin' | |||
|
352 | 330 | '''set template string to use''' |
|
353 | 331 | self.t.cache['changeset'] = t |
|
354 | 332 | |
|
355 |
def show(self, rev |
|
|
333 | def _show(self, rev, changenode, copies, props): | |
|
356 | 334 | '''show a single changeset or file revision''' |
|
357 | if self.buffered: | |
|
358 | self.ui.mark(rev) | |
|
359 | 335 | log = self.repo.changelog |
|
360 | 336 | if changenode is None: |
|
361 | 337 | changenode = log.node(rev) |
@@ -513,7 +489,7 b' class changeset_templater(changeset_prin' | |||
|
513 | 489 | if key: |
|
514 | 490 | h = templater.stringify(self.t(key, **props)) |
|
515 | 491 | if self.buffered: |
|
516 |
self. |
|
|
492 | self.header[rev] = h | |
|
517 | 493 | else: |
|
518 | 494 | self.ui.write(h) |
|
519 | 495 | if self.ui.debugflag and 'changeset_debug' in self.t: |
@@ -532,20 +508,6 b' class changeset_templater(changeset_prin' | |||
|
532 | 508 | except SyntaxError, inst: |
|
533 | 509 | raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0])) |
|
534 | 510 | |
|
535 | class stringio(object): | |
|
536 | '''wrap cStringIO for use by changeset_templater.''' | |
|
537 | def __init__(self): | |
|
538 | self.fp = cStringIO.StringIO() | |
|
539 | ||
|
540 | def write(self, *args): | |
|
541 | for a in args: | |
|
542 | self.fp.write(a) | |
|
543 | ||
|
544 | write_header = write | |
|
545 | ||
|
546 | def __getattr__(self, key): | |
|
547 | return getattr(self.fp, key) | |
|
548 | ||
|
549 | 511 | def show_changeset(ui, repo, opts, buffered=False): |
|
550 | 512 | """show one changeset using template or regular display. |
|
551 | 513 |
General Comments 0
You need to be logged in to leave comments.
Login now