comparison tests/test-phabricator.t @ 42618:c17e6a3e7356

phabricator: handle local:commits time being string or int When setting local:commits arcanist has different behaviour depending on whether the repo is git or hg. With hg it sets the time as a number, since it calls PHP's strtotime on the value, but with git it sets it as a string. Normally this wouldn't be an issue since phabread wouldn't be interacting with Phabricator Revisions for git repos, but Mozilla has a secondary workflow for git users that uses the git-cinnabar tool to interact with their hg repos. When a git-cinnabar user uses the moz-phab tool to submit patches for mozilla-central it makes use of Mozilla's fork of arcanist, which works with their local git version of m-c, and thus sets the local:commit time as a string, and then translates the commit hashes. Currently when encountering such DREVS phabread dies with "TypeError: %d format: a number is required, not str". phabsend also used to set it as a string but wouldn't have encountered the issue with its own DREVs since it would read hg:meta first. Differential Revision: https://phab.mercurial-scm.org/D6650
author Ian Moody <moz-ian@perix.co.uk>
date Tue, 16 Jul 2019 19:18:16 +0100
parents 7629eb87e7f2
children 3355e0c2845f
comparison
equal deleted inserted replaced
42617:7629eb87e7f2 42618:c17e6a3e7356
130 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/81fce7de1b7d-05339e5b-amend.hg 130 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/81fce7de1b7d-05339e5b-amend.hg
131 $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json" 131 $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
132 D1253 - updated - 1acd4b60af38: create comment for phabricator test 132 D1253 - updated - 1acd4b60af38: create comment for phabricator test
133 133
134 Phabreading a DREV with a local:commits time as a string: 134 Phabreading a DREV with a local:commits time as a string:
135 BROKEN: shouldn't error
136 $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285 135 $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
137 ** unknown exception encountered, please report by visiting 136 # HG changeset patch
138 ** https://mercurial-scm.org/wiki/BugTracker 137 # User test <test>
139 ** Python * (glob) 138 # Date 1562019844 0
140 ** Mercurial Distributed SCM (version *) (glob) 139 # Branch default
141 ** Extensions loaded: phabricator 140 # Node ID da5c8c6bf23a36b6e3af011bc3734460692c23ce
142 Traceback (most recent call last): 141 # Parent 1f634396406d03e565ed645370e5fecd062cf215
143 File "*/install/bin/hg", line *, in <module> (glob) 142 test string time
144 dispatch.run() 143
145 File "*/install/lib/python/mercurial/dispatch.py", line *, in run (glob) 144 Differential Revision: https://phab.mercurial-scm.org/D1285
146 status = dispatch(req) 145 diff --git a/test b/test
147 File "*/install/lib/python/mercurial/dispatch.py", line *, in dispatch (glob) 146 new file mode 100644
148 ret = _runcatch(req) or 0 147 --- /dev/null
149 File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcatch (glob) 148 +++ b/test
150 return _callcatch(ui, _runcatchfunc) 149 @@ * @@ (glob)
151 File "*/install/lib/python/mercurial/dispatch.py", line *, in _callcatch (glob) 150 +test
152 return scmutil.callcatch(ui, func) 151
153 File "*/install/lib/python/mercurial/scmutil.py", line *, in callcatch (glob)
154 return func()
155 File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcatchfunc (glob)
156 return _dispatch(req)
157 File "*/install/lib/python/mercurial/dispatch.py", line *, in _dispatch (glob)
158 cmdpats, cmdoptions)
159 File "*/install/lib/python/mercurial/dispatch.py", line *, in runcommand (glob)
160 ret = _runcommand(ui, options, cmd, d)
161 File "*/install/lib/python/mercurial/dispatch.py", line *, in _runcommand (glob)
162 return cmdfunc()
163 File "*/install/lib/python/mercurial/dispatch.py", line *, in <lambda> (glob)
164 d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
165 File "*/install/lib/python/mercurial/util.py", line *, in check (glob)
166 return func(*args, **kwargs)
167 File "*/install/lib/python/hgext/phabricator.py", line *, in inner (glob)
168 return fn(*args, **kwargs)
169 File "*/install/lib/python/hgext/phabricator.py", line *, in phabread (glob)
170 readpatch(repo, drevs, ui.write)
171 File "*/install/lib/python/hgext/phabricator.py", line *, in readpatch (glob)
172 meta = getdiffmeta(diffs[b'%d' % diffid])
173 File "*/install/lib/python/hgext/phabricator.py", line *, in getdiffmeta (glob)
174 meta[b'date'] = b'%d 0' % commit[b'time']
175 TypeError: %d format: a number is required, not str
176 [1]
177 152
178 $ cd .. 153 $ cd ..