##// END OF EJS Templates
add --git option to commands supporting --patch (log, incoming, history, tip)...
Jim Correia -
r7762:fece056b default
parent child Browse files
Show More
@@ -367,7 +367,7 b' class bugzilla(object):'
367 mapfile = self.ui.config('bugzilla', 'style')
367 mapfile = self.ui.config('bugzilla', 'style')
368 tmpl = self.ui.config('bugzilla', 'template')
368 tmpl = self.ui.config('bugzilla', 'template')
369 t = cmdutil.changeset_templater(self.ui, self.repo,
369 t = cmdutil.changeset_templater(self.ui, self.repo,
370 False, mapfile, False)
370 False, None, mapfile, False)
371 if not mapfile and not tmpl:
371 if not mapfile and not tmpl:
372 tmpl = _('changeset {node|short} in repo {root} refers '
372 tmpl = _('changeset {node|short} in repo {root} refers '
373 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
373 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
@@ -15,7 +15,7 b' import time, datetime'
15 def maketemplater(ui, repo, tmpl):
15 def maketemplater(ui, repo, tmpl):
16 tmpl = templater.parsestring(tmpl, quoted=False)
16 tmpl = templater.parsestring(tmpl, quoted=False)
17 try:
17 try:
18 t = cmdutil.changeset_templater(ui, repo, False, None, False)
18 t = cmdutil.changeset_templater(ui, repo, False, None, None, False)
19 except SyntaxError, inst:
19 except SyntaxError, inst:
20 raise util.Abort(inst.args[0])
20 raise util.Abort(inst.args[0])
21 t.use_template(tmpl)
21 t.use_template(tmpl)
@@ -188,7 +188,8 b' class hgcia(object):'
188 if not template:
188 if not template:
189 template = self.diffstat and self.dstemplate or self.deftemplate
189 template = self.diffstat and self.dstemplate or self.deftemplate
190 template = templater.parsestring(template, quoted=False)
190 template = templater.parsestring(template, quoted=False)
191 t = cmdutil.changeset_templater(self.ui, self.repo, False, style, False)
191 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
192 style, False)
192 t.use_template(template)
193 t.use_template(template)
193 self.templater = t
194 self.templater = t
194
195
@@ -137,7 +137,7 b' class kwtemplater(object):'
137
137
138 templatefilters.filters['utcdate'] = utcdate
138 templatefilters.filters['utcdate'] = utcdate
139 self.ct = cmdutil.changeset_templater(self.ui, self.repo,
139 self.ct = cmdutil.changeset_templater(self.ui, self.repo,
140 False, '', False)
140 False, None, '', False)
141
141
142 def substitute(self, data, path, ctx, subfunc):
142 def substitute(self, data, path, ctx, subfunc):
143 '''Replaces keywords in data with expanded template.'''
143 '''Replaces keywords in data with expanded template.'''
@@ -113,7 +113,7 b' class notifier(object):'
113 template = (self.ui.config('notify', hooktype) or
113 template = (self.ui.config('notify', hooktype) or
114 self.ui.config('notify', 'template'))
114 self.ui.config('notify', 'template'))
115 self.t = cmdutil.changeset_templater(self.ui, self.repo,
115 self.t = cmdutil.changeset_templater(self.ui, self.repo,
116 False, mapfile, False)
116 False, None, mapfile, False)
117 if not mapfile and not template:
117 if not mapfile and not template:
118 template = deftemplates.get(hooktype) or single_template
118 template = deftemplates.get(hooktype) or single_template
119 if template:
119 if template:
@@ -569,11 +569,12 b' def service(opts, parentfn=None, initfn='
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
@@ -670,7 +671,7 b' class changeset_printer(object):'
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")
@@ -694,8 +695,8 b' class changeset_printer(object):'
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]))
@@ -912,12 +913,12 b' def show_changeset(ui, repo, opts, buffe'
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"""
@@ -3001,6 +3001,7 b' templateopts = ['
3001
3001
3002 logopts = [
3002 logopts = [
3003 ('p', 'patch', None, _('show patch')),
3003 ('p', 'patch', None, _('show patch')),
3004 ('', 'git', None, _('use git extended diff format')),
3004 ('l', 'limit', '', _('limit number of changes displayed')),
3005 ('l', 'limit', '', _('limit number of changes displayed')),
3005 ('M', 'no-merges', None, _('do not show merges')),
3006 ('M', 'no-merges', None, _('do not show merges')),
3006 ] + templateopts
3007 ] + templateopts
@@ -3391,6 +3392,7 b' table = {'
3391 "tip":
3392 "tip":
3392 (tip,
3393 (tip,
3393 [('p', 'patch', None, _('show patch')),
3394 [('p', 'patch', None, _('show patch')),
3395 ('', 'git', None, _('use git extended diff format')),
3394 ] + templateopts,
3396 ] + templateopts,
3395 _('[-p]')),
3397 _('[-p]')),
3396 "unbundle":
3398 "unbundle":
@@ -21,6 +21,8 b' hg -R new incoming test'
21 hg -R new incoming -r 4 test
21 hg -R new incoming -r 4 test
22 echo "% limit to 2 changesets"
22 echo "% limit to 2 changesets"
23 hg -R new incoming -l 2 test
23 hg -R new incoming -l 2 test
24 echo "% limit to 2 changesets, test with -p --git"
25 hg -R new incoming -l 2 -p --git test
24
26
25 # test with --bundle
27 # test with --bundle
26 http_proxy= hg -R new incoming --bundle test.hg http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,'
28 http_proxy= hg -R new incoming --bundle test.hg http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,'
@@ -163,6 +163,32 b' user: test'
163 date: Mon Jan 12 13:46:40 1970 +0000
163 date: Mon Jan 12 13:46:40 1970 +0000
164 summary: 1
164 summary: 1
165
165
166 % limit to 2 changesets, test with -p --git
167 comparing with test
168 changeset: 0:9cb21d99fe27
169 user: test
170 date: Mon Jan 12 13:46:40 1970 +0000
171 summary: 0
172
173 diff --git a/foo b/foo
174 new file mode 100644
175 --- /dev/null
176 +++ b/foo
177 @@ -0,0 +1,1 @@
178 +0
179
180 changeset: 1:d717f5dfad6a
181 user: test
182 date: Mon Jan 12 13:46:40 1970 +0000
183 summary: 1
184
185 diff --git a/foo b/foo
186 --- a/foo
187 +++ b/foo
188 @@ -1,1 +1,2 @@
189 0
190 +1
191
166 comparing with http://localhost/
192 comparing with http://localhost/
167 changeset: 0:9cb21d99fe27
193 changeset: 0:9cb21d99fe27
168 user: test
194 user: test
@@ -95,6 +95,9 b' hg log --follow-first'
95 echo % log -P 2
95 echo % log -P 2
96 hg log -P 2
96 hg log -P 2
97
97
98 echo '% log -r tip -p --git'
99 hg log -r tip -p --git
100
98 echo '% log -r ""'
101 echo '% log -r ""'
99 hg log -r ''
102 hg log -r ''
100
103
@@ -221,6 +221,20 b' user: test'
221 date: Thu Jan 01 00:00:01 1970 +0000
221 date: Thu Jan 01 00:00:01 1970 +0000
222 summary: b1
222 summary: b1
223
223
224 % log -r tip -p --git
225 changeset: 6:2404bbcab562
226 tag: tip
227 user: test
228 date: Thu Jan 01 00:00:01 1970 +0000
229 summary: b1.1
230
231 diff --git a/b1 b/b1
232 --- a/b1
233 +++ b/b1
234 @@ -1,1 +1,2 @@
235 b1
236 +postm
237
224 % log -r ""
238 % log -r ""
225 abort: 00changelog.i@: ambiguous identifier!
239 abort: 00changelog.i@: ambiguous identifier!
226 % log -r <some unknown node id>
240 % log -r <some unknown node id>
General Comments 0
You need to be logged in to leave comments. Login now