Patchwork template: allow unquoted int function arguments

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 9, 2013, 4:49 p.m.
Message ID <u8v4rejj9.wl%foozy@lares.dti.ne.jp>
Download mbox | patch
Permalink /patch/1265/
State Not Applicable, archived
Headers show

Comments

Katsunori FUJIWARA - April 9, 2013, 4:49 p.m.
At Sun, 07 Apr 2013 23:26:21 -0700,
Brendan Cully wrote:
> 
> # HG changeset patch
> # User Brendan Cully <brendan@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@hostname>
> +
>  Error on syntax:
>  
>    $ echo 'x = "f' >> t

This change seems to cause below test failure: "templater.engine" is
used in schemes extension.
Brendan Cully - April 9, 2013, 5:25 p.m.
On Wednesday, 10 April 2013 at 01:49, FUJIWARA Katsunori wrote:
> 
> At Sun, 07 Apr 2013 23:26:21 -0700,
> Brendan Cully wrote:
> > 
> > # HG changeset patch
> > # User Brendan Cully <brendan@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@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

Argh. I guess the patch will have to be backed out.

Patch

========================================
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@lares.dti.ne.jp