codemod: fix compatibility with the upstream revset refactoring

Summary:
`mercurial.revset` was recently split into `revset + revsetlang + smartset`.
Update our code accordingly.

D4604848 has fixed the `revsetlang` part. This patch fixes the remaining
`smartset` part.

Also fixes some test failures introduced by D4547080.

Test Plan: `arc unit`

Reviewers: #mercurial

Subscribers: jeroenv, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4595417
This commit is contained in:
Jun Wu 2017-02-23 13:09:59 -08:00
parent 01fdb5bf0d
commit 635683876d
4 changed files with 39 additions and 21 deletions

View File

@ -12,7 +12,6 @@ from mercurial import (
util,
)
from mercurial.i18n import _
import inspect
testedwith = 'ships-with-fb-hgext'
@ -104,5 +103,5 @@ def recordfilter(ui, headers, operation=None):
h = specials[h.filename()]
applied[h.filename()] = [h] + h.hunks
return (sum([h for h in applied.itervalues()
if h[0].special() or len(h) > 1], []), {})
return (sum([i for i in applied.itervalues()
if i[0].special() or len(i) > 1], []), {})

View File

@ -271,10 +271,10 @@ def getfastlogrevs(orig, repo, pats, opts):
'only_merges', 'prune', 'user']
if match.anypats() or any(opts.get(opt) for opt in complex):
f = fastlog(repo, rev, dirs, None)
revs = revset.generatorset(f, iterasc=False)
revs = smartset.generatorset(f, iterasc=False)
revs.reverse()
if not revs:
return revset.baseset([]), None, None
return smartset.baseset([]), None, None
expr, filematcher = cmdutil._makelogrevset(repo, pats, opts, revs)
matcher = revset.match(repo.ui, expr)
matched = matcher(repo, revs)
@ -484,7 +484,7 @@ class FastLogThread(Thread):
self._paths_to_fetch = len(paths)
for path in paths:
g = self.generate(path)
gen = revset.generatorset(g, iterasc=False)
gen = smartset.generatorset(g, iterasc=False)
gen.reverse()
if revs:
revs = smartset.addset(revs, gen, ascending=False)

View File

@ -39,6 +39,7 @@ from mercurial import (
revset,
revsetlang,
scmutil,
smartset,
templatekw,
util,
)
@ -299,7 +300,7 @@ def getdag(ui, repo, revs, master):
gp = gpcache.get(mpar)
if gp is None:
gp = gpcache[mpar] = revset.reachableroots(
repo, revset.baseset(revs), [mpar])
repo, smartset.baseset(revs), [mpar])
if not gp:
parents.append((graphmod.MISSINGPARENT, mpar))
else:

View File

@ -12,22 +12,40 @@ import repack as repackmod
from mercurial.node import hex
from mercurial.i18n import _
from mercurial.extensions import wrapfunction
from mercurial import error, util
from mercurial import repair, extensions, revlog, cmdutil
from mercurial import copies, store, context, changegroup, localrepo, changelog
from mercurial import commands, scmutil, dispatch, merge, context
from mercurial import templatekw, repoview, revset, hg, patch
from mercurial import match, exchange
from mercurial import (
changegroup,
changelog,
cmdutil,
commands,
context,
context,
copies,
debugcommands as hgdebugcommands,
dispatch,
error,
exchange,
extensions,
hg,
localrepo,
match,
merge,
patch,
repair,
repoview,
revlog,
revset,
scmutil,
smartset,
store,
templatekw,
util,
)
import os
import traceback
try:
# debug commands were moved to a separate module
# importing it ensures the commands are registered
from mercurial import debugcommands as hgdebugcommands
hgdebugcommands.command
except ImportError:
pass
# ensures debug commands are registered
hgdebugcommands.command
try:
from mercurial import streamclone
@ -527,7 +545,7 @@ def filelogrevset(orig, repo, subset, x):
for actx in fctx.ancestors():
s.add(actx.linkrev())
return revset.baseset([r for r in subset if r in s])
return smartset.baseset([r for r in subset if r in s])
@command('gc', [], _('hg gc [REPO...]'), norepo=True)
def gc(ui, *args, **opts):