reviewboard: avoid devel warning in Mercurial 4.3 (
bug 1413628); r?glob
Mercurial 4.3+ will issue a devel warning if you pass a default
argument to look up the config value of an option with a static
default value.
There doesn't appear to be a good way to suppress the warning in
code aside from not passing the default argument. So we change
the code.
MozReview-Commit-ID: 9RbEMrq7IMZ
--- a/hgext/reviewboard/server.py
+++ b/hgext/reviewboard/server.py
@@ -61,16 +61,24 @@ cmdtable = {}
# Mercurial 4.3 introduced registrar.command as a replacement for
# cmdutil.command.
if util.safehasattr(registrar, 'command'):
command = registrar.command(cmdtable)
else:
command = cmdutil.command(cmdtable)
+# Mercurial 4.3 started defining config items using a central registrar.
+# Mercurial 4.4 finished this transition.
+try:
+ from mercurial import configitems
+ have_config_registrar = True
+except ImportError:
+ have_config_registrar = False
+
# Capabilities the server requires in clients.
#
# Add to this and add a corresponding entry in the client extension to force
# the client to pull latest code.
requirecaps = set([
# Client can speak protocol format 1.
'proto1',
# Client knows how to interpret lists in review data.
@@ -391,17 +399,23 @@ def reposetup(ui, repo):
if not ui.config('reviewboard', 'password', None):
raise util.Abort(_('Please set reviewboard.password to the password '
'for priveleged communications with Review Board.'))
if not ui.config('bugzilla', 'url', None):
raise util.Abort(_('Please set bugzilla.url to the URL of the '
'Bugzilla instance to talk to.'))
- if ui.configbool('phases', 'publish', True):
+ # TRACKING hg33+
+ if have_config_registrar:
+ publish = ui.configbool('phases', 'publish')
+ else:
+ publish = ui.configbool('phases', 'publish', True)
+
+ if publish:
raise util.Abort(_('reviewboard server extension is only compatible '
'with non-publishing repositories.'))
ui.setconfig('hooks', 'changegroup.reviewboard', changegrouphook)
# This shouldn't be needed to prevent pushes, as the "heads" wireproto
# wrapping should kill them. However, this is defense in depth and will
# kill all changegroup additions, even if the server operator is dumb.