197 repo.copy(old, new, wlock=wlock) |
197 repo.copy(old, new, wlock=wlock) |
198 |
198 |
199 class changeset_printer(object): |
199 class changeset_printer(object): |
200 '''show changeset information when templating not requested.''' |
200 '''show changeset information when templating not requested.''' |
201 |
201 |
202 def __init__(self, ui, repo, patch, brinfo, buffered): |
202 def __init__(self, ui, repo, patch, buffered): |
203 self.ui = ui |
203 self.ui = ui |
204 self.repo = repo |
204 self.repo = repo |
205 self.buffered = buffered |
205 self.buffered = buffered |
206 self.patch = patch |
206 self.patch = patch |
207 self.brinfo = brinfo |
|
208 self.header = {} |
207 self.header = {} |
209 self.hunk = {} |
208 self.hunk = {} |
210 self.lastheader = None |
209 self.lastheader = None |
211 |
210 |
212 def flush(self, rev): |
211 def flush(self, rev): |
266 for tag in self.repo.nodetags(changenode): |
265 for tag in self.repo.nodetags(changenode): |
267 self.ui.write(_("tag: %s\n") % tag) |
266 self.ui.write(_("tag: %s\n") % tag) |
268 for parent in parents: |
267 for parent in parents: |
269 self.ui.write(_("parent: %d:%s\n") % parent) |
268 self.ui.write(_("parent: %d:%s\n") % parent) |
270 |
269 |
271 if self.brinfo: |
|
272 br = self.repo.branchlookup([changenode]) |
|
273 if br: |
|
274 self.ui.write(_("branch: %s\n") % " ".join(br[changenode])) |
|
275 |
|
276 if self.ui.debugflag: |
270 if self.ui.debugflag: |
277 self.ui.write(_("manifest: %d:%s\n") % |
271 self.ui.write(_("manifest: %d:%s\n") % |
278 (self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
272 (self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
279 self.ui.write(_("user: %s\n") % changes[1]) |
273 self.ui.write(_("user: %s\n") % changes[1]) |
280 self.ui.write(_("date: %s\n") % date) |
274 self.ui.write(_("date: %s\n") % date) |
318 self.ui.write("\n") |
312 self.ui.write("\n") |
319 |
313 |
320 class changeset_templater(changeset_printer): |
314 class changeset_templater(changeset_printer): |
321 '''format changeset information.''' |
315 '''format changeset information.''' |
322 |
316 |
323 def __init__(self, ui, repo, patch, brinfo, mapfile, buffered): |
317 def __init__(self, ui, repo, patch, mapfile, buffered): |
324 changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered) |
318 changeset_printer.__init__(self, ui, repo, patch, buffered) |
325 self.t = templater.templater(mapfile, templater.common_filters, |
319 self.t = templater.templater(mapfile, templater.common_filters, |
326 cache={'parent': '{rev}:{node|short} ', |
320 cache={'parent': '{rev}:{node|short} ', |
327 'manifest': '{rev}:{node|short}', |
321 'manifest': '{rev}:{node|short}', |
328 'filecopy': '{name} ({source})'}) |
322 'filecopy': '{name} ({source})'}) |
329 |
323 |
405 def showbranches(**args): |
399 def showbranches(**args): |
406 branch = changes[5].get("branch") |
400 branch = changes[5].get("branch") |
407 if branch: |
401 if branch: |
408 branch = util.tolocal(branch) |
402 branch = util.tolocal(branch) |
409 return showlist('branch', [branch], plural='branches', **args) |
403 return showlist('branch', [branch], plural='branches', **args) |
410 # add old style branches if requested |
|
411 if self.brinfo: |
|
412 br = self.repo.branchlookup([changenode]) |
|
413 if changenode in br: |
|
414 return showlist('branch', br[changenode], |
|
415 plural='branches', **args) |
|
416 |
404 |
417 def showparents(**args): |
405 def showparents(**args): |
418 parents = [[('rev', log.rev(p)), ('node', hex(p))] |
406 parents = [[('rev', log.rev(p)), ('node', hex(p))] |
419 for p in log.parents(changenode) |
407 for p in log.parents(changenode) |
420 if self.ui.debugflag or p != nullid] |
408 if self.ui.debugflag or p != nullid] |
524 # options |
512 # options |
525 patch = False |
513 patch = False |
526 if opts.get('patch'): |
514 if opts.get('patch'): |
527 patch = matchfn or util.always |
515 patch = matchfn or util.always |
528 |
516 |
529 br = None |
|
530 if opts.get('branches'): |
|
531 ui.warn(_("the --branches option is deprecated, " |
|
532 "please use 'hg branches' instead\n")) |
|
533 br = True |
|
534 tmpl = opts.get('template') |
517 tmpl = opts.get('template') |
535 mapfile = None |
518 mapfile = None |
536 if tmpl: |
519 if tmpl: |
537 tmpl = templater.parsestring(tmpl, quoted=False) |
520 tmpl = templater.parsestring(tmpl, quoted=False) |
538 else: |
521 else: |
550 if not os.path.split(mapfile)[0]: |
533 if not os.path.split(mapfile)[0]: |
551 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
534 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
552 or templater.templatepath(mapfile)) |
535 or templater.templatepath(mapfile)) |
553 if mapname: mapfile = mapname |
536 if mapname: mapfile = mapname |
554 try: |
537 try: |
555 t = changeset_templater(ui, repo, patch, br, mapfile, buffered) |
538 t = changeset_templater(ui, repo, patch, mapfile, buffered) |
556 except SyntaxError, inst: |
539 except SyntaxError, inst: |
557 raise util.Abort(inst.args[0]) |
540 raise util.Abort(inst.args[0]) |
558 if tmpl: t.use_template(tmpl) |
541 if tmpl: t.use_template(tmpl) |
559 return t |
542 return t |
560 return changeset_printer(ui, repo, patch, br, buffered) |
543 return changeset_printer(ui, repo, patch, buffered) |
561 |
544 |
562 def finddate(ui, repo, date): |
545 def finddate(ui, repo, date): |
563 """Find the tipmost changeset that matches the given date spec""" |
546 """Find the tipmost changeset that matches the given date spec""" |
564 df = util.matchdate(date + " to " + date) |
547 df = util.matchdate(date + " to " + date) |
565 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |
548 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |