Bug 4591 - hg archive aborts if revision 0 is hidden
Summary: hg archive aborts if revision 0 is hidden
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: evolution (show other bugs)
Version: 3.3.2
Hardware: PC Linux
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-07 18:21 UTC by Jordi Gutiérrez Hermoso
Modified: 2015-04-17 01: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 Jordi Gutiérrez Hermoso 2015-04-07 18:21 UTC
repro:

 hg init lol
 cd lol
 echo a > a
 hg addr

 hg ci -m a
 echo b > b
 hg addr

 hg ci -m b
 hg prune 0
 hg evolve -a
 hg archive ../lol.tar.gz

With this I see,

** Unknown exception encountered with possibly-broken third-party extension crecord
** which supports versions unknown of Mercurial.
** Please disable crecord and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2]
** Mercurial Distributed SCM (version 3.3.2)
** Extensions loaded: convert, strip, record, churn, purge, rebase, highlight, color, progress, patchbomb, histedit, largefiles, shelve, pager, hggit, crecord, evolve
Traceback (most recent call last):
  File "/usr/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 71, in dispatch
    ret = _runcatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 140, in _runcatch
    return _dispatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 863, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 624, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 194, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 158, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 194, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 491, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 954, in _runcommand
    return checkargs()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 925, in checkargs
    return cmdfunc()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 860, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 713, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 423, in archive
    matchfn, prefix, subrepos=opts.get('subrepos'))
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 194, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/largefiles/overrides.py", line 893, in overridearchive
    write('.hg_archival.txt', 0644, False, metadata)
  File "/usr/lib/python2.7/dist-packages/hgext/largefiles/overrides.py", line 868, in write
    data = getdata()
  File "/usr/lib/python2.7/dist-packages/hgext/largefiles/overrides.py", line 878, in metadata
    hex(repo.changelog.node(0)), hex(node), ctx.branch())
  File "/usr/lib/python2.7/dist-packages/mercurial/changelog.py", line 206, in node
    raise error.FilteredIndexError(rev)
mercurial.error.FilteredIndexError: 0
Comment 1 Matt Mackall 2015-04-07 18:35 UTC
That'll probably break other stuff too, as rev 0's hash is used as the repository identity.

Might be easiest to disallow it.
Comment 2 Yuya Nishihara 2015-04-08 08:56 UTC
TortoiseHg has a function that returns the first visible changeset.
I think it can be ported to Mercurial.

https://bitbucket.org/tortoisehg/thg/src/853f8ed5b2f0/tortoisehg/util/hglib.py#cl-124
Comment 3 HG Bot 2015-04-09 14:01 UTC
Fixed by http://selenic.com/repo/hg/rev/33ab99a6ad9b
Yuya Nishihara <yuya@tcha.org>
archive: look for first visible revision to build repo identity (issue4591)

No test for the case where all revisions are hidden because "archive" command
aborts if the target revision is null.

(please test the fix)
Comment 4 Bugzilla 2015-04-17 01:00 UTC
Bug was set to TESTING for 7 days, resolving