Mercurial > evolve
view contrib/nopushpublish.py @ 5602:e25394b6d021 stable
ngtip: fix TypeError: make revset from revs, not nodes (issue6405)
This commit does two things:
- Firstly, it tweaks the ngtip revset test to exercise the -G/--graph
flag. This successfully triggers the bug when it is present.
- Secondly, it changes the `ngtip` revset to return a revset made from
integer revs instead of node hash bytes. The test now passes.
Details: The TypeError was triggered by running
hg log -r 'ngtip("default")' --graph
in a repository with more than one changeset. The --graph tag caused the
flow of control to call `reachableroots2` with the changeset ID found by
the `ngtip` revset. Because the changeset ID was a node hash (bytes)
instead of a rev (int), reachableroots2 raised the following error:
TypeError: an integer is required (got type bytes)
author | Sietse Brouwer <sbbrouwer@gmail.com> |
---|---|
date | Wed, 07 Oct 2020 09:34:59 +0200 |
parents | 4f5e915ddb71 |
children |
line wrap: on
line source
# Extension which prevent changeset to be turn public by push operation # # Copyright 2011 Logilab SA <contact@logilab.fr> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from mercurial import extensions, util from mercurial import discovery def checkpublish(orig, repo, remote, outgoing, *args): # is remote publishing? publish = True if 'phases' in remote.listkeys('namespaces'): remotephases = remote.listkeys('phases') publish = remotephases.get('publishing', False) npublish = 0 if publish: for rev in outgoing.missing: if repo[rev].phase(): npublish += 1 if npublish: repo.ui.warn("Push would publish %s changesets" % npublish) ret = orig(repo, remote, outgoing, *args) if npublish: raise util.Abort("Publishing push forbidden", hint="Use `hg phase -p <rev>` to manually publish them") return ret def uisetup(ui): extensions.wrapfunction(discovery, 'checkheads', checkpublish)