Re: D4039: [RFC] shortest: cache disambiguation revset

2018-08-04 Thread Yuya Nishihara
> (I don't know what a resolver is yet, but I'll figure that out later).

Perhaps I mistook a function name. I just meant `shortesthexnodeidprefix()`
could be turned into a closure having node cache.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4039: [RFC] shortest: cache disambiguation revset

2018-08-03 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D4039#63460, @yuja wrote:
  
  > >   This doesn't seem like the right way to cache it. Suggestions?
  >
  > Suppose the cache exists mainly for templating, templatefuncs.shortest()
  >  can pass in a cached revset to resolvehexnodeidprefix(), and we don't have
  >  to take care of cache invalidation.
  
  
  Yep, it's pretty much only for templating, so that's a good suggestion. I'll 
start working on that. Thanks!
  
  > If we want to cache a prefix tree, maybe it could be turned into a 
"resolver"
  >  object which the templater creates at the first shortest() call.
  
  I have a stack of changes that make the nodetree struct a Python type that 
can be used for this. I might clean that up and send it another day. I'll try 
to follow your advice here then (I don't know what a resolver is yet, but I'll 
figure that out later).

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D4039: [RFC] shortest: cache disambiguation revset

2018-08-03 Thread Yuya Nishihara
>   This doesn't seem like the right way to cache it. Suggestions?

Suppose the cache exists mainly for templating, templatefuncs.shortest()
can pass in a cached revset to resolvehexnodeidprefix(), and we don't have
to take care of cache invalidation.

If we want to cache a prefix tree, maybe it could be turned into a "resolver"
object which the templater creates at the first shortest() call.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4039: [RFC] shortest: cache disambiguation revset

2018-08-03 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   This doesn't seem like the right way to cache it. Suggestions?
  
  Suppose the cache exists mainly for templating, templatefuncs.shortest()
  can pass in a cached revset to resolvehexnodeidprefix(), and we don't have
  to take care of cache invalidation.
  
  If we want to cache a prefix tree, maybe it could be turned into a "resolver"
  object which the templater creates at the first shortest() call.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4039: [RFC] shortest: cache disambiguation revset

2018-08-01 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This doesn't seem like the right way to cache it. Suggestions?

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -491,7 +491,9 @@
 
 revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
 if revset:
-revs = repo.anyrevs([revset], user=True)
+if not util.safehasattr(repo, '_cacheddisambiguationrevs'):
+repo._cacheddisambiguationrevs = repo.anyrevs([revset], user=True)
+revs = repo._cacheddisambiguationrevs
 if cl.rev(node) in revs:
 hexnode = hex(node)
 for length in range(minlength, len(hexnode) + 1):



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel