[PATCH] template: allow unquoted int function arguments

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Apr 9 11:49:30 CDT 2013


At Sun, 07 Apr 2013 23:26:21 -0700,
Brendan Cully wrote:
> 
> # HG changeset patch
> # User Brendan Cully <brendan at kublai.com>
> # Date 1365402350 25200
> #      Sun Apr 07 23:25:50 2013 -0700
> # Node ID 5e8ca3d6df6c2c92ad6e30ebb05ace3c36f59be7
> # Parent  565482e2ac6b71125e74adf409939bf54bad274f
> template: allow unquoted int function arguments
> 
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -66,7 +66,10 @@
>                      break
>                  pos += 1
>              sym = program[s:pos]
> -            yield ('symbol', sym, s)
> +            try:
> +                yield('string', str(int(sym)), s)
> +            except ValueError:
> +                yield ('symbol', sym, s)
>              pos -= 1
>          elif c == '}':
>              pos += 1
> diff --git a/tests/test-command-template.t b/tests/test-command-template.t
> --- a/tests/test-command-template.t
> +++ b/tests/test-command-template.t
> @@ -1360,6 +1360,12 @@
>    $ hg log -l1 --template '{date|age}\n'
>    7 years from now
>  
> +Filter with int function argument:
> +
> +  $ hg log --template '{fill(author, 20)}\n' -r 0
> +  User Name
> +  <user at hostname>
> +
>  Error on syntax:
>  
>    $ echo 'x = "f' >> t

This change seems to cause below test failure: "templater.engine" is
used in schemes extension.

========================================
make -k test-schemes.t
cd tests && python run-tests.py  test-schemes.t
python hash seed: 1524144202

--- /home/fujiwara/anyware/mercurial/repo/selenic.com/hg/tests/test-schemes.t
+++ /home/fujiwara/anyware/mercurial/repo/selenic.com/hg/tests/test-schemes.t.err
@@ -25,15 +25,10 @@
 check that {1} syntax works

   $ hg incoming --debug parts://localhost
-  using http://localhost:$HGPORT/
+  using http://1:$HGPORT/
   sending capabilities command
-  comparing with parts://localhost/
-  query 1; heads
-  sending batch command
-  searching for changes
-  all remote heads known locally
-  no changes found
-  [1]
+  abort: error: Invalid argument
+  [255]
========================================

Adding --traceback to "hg incoming" in the test shows below:

========================================
--- /home/fujiwara/anyware/mercurial/repo/selenic.com/hg/tests/test-schemes.t
+++ /home/fujiwara/anyware/mercurial/repo/selenic.com/hg/tests/test-schemes.t.err
@@ -25,15 +25,56 @@
 check that {1} syntax works

   $ hg --traceback incoming --debug parts://localhost
-  using http://localhost:$HGPORT/
+  using http://1:$HGPORT/
   sending capabilities command
-  comparing with parts://localhost/
-  query 1; heads
-  sending batch command
-  searching for changes
-  all remote heads known locally
-  no changes found
-  [1]
+  Traceback (most recent call last):
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 88, in _runcatch
+      return _dispatch(req)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 746, in _dispatch
+      cmdpats, cmdoptions)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 515, in runcommand
+      ret = _runcommand(ui, options, cmd, d)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 841, in _runcommand
+      return checkargs()
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 812, in checkargs
+      return cmdfunc()
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/dispatch.py", line 741, in <lambda>
+      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/util.py", line 506, in check
+      return func(*args, **kwargs)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/commands.py", line 3800, in incoming
+      return hg.incoming(ui, repo, source, opts)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/hg.py", line 547, in incoming
+      return _incoming(display, subreporecurse, ui, repo, source, opts)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/hg.py", line 499, in _incoming
+      other = peer(repo, opts, source)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/hg.py", line 121, in peer
+      return _peerorrepo(rui, path, create).peer()
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/hg.py", line 101, in _peerorrepo
+      obj = _peerlookup(path).instance(ui, path, create)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/hgext/schemes.py", line 74, in instance
+      return hg._peerlookup(url).instance(ui, url, create)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/httppeer.py", line 238, in instance
+      inst._fetchcaps()
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/httppeer.py", line 57, in _fetchcaps
+      self.caps = set(self._call('capabilities').split())
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/httppeer.py", line 171, in _call
+      fp = self._callstream(cmd, **args)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/httppeer.py", line 118, in _callstream
+      resp = self.urlopener.open(req)
+    File "/usr/lib/python2.6/urllib2.py", line 391, in open
+      response = self._open(req, data)
+    File "/usr/lib/python2.6/urllib2.py", line 409, in _open
+      '_open', req)
+    File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
+      result = func(*args)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/url.py", line 315, in http_open
+      return self.do_open(httpconnection, req)
+    File "/tmp/hgtests.YcdIqR/install/lib/python/mercurial/keepalive.py", line 257, in do_open
+      raise urllib2.URLError(err)
+  URLError: <urlopen error [Errno 22] Invalid argument>
+  abort: error: Invalid argument
+  [255]
========================================

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list