[Differential] [Request, 10 lines] D97: revset: pass repo when passing ui

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Jul 15 23:42:03 UTC 2017


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The repo instance is currently only used to provide a changeset
  lookup function as part of parsing revsets. I /think/ this allows
  node fragments to resolve. I'm not sure why we wouldn't want this
  to always "just work" if parsing a revset string.
  
  Plus, an upcoming commit will introduce a new consumer that needs a
  handle on the repo. So passing it more often will make that code
  work more.
  
  Passing a repo instance in all callers of revset.match* results in
  a bunch of test changes. Notably, branch and tags caches get
  populated as part of evaluating revsets. I'm not sure if this is
  desirable. So this patch takes the conservative approach and only
  passes the repo if we're passing a ui instance.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D97

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/hgweb/webcommands.py
  mercurial/templater.py

CHANGE DETAILS

Index: mercurial/templater.py
===================================================================
--- mercurial/templater.py
+++ mercurial/templater.py
@@ -874,7 +874,7 @@
     repo = ctx.repo()
 
     def query(expr):
-        m = revsetmod.match(repo.ui, expr)
+        m = revsetmod.match(repo.ui, expr, repo=repo)
         return m(repo)
 
     if len(args) > 1:
Index: mercurial/hgweb/webcommands.py
===================================================================
--- mercurial/hgweb/webcommands.py
+++ mercurial/hgweb/webcommands.py
@@ -260,7 +260,7 @@
         if not funcsused.issubset(revset.safesymbols):
             return MODE_KEYWORD, query
 
-        mfunc = revset.match(web.repo.ui, revdef)
+        mfunc = revset.match(web.repo.ui, revdef, repo=web.repo)
         try:
             revs = mfunc(web.repo)
             return MODE_REVSET, revs
Index: mercurial/cmdutil.py
===================================================================
--- mercurial/cmdutil.py
+++ mercurial/cmdutil.py
@@ -2276,7 +2276,8 @@
         if not (revs.isdescending() or revs.istopo()):
             revs.sort(reverse=True)
     if expr:
-        matcher = revset.match(repo.ui, expr, order=revset.followorder)
+        matcher = revset.match(repo.ui, expr, repo=repo,
+                               order=revset.followorder)
         revs = matcher(repo, revs)
     if limit is not None:
         limitedrevs = []
@@ -2302,7 +2303,8 @@
         return smartset.baseset([]), None, None
     expr, filematcher = _makelogrevset(repo, pats, opts, revs)
     if expr:
-        matcher = revset.match(repo.ui, expr, order=revset.followorder)
+        matcher = revset.match(repo.ui, expr, repo=repo,
+                               order=revset.followorder)
         revs = matcher(repo, revs)
     if limit is not None:
         limitedrevs = []


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list