D451 is going to add an order parameter so let's update our code.
Also remove the wrapping of revset.symbols['stringset'], which is no
longer needed by the current Mercurial.
durham |
Restricted Project |
D451 is going to add an order parameter so let's update our code.
Also remove the wrapping of revset.symbols['stringset'], which is no
longer needed by the current Mercurial.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext3rd/fbconduit.py (5 lines) | |||
M | hgext3rd/gitrevset.py (6 lines) | |||
M | hgext3rd/phrevset.py (5 lines) |
def extsetup(ui): | def extsetup(ui): | ||||
if not conduit_config(ui): | if not conduit_config(ui): | ||||
ui.warn(_('No conduit host specified in config; disabling fbconduit\n')) | ui.warn(_('No conduit host specified in config; disabling fbconduit\n')) | ||||
return | return | ||||
revset.symbols['gitnode'] = gitnode | revset.symbols['gitnode'] = gitnode | ||||
extensions.wrapfunction(revset, 'stringset', overridestringset) | extensions.wrapfunction(revset, 'stringset', overridestringset) | ||||
revset.symbols['stringset'] = revset.stringset | |||||
revset.methods['string'] = revset.stringset | revset.methods['string'] = revset.stringset | ||||
revset.methods['symbol'] = revset.stringset | revset.methods['symbol'] = revset.stringset | ||||
def conduit_config(ui, host=None, path=None, protocol=None): | def conduit_config(ui, host=None, path=None, protocol=None): | ||||
global conduit_host, conduit_path, conduit_protocol | global conduit_host, conduit_path, conduit_protocol | ||||
conduit_host = host or ui.config('fbconduit', 'host') | conduit_host = host or ui.config('fbconduit', 'host') | ||||
conduit_path = path or ui.config('fbconduit', 'path') | conduit_path = path or ui.config('fbconduit', 'path') | ||||
conduit_protocol = protocol or ui.config('fbconduit', 'protocol') | conduit_protocol = protocol or ui.config('fbconduit', 'protocol') | ||||
n, lasterror))) | n, lasterror))) | ||||
else: | else: | ||||
repo.ui.warn(("Could not translate revision {0}\n".format(n))) | repo.ui.warn(("Could not translate revision {0}\n".format(n))) | ||||
return subset.filter(lambda r: False) | return subset.filter(lambda r: False) | ||||
rn = repo[node.bin(hghash)].rev() | rn = repo[node.bin(hghash)].rev() | ||||
return subset.filter(lambda r: r == rn) | return subset.filter(lambda r: r == rn) | ||||
def overridestringset(orig, repo, subset, x): | def overridestringset(orig, repo, subset, x, *args, **kwargs): | ||||
# Is the given revset a phabricator hg hash (ie: rHGEXTaaacb34aacb34aa) | # Is the given revset a phabricator hg hash (ie: rHGEXTaaacb34aacb34aa) | ||||
phabmatch = phabhashre.match(x) | phabmatch = phabhashre.match(x) | ||||
if phabmatch: | if phabmatch: | ||||
phabrepo = phabmatch.group(1) | phabrepo = phabmatch.group(1) | ||||
phabhash = phabmatch.group(2) | phabhash = phabmatch.group(2) | ||||
# The hash may be a git hash | # The hash may be a git hash | ||||
if phabrepo in repo.ui.configlist('fbconduit', 'gitcallsigns', []): | if phabrepo in repo.ui.configlist('fbconduit', 'gitcallsigns', []): | ||||
return overridestringset(orig, repo, subset, 'g%s' % phabhash) | return overridestringset(orig, repo, subset, 'g%s' % phabhash) | ||||
m = githashre.match(x) | m = githashre.match(x) | ||||
if m is not None: | if m is not None: | ||||
githash = m.group(1) | githash = m.group(1) | ||||
if len(githash) == 40: | if len(githash) == 40: | ||||
return gitnode(repo, subset, ('string', githash)) | return gitnode(repo, subset, ('string', githash)) | ||||
else: | else: | ||||
raise error.Abort('git hash must be 40 characters') | raise error.Abort('git hash must be 40 characters') | ||||
return orig(repo, subset, x) | return orig(repo, subset, x, *args, **kwargs) |
"You can view the diff at http://phabricator.fb.com/D%s\n\n" | "You can view the diff at http://phabricator.fb.com/D%s\n\n" | ||||
repo.ui.warn(msg % (diffid, diffid)) | repo.ui.warn(msg % (diffid, diffid)) | ||||
return [] | return [] | ||||
else: | else: | ||||
raise error.Abort('Conduit returned unknown ' | raise error.Abort('Conduit returned unknown ' | ||||
'sourceControlSystem "%s"' % vcs) | 'sourceControlSystem "%s"' % vcs) | ||||
def revsetstringset(orig, repo, subset, revstr): | def revsetstringset(orig, repo, subset, revstr, *args, **kwargs): | ||||
"""Wrapper that recognizes revisions starting with 'D'""" | """Wrapper that recognizes revisions starting with 'D'""" | ||||
if revstr.startswith('D') and revstr[1:].isdigit(): | if revstr.startswith('D') and revstr[1:].isdigit(): | ||||
return smartset.baseset(revsetdiff(repo, subset, revstr[1:])) | return smartset.baseset(revsetdiff(repo, subset, revstr[1:])) | ||||
return orig(repo, subset, revstr) | return orig(repo, subset, revstr, *args, **kwargs) | ||||
def extsetup(ui): | def extsetup(ui): | ||||
extensions.wrapfunction(revset, 'stringset', revsetstringset) | extensions.wrapfunction(revset, 'stringset', revsetstringset) | ||||
revset.symbols['stringset'] = revset.stringset | |||||
revset.methods['string'] = revset.stringset | revset.methods['string'] = revset.stringset | ||||
revset.methods['symbol'] = revset.stringset | revset.methods['symbol'] = revset.stringset | ||||
Import keyword is missing here