# HG changeset patch # User FUJIWARA Katsunori # Date 1436457591 -32400 # Node ID 7a9ef8608a1d40240a42f21380791aadb074c75e # Parent 026105c442d7f20d239c1e5e5fac1cfa080323da subrepo: prefetch ctx.repo() for efficiency and centralization 'subrepo.state()' refers same 'ctx.repo()' in many places and times. diff -r 026105c442d7 -r 7a9ef8608a1d mercurial/subrepo.py --- a/mercurial/subrepo.py Thu Jul 02 21:39:31 2015 +0900 +++ b/mercurial/subrepo.py Fri Jul 10 00:59:51 2015 +0900 @@ -62,6 +62,7 @@ (key in types dict)) """ p = config.config() + repo = ctx.repo() def read(f, sections=None, remap=None): if f in ctx: try: @@ -71,11 +72,10 @@ raise # handle missing subrepo spec files as removed ui.warn(_("warning: subrepo spec file \'%s\' not found\n") % - util.pathto(ctx.repo().root, ctx.repo().getcwd(), f)) + util.pathto(repo.root, repo.getcwd(), f)) return p.parse(f, data, sections, remap, read) else: - repo = ctx.repo() raise util.Abort(_("subrepo spec file \'%s\' not found") % util.pathto(repo.root, repo.getcwd(), f)) @@ -95,7 +95,6 @@ try: revision, path = l.split(" ", 1) except ValueError: - repo = ctx.repo() raise util.Abort(_("invalid subrepository revision " "specifier in \'%s\' line %d") % (util.pathto(repo.root, repo.getcwd(), @@ -132,7 +131,7 @@ src = src.lstrip() # strip any extra whitespace after ']' if not util.url(src).isabs(): - parent = _abssource(ctx.repo(), abort=False) + parent = _abssource(repo, abort=False) if parent: parent = util.url(parent) parent.path = posixpath.join(parent.path or '', src)