D3313: scmutil: make shortesthexnodeidprefix() use unfiltered repo

2018-04-15 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa2c30721743f: scmutil: make shortesthexnodeidprefix() use 
unfiltered repo (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3313?vs=8255=8302

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

AFFECTED FILES
  hgext/show.py
  mercurial/scmutil.py
  mercurial/templatefuncs.py

CHANGE DETAILS

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -587,11 +587,8 @@
 # i18n: "shortest" is a keyword
 _("shortest() expects an integer minlength"))
 
-# _partialmatch() of filtered changelog could take O(len(repo)) time,
-# which would be unacceptably slow. so we look for hash collision in
-# unfiltered space, which means some hashes may be slightly longer.
 repo = context.resource(mapping, 'ctx')._repo
-return scmutil.shortesthexnodeidprefix(repo.unfiltered(), node, minlength)
+return scmutil.shortesthexnodeidprefix(repo, node, minlength)
 
 @templatefunc('strip(text[, chars])')
 def strip(context, mapping, args):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -436,16 +436,19 @@
 
 def resolvehexnodeidprefix(repo, prefix):
 # Uses unfiltered repo because it's faster when prefix is ambiguous/
-# This matches the "shortest" template function.
+# This matches the shortesthexnodeidprefix() function below.
 node = repo.unfiltered().changelog._partialmatch(prefix)
 if node is None:
 return
 repo.changelog.rev(node)  # make sure node isn't filtered
 return node
 
 def shortesthexnodeidprefix(repo, hexnode, minlength=1):
 """Find the shortest unambiguous prefix that matches hexnode."""
-return repo.changelog.shortest(hexnode, minlength)
+# _partialmatch() of filtered changelog could take O(len(repo)) time,
+# which would be unacceptably slow. so we look for hash collision in
+# unfiltered space, which means some hashes may be slightly longer.
+return repo.unfiltered().changelog.shortest(hexnode, minlength)
 
 def isrevsymbol(repo, symbol):
 """Checks if a symbol exists in the repo.
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -447,10 +447,8 @@
 """
 if not revs:
 return minlen
-# don't use filtered repo because it's slow. see templater.shortest().
 cl = repo.changelog
-return max(len(scmutil.shortesthexnodeidprefix(repo.unfiltered(),
-   hex(cl.node(r)),
+return max(len(scmutil.shortesthexnodeidprefix(repo, hex(cl.node(r)),
minlen)) for r in revs)
 
 # Adjust the docstring of the show command so it shows all registered views.



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


D3313: scmutil: make shortesthexnodeidprefix() use unfiltered repo

2018-04-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 8255.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3313?vs=8250=8255

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

AFFECTED FILES
  hgext/show.py
  mercurial/scmutil.py
  mercurial/templatefuncs.py

CHANGE DETAILS

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -587,11 +587,8 @@
 # i18n: "shortest" is a keyword
 _("shortest() expects an integer minlength"))
 
-# _partialmatch() of filtered changelog could take O(len(repo)) time,
-# which would be unacceptably slow. so we look for hash collision in
-# unfiltered space, which means some hashes may be slightly longer.
 repo = context.resource(mapping, 'ctx')._repo
-return scmutil.shortesthexnodeidprefix(repo.unfiltered(), node, minlength)
+return scmutil.shortesthexnodeidprefix(repo, node, minlength)
 
 @templatefunc('strip(text[, chars])')
 def strip(context, mapping, args):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -436,16 +436,19 @@
 
 def resolvehexnodeidprefix(repo, prefix):
 # Uses unfiltered repo because it's faster when prefix is ambiguous/
-# This matches the "shortest" template function.
+# This matches the shortesthexnodeidprefix() function below.
 node = repo.unfiltered().changelog._partialmatch(prefix)
 if node is None:
 return
 repo.changelog.rev(node)  # make sure node isn't filtered
 return node
 
 def shortesthexnodeidprefix(repo, hexnode, minlength=1):
 """Find the shortest unambiguous prefix that matches hexnode."""
-return repo.changelog.shortest(hexnode, minlength)
+# _partialmatch() of filtered changelog could take O(len(repo)) time,
+# which would be unacceptably slow. so we look for hash collision in
+# unfiltered space, which means some hashes may be slightly longer.
+return repo.unfiltered().changelog.shortest(hexnode, minlength)
 
 def isrevsymbol(repo, symbol):
 """Checks if a symbol exists in the repo.
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -447,10 +447,8 @@
 """
 if not revs:
 return minlen
-# don't use filtered repo because it's slow. see templater.shortest().
 cl = repo.changelog
-return max(len(scmutil.shortesthexnodeidprefix(repo.unfiltered(),
-   hex(cl.node(r)),
+return max(len(scmutil.shortesthexnodeidprefix(repo, hex(cl.node(r)),
minlen)) for r in revs)
 
 # Adjust the docstring of the show command so it shows all registered views.



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


D3313: scmutil: make shortesthexnodeidprefix() use unfiltered repo

2018-04-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 8250.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3313?vs=8119=8250

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

AFFECTED FILES
  hgext/show.py
  mercurial/scmutil.py
  mercurial/templatefuncs.py

CHANGE DETAILS

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -587,11 +587,8 @@
 # i18n: "shortest" is a keyword
 _("shortest() expects an integer minlength"))
 
-# _partialmatch() of filtered changelog could take O(len(repo)) time,
-# which would be unacceptably slow. so we look for hash collision in
-# unfiltered space, which means some hashes may be slightly longer.
 repo = context.resource(mapping, 'ctx')._repo
-return scmutil.shortesthexnodeidprefix(repo.unfiltered(), node, minlength)
+return scmutil.shortesthexnodeidprefix(repo, node, minlength)
 
 @templatefunc('strip(text[, chars])')
 def strip(context, mapping, args):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -436,16 +436,19 @@
 
 def resolvehexnodeidprefix(repo, prefix):
 # Uses unfiltered repo because it's faster when prefix is ambiguous/
-# This matches the "shortest" template function.
+# This matches the shortesthexnodeidprefix() function below.
 node = repo.unfiltered().changelog._partialmatch(prefix)
 if node is None:
 return
 repo.changelog.rev(node)  # make sure node isn't filtered
 return node
 
 def shortesthexnodeidprefix(repo, hexnode, minlength=1):
 """Find the shortest unambiguous prefix that matches hexnode."""
-return repo.changelog.shortest(hexnode)
+# _partialmatch() of filtered changelog could take O(len(repo)) time,
+# which would be unacceptably slow. so we look for hash collision in
+# unfiltered space, which means some hashes may be slightly longer.
+return repo.unfiltered().changelog.shortest(hexnode)
 
 def isrevsymbol(repo, symbol):
 """Checks if a symbol exists in the repo.
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -447,10 +447,8 @@
 """
 if not revs:
 return minlen
-# don't use filtered repo because it's slow. see templater.shortest().
 cl = repo.changelog
-return max(len(scmutil.shortesthexnodeidprefix(repo.unfiltered(),
-   hex(cl.node(r)),
+return max(len(scmutil.shortesthexnodeidprefix(repo, hex(cl.node(r)),
minlen)) for r in revs)
 
 # Adjust the docstring of the show command so it shows all registered views.



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


D3313: scmutil: make shortesthexnodeidprefix() use unfiltered repo

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

REVISION SUMMARY
  Both callers were doing this, and resolvehexnodeidprefix() was also
  working on the unfiltered repo, so it makes more sense to have it all
  in one place.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/show.py
  mercurial/scmutil.py
  mercurial/templatefuncs.py

CHANGE DETAILS

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -587,11 +587,8 @@
 # i18n: "shortest" is a keyword
 _("shortest() expects an integer minlength"))
 
-# _partialmatch() of filtered changelog could take O(len(repo)) time,
-# which would be unacceptably slow. so we look for hash collision in
-# unfiltered space, which means some hashes may be slightly longer.
 repo = context.resource(mapping, 'ctx')._repo
-return scmutil.shortesthexnodeidprefix(repo.unfiltered(), node, minlength)
+return scmutil.shortesthexnodeidprefix(repo, node, minlength)
 
 @templatefunc('strip(text[, chars])')
 def strip(context, mapping, args):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -436,16 +436,19 @@
 
 def resolvehexnodeidprefix(repo, prefix):
 # Uses unfiltered repo because it's faster when prefix is ambiguous/
-# This matches the "shortest" template function.
+# This matches the shortesthexnodeidprefix() function below.
 node = repo.unfiltered().changelog._partialmatch(prefix)
 if node is None:
 return
 repo.changelog.rev(node)  # make sure node isn't filtered
 return node
 
 def shortesthexnodeidprefix(repo, hexnode, minlength=1):
 """Find the shortest unambiguous prefix that matches hexnode."""
-cl = repo.changelog
+# _partialmatch() of filtered changelog could take O(len(repo)) time,
+# which would be unacceptably slow. so we look for hash collision in
+# unfiltered space, which means some hashes may be slightly longer.
+cl = repo.unfiltered().changelog
 def isvalid(test):
 try:
 if cl._partialmatch(test) is None:
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -447,10 +447,8 @@
 """
 if not revs:
 return minlen
-# don't use filtered repo because it's slow. see templater.shortest().
 cl = repo.changelog
-return max(len(scmutil.shortesthexnodeidprefix(repo.unfiltered(),
-   hex(cl.node(r)),
+return max(len(scmutil.shortesthexnodeidprefix(repo, hex(cl.node(r)),
minlen)) for r in revs)
 
 # Adjust the docstring of the show command so it shows all registered views.



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