Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 22386:54e614a297ac
cmdutil: avoid the confusing name 'patch' for a matcher
author | Martin von Zweigbergk <martinvonz@gmail.com> |
---|---|
date | Sun, 31 Aug 2014 07:45:50 -0700 |
parents | 4509a16c76c2 |
children | 67588e47522a |
comparison
equal
deleted
inserted
replaced
22385:95032d2cf96f | 22386:54e614a297ac |
---|---|
835 stat=stat, fp=fp, prefix=prefix) | 835 stat=stat, fp=fp, prefix=prefix) |
836 | 836 |
837 class changeset_printer(object): | 837 class changeset_printer(object): |
838 '''show changeset information when templating not requested.''' | 838 '''show changeset information when templating not requested.''' |
839 | 839 |
840 def __init__(self, ui, repo, patch, diffopts, buffered): | 840 def __init__(self, ui, repo, matchfn, diffopts, buffered): |
841 self.ui = ui | 841 self.ui = ui |
842 self.repo = repo | 842 self.repo = repo |
843 self.buffered = buffered | 843 self.buffered = buffered |
844 self.patch = patch | 844 self.matchfn = matchfn |
845 self.diffopts = diffopts | 845 self.diffopts = diffopts |
846 self.header = {} | 846 self.header = {} |
847 self.hunk = {} | 847 self.hunk = {} |
848 self.lastheader = None | 848 self.lastheader = None |
849 self.footer = None | 849 self.footer = None |
978 | 978 |
979 self.showpatch(changenode, matchfn) | 979 self.showpatch(changenode, matchfn) |
980 | 980 |
981 def showpatch(self, node, matchfn): | 981 def showpatch(self, node, matchfn): |
982 if not matchfn: | 982 if not matchfn: |
983 matchfn = self.patch | 983 matchfn = self.matchfn |
984 if matchfn: | 984 if matchfn: |
985 stat = self.diffopts.get('stat') | 985 stat = self.diffopts.get('stat') |
986 diff = self.diffopts.get('patch') | 986 diff = self.diffopts.get('patch') |
987 diffopts = patch.diffopts(self.ui, self.diffopts) | 987 diffopts = patch.diffopts(self.ui, self.diffopts) |
988 prev = self.repo.changelog.parents(node)[0] | 988 prev = self.repo.changelog.parents(node)[0] |
1013 | 1013 |
1014 | 1014 |
1015 class changeset_templater(changeset_printer): | 1015 class changeset_templater(changeset_printer): |
1016 '''format changeset information.''' | 1016 '''format changeset information.''' |
1017 | 1017 |
1018 def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered): | 1018 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered): |
1019 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) | 1019 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1020 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) | 1020 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) |
1021 defaulttempl = { | 1021 defaulttempl = { |
1022 'parent': '{rev}:{node|formatnode} ', | 1022 'parent': '{rev}:{node|formatnode} ', |
1023 'manifest': '{rev}:{node|formatnode}', | 1023 'manifest': '{rev}:{node|formatnode}', |
1024 'file_copy': '{name} ({source})', | 1024 'file_copy': '{name} ({source})', |
1187 4. [ui] setting 'style' | 1187 4. [ui] setting 'style' |
1188 If all of these values are either the unset or the empty string, | 1188 If all of these values are either the unset or the empty string, |
1189 regular display via changeset_printer() is done. | 1189 regular display via changeset_printer() is done. |
1190 """ | 1190 """ |
1191 # options | 1191 # options |
1192 patch = None | 1192 matchfn = None |
1193 if opts.get('patch') or opts.get('stat'): | 1193 if opts.get('patch') or opts.get('stat'): |
1194 patch = scmutil.matchall(repo) | 1194 matchfn = scmutil.matchall(repo) |
1195 | 1195 |
1196 tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style')) | 1196 tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style')) |
1197 | 1197 |
1198 if not tmpl and not mapfile: | 1198 if not tmpl and not mapfile: |
1199 return changeset_printer(ui, repo, patch, opts, buffered) | 1199 return changeset_printer(ui, repo, matchfn, opts, buffered) |
1200 | 1200 |
1201 try: | 1201 try: |
1202 t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered) | 1202 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, |
1203 buffered) | |
1203 except SyntaxError, inst: | 1204 except SyntaxError, inst: |
1204 raise util.Abort(inst.args[0]) | 1205 raise util.Abort(inst.args[0]) |
1205 return t | 1206 return t |
1206 | 1207 |
1207 def showmarker(ui, marker): | 1208 def showmarker(ui, marker): |