[PATCH 1 of 2] Add a --git option commands which support --patch (log, incoming, history

jim.correia at gmail.com jim.correia at gmail.com
Mon Feb 9 09:45:11 CST 2009


# HG changeset patch
# User Jim Correia <jim.correia at pobox.com>
# Date 1232820688 18000
# Node ID 3031c4495904ecd78de6a0a68b9bd0800b0e3a98
# Parent  fceb9fa01a00ca494500eac5a79b2f1ebc1e8020
Add a --git option commands which support --patch (log, incoming, history
and tip).

There is no short form (-g) since it would conflict with -g from the
graphlog extension.

diff -r fceb9fa01a00 -r 3031c4495904 hgext/bugzilla.py
--- a/hgext/bugzilla.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/hgext/bugzilla.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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}')
diff -r fceb9fa01a00 -r 3031c4495904 hgext/churn.py
--- a/hgext/churn.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/hgext/churn.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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)
diff -r fceb9fa01a00 -r 3031c4495904 hgext/hgcia.py
--- a/hgext/hgcia.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/hgext/hgcia.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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
 
diff -r fceb9fa01a00 -r 3031c4495904 hgext/keyword.py
--- a/hgext/keyword.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/hgext/keyword.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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.'''
diff -r fceb9fa01a00 -r 3031c4495904 hgext/notify.py
--- a/hgext/notify.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/hgext/notify.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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:
diff -r fceb9fa01a00 -r 3031c4495904 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/mercurial/cmdutil.py	Sat Jan 24 13:11:28 2009 -0500
@@ -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, patchopts, buffered):
         self.ui = ui
         self.repo = repo
         self.buffered = buffered
         self.patch = patch
+        self.patchopts = patchopts
         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.patchopts))
             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, patchopts, mapfile, buffered):
+        changeset_printer.__init__(self, ui, repo, patch, patchopts, 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"""
diff -r fceb9fa01a00 -r 3031c4495904 mercurial/commands.py
--- a/mercurial/commands.py	Mon Feb 09 13:08:32 2009 +0100
+++ b/mercurial/commands.py	Sat Jan 24 13:11:28 2009 -0500
@@ -2997,6 +2997,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
@@ -3387,6 +3388,7 @@
     "tip":
         (tip,
          [('p', 'patch', None, _('show patch')),
+          ('',  'git', None, _('use git extended diff format')),
          ] + templateopts,
          _('[-p]')),
     "unbundle":
diff -r fceb9fa01a00 -r 3031c4495904 tests/test-incoming-outgoing
--- a/tests/test-incoming-outgoing	Mon Feb 09 13:08:32 2009 +0100
+++ b/tests/test-incoming-outgoing	Sat Jan 24 13:11:28 2009 -0500
@@ -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]*/,/,'
diff -r fceb9fa01a00 -r 3031c4495904 tests/test-incoming-outgoing.out
--- a/tests/test-incoming-outgoing.out	Mon Feb 09 13:08:32 2009 +0100
+++ b/tests/test-incoming-outgoing.out	Sat Jan 24 13:11:28 2009 -0500
@@ -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
diff -r fceb9fa01a00 -r 3031c4495904 tests/test-log
--- a/tests/test-log	Mon Feb 09 13:08:32 2009 +0100
+++ b/tests/test-log	Sat Jan 24 13:11:28 2009 -0500
@@ -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 ''
 
diff -r fceb9fa01a00 -r 3031c4495904 tests/test-log.out
--- a/tests/test-log.out	Mon Feb 09 13:08:32 2009 +0100
+++ b/tests/test-log.out	Sat Jan 24 13:11:28 2009 -0500
@@ -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>


More information about the Mercurial-devel mailing list