Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 7762:fece056bf240
add --git option to commands supporting --patch (log, incoming, history, tip)
No short -g form, since it would conflict with -g from the graphlog extension.
author | Jim Correia <jim.correia@pobox.com> |
---|---|
date | Sat, 14 Feb 2009 22:40:39 +0100 |
parents | bd5c37d792e6 |
children | e899ead7b8ae |
comparison
equal
deleted
inserted
replaced
7761:1e70db1825d2 | 7762:fece056bf240 |
---|---|
567 return runfn() | 567 return runfn() |
568 | 568 |
569 class changeset_printer(object): | 569 class changeset_printer(object): |
570 '''show changeset information when templating not requested.''' | 570 '''show changeset information when templating not requested.''' |
571 | 571 |
572 def __init__(self, ui, repo, patch, buffered): | 572 def __init__(self, ui, repo, patch, diffopts, buffered): |
573 self.ui = ui | 573 self.ui = ui |
574 self.repo = repo | 574 self.repo = repo |
575 self.buffered = buffered | 575 self.buffered = buffered |
576 self.patch = patch | 576 self.patch = patch |
577 self.diffopts = diffopts | |
577 self.header = {} | 578 self.header = {} |
578 self.hunk = {} | 579 self.hunk = {} |
579 self.lastheader = None | 580 self.lastheader = None |
580 | 581 |
581 def flush(self, rev): | 582 def flush(self, rev): |
668 | 669 |
669 def showpatch(self, node): | 670 def showpatch(self, node): |
670 if self.patch: | 671 if self.patch: |
671 prev = self.repo.changelog.parents(node)[0] | 672 prev = self.repo.changelog.parents(node)[0] |
672 chunks = patch.diff(self.repo, prev, node, match=self.patch, | 673 chunks = patch.diff(self.repo, prev, node, match=self.patch, |
673 opts=patch.diffopts(self.ui)) | 674 opts=patch.diffopts(self.ui, self.diffopts)) |
674 for chunk in chunks: | 675 for chunk in chunks: |
675 self.ui.write(chunk) | 676 self.ui.write(chunk) |
676 self.ui.write("\n") | 677 self.ui.write("\n") |
677 | 678 |
678 def _meaningful_parentrevs(self, log, rev): | 679 def _meaningful_parentrevs(self, log, rev): |
692 | 693 |
693 | 694 |
694 class changeset_templater(changeset_printer): | 695 class changeset_templater(changeset_printer): |
695 '''format changeset information.''' | 696 '''format changeset information.''' |
696 | 697 |
697 def __init__(self, ui, repo, patch, mapfile, buffered): | 698 def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): |
698 changeset_printer.__init__(self, ui, repo, patch, buffered) | 699 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) |
699 filters = templatefilters.filters.copy() | 700 filters = templatefilters.filters.copy() |
700 filters['formatnode'] = (ui.debugflag and (lambda x: x) | 701 filters['formatnode'] = (ui.debugflag and (lambda x: x) |
701 or (lambda x: x[:12])) | 702 or (lambda x: x[:12])) |
702 self.t = templater.templater(mapfile, filters, | 703 self.t = templater.templater(mapfile, filters, |
703 cache={ | 704 cache={ |
910 if not os.path.split(mapfile)[0]: | 911 if not os.path.split(mapfile)[0]: |
911 mapname = (templater.templatepath('map-cmdline.' + mapfile) | 912 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
912 or templater.templatepath(mapfile)) | 913 or templater.templatepath(mapfile)) |
913 if mapname: mapfile = mapname | 914 if mapname: mapfile = mapname |
914 try: | 915 try: |
915 t = changeset_templater(ui, repo, patch, mapfile, buffered) | 916 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) |
916 except SyntaxError, inst: | 917 except SyntaxError, inst: |
917 raise util.Abort(inst.args[0]) | 918 raise util.Abort(inst.args[0]) |
918 if tmpl: t.use_template(tmpl) | 919 if tmpl: t.use_template(tmpl) |
919 return t | 920 return t |
920 return changeset_printer(ui, repo, patch, buffered) | 921 return changeset_printer(ui, repo, patch, opts, buffered) |
921 | 922 |
922 def finddate(ui, repo, date): | 923 def finddate(ui, repo, date): |
923 """Find the tipmost changeset that matches the given date spec""" | 924 """Find the tipmost changeset that matches the given date spec""" |
924 df = util.matchdate(date) | 925 df = util.matchdate(date) |
925 get = util.cachefunc(lambda r: repo[r].changeset()) | 926 get = util.cachefunc(lambda r: repo[r].changeset()) |