reviewboard: support calling showlist() with Mercurial 4.2 (
bug 1385979); r?glob
The prototype of templatekw.showlist() changed in Mercurial 4.2.
While I normally try to call one form and fall back on TypeError,
the use of **kwargs in the old form makes this difficult. So we
use inspect.getargspec() to see what arguments it expects.
MozReview-Commit-ID: 88pZtlA1jXl
--- a/hgext/reviewboard/client.py
+++ b/hgext/reviewboard/client.py
@@ -17,22 +17,22 @@ This extension adds new options to the `
testing or ensuring certain commits are present on the remote.
* --reviewid The review identifier to use. Pushes using the same
review ID will overwrite existing reviews for that ID.
* -c Single changeset to review.
"""
import contextlib
import errno
+import inspect
import json
import os
import re
import sys
import urllib
-import urllib2
from mercurial import (
cmdutil,
commands,
context,
demandimport,
encoding,
error,
@@ -41,17 +41,16 @@ from mercurial import (
hg,
httppeer,
localrepo,
obsolete,
phases,
scmutil,
sshpeer,
templatekw,
- url as urlmod,
util,
)
from mercurial.i18n import _
from mercurial.node import bin, hex
OUR_DIR = os.path.normpath(os.path.dirname(__file__))
execfile(os.path.join(OUR_DIR, '..', 'bootstrap.py'))
@@ -980,17 +979,23 @@ def template_reviews(repo, ctx, revcache
r = repo.reviews.getreviewrequest(rid)
# Bug 1065022 add parent review info to this data structure.
reviews.append({
'url': repo.reviews.reviewurl(rid),
'status': r.get('status'),
})
revcache['reviews'] = reviews
- return templatekw.showlist('review', revcache['reviews'])
+
+ # Mercurial 4.2+ take mapping as a positional argument. Older versions
+ # take mapping as **kwargs.
+ if 'mapping' in inspect.getargspec(templatekw.showlist).args:
+ return templatekw.showlist('review', revcache['reviews'], {})
+ else:
+ return templatekw.showlist('review', revcache['reviews'])
@command('fetchreviews', [], _('hg fetchreviews'))
def fetchreviews(ui, repo, **opts):
"""Fetch information about your active code reviews.
When you initiate a code review by pushing to a review-enabled remote,
your repository will track the existence of that code review.