Patchwork test-pathencode: accept --seed parameter in hex as well

login
register
mail settings
Submitter Adrian Buehlmann
Date Dec. 20, 2012, 2:23 p.m.
Message ID <947209a09d9d0c4ae2a0.1356013392@kork>
Download mbox | patch
Permalink /patch/213/
State Accepted
Commit acfc6fab13617482899ac71287edf4f23fe6f06f
Headers show

Comments

Adrian Buehlmann - Dec. 20, 2012, 2:23 p.m.
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1356013121 -3600
# Node ID 947209a09d9d0c4ae2a03144cd39f8c3a6cd2cc0
# Parent  11748167a78ea677eff1ab1ac2a89b9e9cff41f1
test-pathencode: accept --seed parameter in hex as well

test-pathencode.py outputs the seed value in hex if it finds a deviation.

This change allows to specify the seed value as a command line parameter for
test-pathencode.py in *hex* as well.

Example (after this change):

  $ PATH="`pwd`/..:/c/python:/c/python/scripts" python test-pathencode.py \
  > --seed 0x2677162b622ede426c945f4dcb8dc475
  seed: 0x2677162b622ede426c945f4dcb8dc475

  p: 'data/st_to_/dohahii/e\x81z_So7/smgeinm/s:ooso.i'
  h: 'data/st__to__/dohahii/e~81z___so7/smgeinm/s~3aooso.i'
  r: 'data/st__to__/dohahii/e~81z___so7/smgeinm/s:ooso.i'

Before this change, the behavior was:

  $ PATH="`pwd`/..:/c/python:/c/python/scripts" python test-pathencode.py \
  > --seed 0x2677162b622ede426c945f4dcb8dc475
  Traceback (most recent call last):
    File "test-pathencode.py", line 198, in <module>
      main()
    File "test-pathencode.py", line 180, in main
      seed = long(a)
  ValueError: invalid literal for long() with base 10: '0x2677162b622ede426c945f4dcb8dc475'

Note that this is a fake example! I've hacked the code in order to introduce a
deliberate, artificial deviation between the C and the Python code. There is no
known deviation. The hack I used was:

  --- a/mercurial/store.py
  +++ b/mercurial/store.py
  @@ -72,7 +72,7 @@
       'the\\x07quick\\xadshot'
       '''
       e = '_'
  -    winreserved = [ord(x) for x in '\\:*?"<>|']
  +    winreserved = [ord(x) for x in '\\*?"<>|']
       cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
       for x in (range(32) + range(126, 256) + winreserved):
           cmap[chr(x)] = "~%02x" % x
Bryan O'Sullivan - Dec. 20, 2012, 8:26 p.m.
On Thu, Dec 20, 2012 at 6:23 AM, Adrian Buehlmann <adrian at cadifra.com>wrote:

> test-pathencode: accept --seed parameter in hex as well
>

Pushed to crew, thanks.

(I trimmed your commit description, which was disproportionately long for
such a tiny change.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121220/375074d5/attachment.html>

Patch

diff --git a/tests/test-pathencode.py b/tests/test-pathencode.py
--- a/tests/test-pathencode.py
+++ b/tests/test-pathencode.py
@@ -177,7 +177,7 @@ 
         if o in ('-c', '--count'):
             count = int(a)
         elif o in ('-s', '--seed'):
-            seed = long(a)
+            seed = long(a, base=0) # accepts base 10 or 16 strings
         elif o == '--build':
             buildprobtable(sys.stdout,
                            'find .hg/store/data -type f && '