changelog: get access to config options

Summary: Pass `uiconfig` to changelog so it can read config options.

Reviewed By: sfilipco

Differential Revision: D16683785

fbshipit-source-id: a64cfbe2cefa6b20ec695d2766bcfe878c764323
This commit is contained in:
Jun Wu 2019-08-15 12:45:39 -07:00 committed by Facebook Github Bot
parent 6d7c287ab2
commit 8b4c670550
8 changed files with 19 additions and 17 deletions

View File

@ -547,7 +547,7 @@ def perftags(ui, repo, **opts):
repocleartagscache = repocleartagscachefunc(repo)
def t():
repo.changelog = changelog.changelog(svfs)
repo.changelog = changelog.changelog(svfs, uiconfig=ui.uiconfig())
repo.manifestlog = manifest.manifestlog(svfs, repo)
repocleartagscache()
return len(repo.tags())

View File

@ -339,8 +339,8 @@ def fastlogfollow(orig, repo, subset, x, name, followfirst=False):
class readonlychangelog(object):
def __init__(self, opener):
self._changelog = changelog.changelog(opener)
def __init__(self, *args, **kwargs):
self._changelog = changelog.changelog(*args, **kwargs)
def parentrevs(self, rev):
return self._changelog.parentrevs(rev)
@ -390,7 +390,7 @@ class LocalIteratorThread(Thread):
# Create a private instance of changelog to avoid trampling
# internal caches of other threads
c = readonlychangelog(repo.svfs)
c = readonlychangelog(repo.svfs, uiconfig=repo.ui.uiconfig())
self.generator = originator(c.parentrevs, rev)
self.filefunc = c.readfiles
self.ui = repo.ui
@ -450,7 +450,7 @@ class FastLogThread(Thread):
self.rev = rev
self.paths = list(paths)
self.ui = repo.ui
self.changelog = readonlychangelog(repo.svfs)
self.changelog = readonlychangelog(repo.svfs, uiconfig=repo.ui.uiconfig())
self._stop = Event()
self._paths_to_fetch = 0

View File

@ -235,7 +235,7 @@ class trivialserializer(object):
def readvalue(repo, path, node):
filectx = repo.filectx(path, fileid=node)
if filectx.node() == nullid:
repo.changelog = changelog.changelog(repo.svfs)
repo.changelog = changelog.changelog(repo.svfs, uiconfig=repo.ui.uiconfig())
filectx = repo.filectx(path, fileid=node)
return lz4wrapper.lz4compresshc(createfileblob(filectx))

View File

@ -183,8 +183,8 @@ class bundlerevlog(revlog.revlog):
class bundlechangelog(bundlerevlog, changelog.changelog):
def __init__(self, opener, cgunpacker):
changelog.changelog.__init__(self, opener)
def __init__(self, opener, cgunpacker, uiconfig):
changelog.changelog.__init__(self, opener, uiconfig)
linkmapper = lambda x: x
bundlerevlog.__init__(self, opener, self.indexfile, cgunpacker, linkmapper)
self._visibleheads.addbundleheads([self.node(r) for r in self.bundleheads])
@ -394,7 +394,7 @@ class bundlerepository(localrepo.localrepository):
def changelog(self):
# consume the header if it exists
self._cgunpacker.changelogheader()
c = bundlechangelog(self.svfs, self._cgunpacker)
c = bundlechangelog(self.svfs, self._cgunpacker, self.ui.uiconfig())
self.manstart = self._cgunpacker.tell()
return c

View File

@ -274,7 +274,7 @@ class changelogrevision(object):
class changelog(revlog.revlog):
def __init__(self, opener, trypending=False):
def __init__(self, opener, uiconfig, trypending=False):
"""Load a changelog revlog using an opener.
If ``trypending`` is true, we attempt to load the index from a
@ -284,6 +284,7 @@ class changelog(revlog.revlog):
It exists in a separate file to facilitate readers (such as
hooks processes) accessing data before a transaction is finalized.
"""
self._uiconfig = uiconfig
self._visibleheads = self._loadvisibleheads(opener)
if trypending and opener.exists("00changelog.i.a"):

View File

@ -780,6 +780,7 @@ class localrepository(object):
def changelog(self):
return changelog.changelog(
self.svfs,
uiconfig=self.ui.uiconfig(),
trypending=txnutil.mayhavesharedpending(self.root, self.sharedroot),
)

View File

@ -487,7 +487,7 @@ def _revlogfrompath(repo, path):
An instance of the appropriate class is returned.
"""
if path == "00changelog.i":
return changelog.changelog(repo.svfs)
return changelog.changelog(repo.svfs, uiconfig=repo.ui.uiconfig())
elif path.endswith("00manifest.i"):
mandir = path[: -len("00manifest.i")]
return manifest.manifestrevlog(repo.svfs, dir=mandir)

View File

@ -27,7 +27,7 @@ We approximate that by reducing the read buffer to 1 byte.
summary: change foo
$ cat >> test.py << EOF
> from edenscm.mercurial import changelog, vfs
> from edenscm.mercurial import changelog, uiconfig, vfs
> from edenscm.mercurial.node import *
>
> class singlebyteread(object):
@ -49,7 +49,7 @@ We approximate that by reducing the read buffer to 1 byte.
> return singlebyteread(f)
> return wrapper
>
> cl = changelog.changelog(opener('.hg/store'))
> cl = changelog.changelog(opener('.hg/store'), uiconfig.uiconfig())
> print len(cl), 'revisions:'
> for r in cl:
> print short(cl.node(r))
@ -68,8 +68,8 @@ Test SEGV caused by bad revision passed to reachableroots() (issue4775):
$ cd a
$ $PYTHON <<EOF
> from edenscm.mercurial import changelog, vfs
> cl = changelog.changelog(vfs.vfs('.hg/store'))
> from edenscm.mercurial import changelog, uiconfig, vfs
> cl = changelog.changelog(vfs.vfs('.hg/store'), uiconfig.uiconfig())
> print 'good heads:'
> for head in [0, len(cl) - 1, -1]:
> print'%s: %r' % (head, cl.reachableroots(0, [head], [0]))
@ -148,8 +148,8 @@ Test corrupted p1/p2 fields that could cause SEGV at parsers.c:
$ cat <<EOF > test.py
> import sys
> from edenscm.mercurial import changelog, vfs
> cl = changelog.changelog(vfs.vfs(sys.argv[1]))
> from edenscm.mercurial import changelog, uiconfig, vfs
> cl = changelog.changelog(vfs.vfs(sys.argv[1]), uiconfig.uiconfig())
> n0, n1 = cl.node(0), cl.node(1)
> ops = [
> ('reachableroots',