Bug 6044 - ProgrammingError with empty revspec
Summary: ProgrammingError with empty revspec
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: default branch
Hardware: PC Linux
: wish bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-01 18:05 UTC by Damien
Modified: 2019-01-11 00:00 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Damien 2019-01-01 18:05 UTC
$ hg up ""
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.15 (default, Jun 27 2018, 13:05:28) [GCC 8.1.1 20180531]
** Mercurial version 4.8.1, système de gestion de sources distribué
** Extensions chargées : 
** ProgrammingError: unsupported changeid '' of type <type 'str'>
Traceback (most recent call last):
  File "/usr/bin/hg", line 43, in <module>
    dispatch.run()
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 96, in run
    status = dispatch(req)
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 220, in dispatch
    ret = _runcatch(req) or 0
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 363, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 371, in _callcatch
    return scmutil.callcatch(ui, func)
  File "/usr/lib/python2.7/site-packages/mercurial/scmutil.py", line 166, in callcatch
    return func()
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 354, in _runcatchfunc
    return _dispatch(req)
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 994, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 737, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 1003, in _runcommand
    return cmdfunc()
  File "/usr/lib/python2.7/site-packages/mercurial/dispatch.py", line 991, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/usr/lib/python2.7/site-packages/mercurial/util.py", line 1644, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/mercurial/commands.py", line 6041, in update
    ctx = scmutil.revsingle(repo, rev, rev)
  File "/usr/lib/python2.7/site-packages/mercurial/scmutil.py", line 659, in revsingle
    return repo[default]
  File "/usr/lib/python2.7/site-packages/mercurial/localrepo.py", line 1277, in __getitem__
    (changeid, type(changeid)))
mercurial.error.ProgrammingError: unsupported changeid '' of type <type 'str'>
$
Comment 1 Chingis Dugarzhapov 2019-01-03 10:09 UTC
I did some bisect on hg-stable and here's what I found: changeid='' was dropped at API level in 

changeset:   37267:de4849b67fe0
user:        Martin von Zweigbergk <martinvonz@google.com>
date:        Mon Apr 02 09:18:01 2018 -0700
summary:     context: drop support for changeid='' (API)

(at de4849b67fe0)
$ hg up ""
abort: 00changelog.i@: ambiguous identifier!
$ echo $?
255

Later, in 8b86acc7aa64, error message was changed, but it's still a valid ui error with 255 exit code:

changeset:   37852:8b86acc7aa64
user:        Martin von Zweigbergk <martinvonz@google.com>
date:        Sat Apr 28 23:16:41 2018 -0700
summary:     context: drop support for looking up context by ambiguous changeid (API)

(at 8b86acc7aa64)
$ hg up ""
abort: unknown revision ''!
$ echo $?
255

Starting from 91618801d5c3, ProgrammingError is somehow thrown for this case as well (hg up "")

changeset:   38589:91618801d5c3
user:        Martin von Zweigbergk <martinvonz@google.com>
date:        Fri Jul 06 16:45:44 2018 -0700
summary:     context: raise ProgrammingError on repo['my-tag']

$ hg up ""
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.13 (default, Dec 18 2016, 07:03:39) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
** Mercurial Distributed SCM (version 4.6.2+709-91618801d5c3)
** Extensions loaded: strip
** ProgrammingError: unsupported changeid '' of type <type 'str'>
Traceback (most recent call last):
<...>
mercurial.error.ProgrammingError: unsupported changeid '' of type <type 'str'>
$ echo $?
1

This looks like not an intended behavior and we should throw ui error with 255 as in pre-91618801d5c3. I'll take a look later what's going on here
Comment 2 HG Bot 2019-01-03 18:05 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/fbd5e2f0bba7
Yuya Nishihara <yuya@tcha.org>
update: do not pass in user revspec as default destination (issue6044)

When the revsingle() was introduced at 61c0df2b089a, it couldn't handle
revspec=0 (not '0') properly. That's probably why the default was set to
rev.

This is technically BC since "hg update ''" was identical to "hg update '.'"
whereas "hg update -r ''" is "hg update", but I believe that's a bug given
no test fails with this change.

(please test the fix)
Comment 3 Bugzilla 2019-01-11 00:00 UTC
Bug was set to TESTING for 7 days, resolving