Mercurial > hg-stable
changeset 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 | 1e70db1825d2 |
children | cdc913e7fc5f |
files | hgext/bugzilla.py hgext/churn.py hgext/hgcia.py hgext/keyword.py hgext/notify.py mercurial/cmdutil.py mercurial/commands.py tests/test-incoming-outgoing tests/test-incoming-outgoing.out tests/test-log tests/test-log.out |
diffstat | 11 files changed, 60 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/bugzilla.py Sat Feb 14 01:07:44 2009 +0100 +++ b/hgext/bugzilla.py Sat Feb 14 22:40:39 2009 +0100 @@ -367,7 +367,7 @@ mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') t = cmdutil.changeset_templater(self.ui, self.repo, - False, mapfile, False) + False, None, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
--- a/hgext/churn.py Sat Feb 14 01:07:44 2009 +0100 +++ b/hgext/churn.py Sat Feb 14 22:40:39 2009 +0100 @@ -15,7 +15,7 @@ def maketemplater(ui, repo, tmpl): tmpl = templater.parsestring(tmpl, quoted=False) try: - t = cmdutil.changeset_templater(ui, repo, False, None, False) + t = cmdutil.changeset_templater(ui, repo, False, None, None, False) except SyntaxError, inst: raise util.Abort(inst.args[0]) t.use_template(tmpl)
--- a/hgext/hgcia.py Sat Feb 14 01:07:44 2009 +0100 +++ b/hgext/hgcia.py Sat Feb 14 22:40:39 2009 +0100 @@ -188,7 +188,8 @@ if not template: template = self.diffstat and self.dstemplate or self.deftemplate template = templater.parsestring(template, quoted=False) - t = cmdutil.changeset_templater(self.ui, self.repo, False, style, False) + t = cmdutil.changeset_templater(self.ui, self.repo, False, None, + style, False) t.use_template(template) self.templater = t
--- a/hgext/keyword.py Sat Feb 14 01:07:44 2009 +0100 +++ b/hgext/keyword.py Sat Feb 14 22:40:39 2009 +0100 @@ -137,7 +137,7 @@ templatefilters.filters['utcdate'] = utcdate self.ct = cmdutil.changeset_templater(self.ui, self.repo, - False, '', False) + False, None, '', False) def substitute(self, data, path, ctx, subfunc): '''Replaces keywords in data with expanded template.'''
--- a/hgext/notify.py Sat Feb 14 01:07:44 2009 +0100 +++ b/hgext/notify.py Sat Feb 14 22:40:39 2009 +0100 @@ -113,7 +113,7 @@ template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) self.t = cmdutil.changeset_templater(self.ui, self.repo, - False, mapfile, False) + False, None, mapfile, False) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template if template:
--- a/mercurial/cmdutil.py Sat Feb 14 01:07:44 2009 +0100 +++ b/mercurial/cmdutil.py Sat Feb 14 22:40:39 2009 +0100 @@ -569,11 +569,12 @@ class changeset_printer(object): '''show changeset information when templating not requested.''' - def __init__(self, ui, repo, patch, buffered): + def __init__(self, ui, repo, patch, diffopts, buffered): self.ui = ui self.repo = repo self.buffered = buffered self.patch = patch + self.diffopts = diffopts self.header = {} self.hunk = {} self.lastheader = None @@ -670,7 +671,7 @@ if self.patch: prev = self.repo.changelog.parents(node)[0] chunks = patch.diff(self.repo, prev, node, match=self.patch, - opts=patch.diffopts(self.ui)) + opts=patch.diffopts(self.ui, self.diffopts)) for chunk in chunks: self.ui.write(chunk) self.ui.write("\n") @@ -694,8 +695,8 @@ class changeset_templater(changeset_printer): '''format changeset information.''' - def __init__(self, ui, repo, patch, mapfile, buffered): - changeset_printer.__init__(self, ui, repo, patch, buffered) + def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): + changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) filters = templatefilters.filters.copy() filters['formatnode'] = (ui.debugflag and (lambda x: x) or (lambda x: x[:12])) @@ -912,12 +913,12 @@ or templater.templatepath(mapfile)) if mapname: mapfile = mapname try: - t = changeset_templater(ui, repo, patch, mapfile, buffered) + t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0]) if tmpl: t.use_template(tmpl) return t - return changeset_printer(ui, repo, patch, buffered) + return changeset_printer(ui, repo, patch, opts, buffered) def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec"""
--- a/mercurial/commands.py Sat Feb 14 01:07:44 2009 +0100 +++ b/mercurial/commands.py Sat Feb 14 22:40:39 2009 +0100 @@ -3001,6 +3001,7 @@ logopts = [ ('p', 'patch', None, _('show patch')), + ('', 'git', None, _('use git extended diff format')), ('l', 'limit', '', _('limit number of changes displayed')), ('M', 'no-merges', None, _('do not show merges')), ] + templateopts @@ -3391,6 +3392,7 @@ "tip": (tip, [('p', 'patch', None, _('show patch')), + ('', 'git', None, _('use git extended diff format')), ] + templateopts, _('[-p]')), "unbundle":
--- a/tests/test-incoming-outgoing Sat Feb 14 01:07:44 2009 +0100 +++ b/tests/test-incoming-outgoing Sat Feb 14 22:40:39 2009 +0100 @@ -21,6 +21,8 @@ hg -R new incoming -r 4 test echo "% limit to 2 changesets" hg -R new incoming -l 2 test +echo "% limit to 2 changesets, test with -p --git" +hg -R new incoming -l 2 -p --git test # test with --bundle http_proxy= hg -R new incoming --bundle test.hg http://localhost:$HGPORT/ | sed -e 's,:[0-9][0-9]*/,/,'
--- a/tests/test-incoming-outgoing.out Sat Feb 14 01:07:44 2009 +0100 +++ b/tests/test-incoming-outgoing.out Sat Feb 14 22:40:39 2009 +0100 @@ -163,6 +163,32 @@ date: Mon Jan 12 13:46:40 1970 +0000 summary: 1 +% limit to 2 changesets, test with -p --git +comparing with test +changeset: 0:9cb21d99fe27 +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 0 + +diff --git a/foo b/foo +new file mode 100644 +--- /dev/null ++++ b/foo +@@ -0,0 +1,1 @@ ++0 + +changeset: 1:d717f5dfad6a +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: 1 + +diff --git a/foo b/foo +--- a/foo ++++ b/foo +@@ -1,1 +1,2 @@ + 0 ++1 + comparing with http://localhost/ changeset: 0:9cb21d99fe27 user: test
--- a/tests/test-log Sat Feb 14 01:07:44 2009 +0100 +++ b/tests/test-log Sat Feb 14 22:40:39 2009 +0100 @@ -95,6 +95,9 @@ echo % log -P 2 hg log -P 2 +echo '% log -r tip -p --git' +hg log -r tip -p --git + echo '% log -r ""' hg log -r ''
--- a/tests/test-log.out Sat Feb 14 01:07:44 2009 +0100 +++ b/tests/test-log.out Sat Feb 14 22:40:39 2009 +0100 @@ -221,6 +221,20 @@ date: Thu Jan 01 00:00:01 1970 +0000 summary: b1 +% log -r tip -p --git +changeset: 6:2404bbcab562 +tag: tip +user: test +date: Thu Jan 01 00:00:01 1970 +0000 +summary: b1.1 + +diff --git a/b1 b/b1 +--- a/b1 ++++ b/b1 +@@ -1,1 +1,2 @@ + b1 ++postm + % log -r "" abort: 00changelog.i@: ambiguous identifier! % log -r <some unknown node id>