Patchwork D2438: util: use util.shellquote() instead of repr() in date parse abort

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 3:49 a.m.
Message ID <differential-rev-PHID-DREV-eky5mkiqkyi2ss65f6ds-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28362/
State Superseded
Headers show

Comments

phabricator - Feb. 26, 2018, 3:49 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This results in slight output changes. I'm not thrilled with seeing a
  literal tab instead of \t in the output, but this is, to my memory,
  consistent with how we've handled this in other places for Python 3
  porting. The loss of quotes in test-revset.t is also vaguely upsetting
  to me, but I don't view it as a BC problem since it's an error
  message, so let's roll with it for now.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

AFFECTED FILES
  mercurial/util.py
  tests/test-commit.t
  tests/test-revset.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 26, 2018, 12:35 p.m.
yuja added a comment.


  I think `shellquote()` is okay, but simpler workaround is to use `bytestr(date)`
  to drop `b`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - March 1, 2018, 11:06 p.m.
pulkit accepted this revision.
pulkit added a comment.


  Looks good to me and Yuya's feedback is also addressed. Queued thanks.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, yuja, mercurial-devel
phabricator - March 2, 2018, 3:55 a.m.
yuja added a comment.


  repr() should be applied to a bytestr object to get bytestr.__repr__() working.
  Fixed in flight.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2438

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, yuja, mercurial-devel

Patch

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -413,7 +413,7 @@ 
   hg: parse error: invalid \x escape
   [255]
   $ log 'date(tip)'
-  hg: parse error: invalid date: 'tip'
+  hg: parse error: invalid date: tip
   [255]
   $ log '0:date'
   abort: unknown revision 'date'!
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -18,7 +18,7 @@ 
   hg: parse error: impossible time zone offset: 4444444
   [255]
   $ hg commit -d '1	15.1' -m commit-4
-  hg: parse error: invalid date: '1\t15.1'
+  hg: parse error: invalid date: '1	15.1'
   [255]
   $ hg commit -d 'foo bar' -m commit-5
   hg: parse error: invalid date: 'foo bar'
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2191,7 +2191,7 @@ 
             else:
                 break
         else:
-            raise error.ParseError(_('invalid date: %r') % date)
+            raise error.ParseError(_('invalid date: %s') % shellquote(date))
     # validate explicit (probably user-specified) date and
     # time zone offset. values must fit in signed 32 bits for
     # current 32-bit linux runtimes. timezones go from UTC-12