Created attachment 1977 [details] patch being imported An attempt to import a patch from an email causes this traceback: modules$ hg import --exact ~/issue820 applying /home/zash/issue820 1 files updated, 0 files merged, 0 files removed, 0 files unresolved ** unknown exception encountered, please report by visiting ** https://mercurial-scm.org/wiki/BugTracker ** Python 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118] ** Mercurial Distributed SCM (version 4.3.3) ** Extensions loaded: extdiff, histedit, pager, patchbomb, purge, rebase, relink, schemes, shelve, show, strip, transplant Traceback (most recent call last): File "/usr/bin/hg", line 45, in <module> mercurial.dispatch.run() File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 81, in run status = (dispatch(req) or 0) & 255 File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 162, in dispatch ret = _runcatch(req) File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 302, in _runcatch return _callcatch(ui, _runcatchfunc) File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 310, in _callcatch return scmutil.callcatch(ui, func) File "/usr/lib/python2.7/dist-packages/mercurial/scmutil.py", line 150, in callcatch return func() File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 292, in _runcatchfunc return _dispatch(req) File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 896, in _dispatch cmdpats, cmdoptions) File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 658, in runcommand ret = _runcommand(ui, options, cmd, d) File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 322, in closure return func(*(args + a), **kw) File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 69, in pagecmd return orig(ui, options, cmd, cmdfunc) File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 904, in _runcommand return cmdfunc() File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 893, in <lambda> d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1077, in check return func(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 3024, in import_ msgs, hg.clean) File "/usr/lib/python2.7/dist-packages/mercurial/cmdutil.py", line 1297, in tryimportone elif opts.get('exact') and hex(n) != nodeid: TypeError: b2a_hex() argument 1 must be string or buffer, not None The repo is a clone of https://hg.prosody.im/prosody-modules/ and the patch is attached (received over email). Attempting to import without --excact appears as follows: modules$ hg import ~/issue820 applying /home/zash/issue820 But the change is not applied or committed.
I can reproduce with Mercurial version 4.3.2+605-7b1e524ad73f
digging deeper, the patch provided is damaged. The longer line got wrapped (the the two dates and the first line of context). This lead the patch to be interpreted as empty for some reason. Fixing the line wrapping led to a successful import of the patch (with or without --exact). So it seems like the --exact checking panics and crash when the patch import do not results in the creation of a changeset.
Sounds like it's easy to fix, because the usage of hex() there is checking if the patch is damaged.
*** Bug 5745 has been marked as a duplicate of this bug. ***
Bug was inactive for 150 days, archiving
Fixed by https://mercurial-scm.org/repo/hg/rev/32a75a8a5b0f Yuya Nishihara <yuya@tcha.org> import: fix crash on --exact check of empty commit (issue5702) (please test the fix)
Works, thanks!
Bug was set to TESTING for 7 days, resolving