D2279: node: make bin() be a wrapper instead of just an alias
This revision was automatically updated to reflect the committed changes. Closed by commit rHGaba1d578c97f: node: make bin() be a wrapper instead of just an alias (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2279?vs=5784&id=5788 REVISION DETAIL https://phab.mercurial-scm.org/D2279 AFFECTED FILES hgext/histedit.py mercurial/node.py mercurial/revlog.py CHANGE DETAILS diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -13,7 +13,6 @@ from __future__ import absolute_import -import binascii import collections import contextlib import errno @@ -1430,7 +1429,7 @@ if maybewdir: raise error.WdirUnsupported return None -except (TypeError, binascii.Error): +except TypeError: pass def lookup(self, id): diff --git a/mercurial/node.py b/mercurial/node.py --- a/mercurial/node.py +++ b/mercurial/node.py @@ -11,7 +11,14 @@ # This ugly style has a noticeable effect in manifest parsing hex = binascii.hexlify -bin = binascii.unhexlify +# Adapt to Python 3 API changes. If this ends up showing up in +# profiles, we can use this version only on Python 3, and forward +# binascii.unhexlify like we used to on Python 2. +def bin(s): +try: +return binascii.unhexlify(s) +except binascii.Error as e: +raise TypeError(e) nullrev = -1 nullid = b"\0" * 20 diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -183,7 +183,6 @@ from __future__ import absolute_import -import binascii import errno import os @@ -426,7 +425,7 @@ rulehash = rule.strip().split(' ', 1)[0] try: rev = node.bin(rulehash) -except (TypeError, binascii.Error): +except TypeError: raise error.ParseError("invalid changeset %s" % rulehash) return cls(state, rev) To: durin42, #hg-reviewers, martinvonz, indygreg Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2279: node: make bin() be a wrapper instead of just an alias
durin42 updated this revision to Diff 5784. durin42 edited the summary of this revision. Herald added a reviewer: indygreg. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2279?vs=5761&id=5784 REVISION DETAIL https://phab.mercurial-scm.org/D2279 AFFECTED FILES hgext/histedit.py mercurial/node.py mercurial/revlog.py CHANGE DETAILS diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -13,7 +13,6 @@ from __future__ import absolute_import -import binascii import collections import contextlib import errno @@ -1430,7 +1429,7 @@ if maybewdir: raise error.WdirUnsupported return None -except (TypeError, binascii.Error): +except TypeError: pass def lookup(self, id): diff --git a/mercurial/node.py b/mercurial/node.py --- a/mercurial/node.py +++ b/mercurial/node.py @@ -11,7 +11,14 @@ # This ugly style has a noticeable effect in manifest parsing hex = binascii.hexlify -bin = binascii.unhexlify +# Adapt to Python 3 API changes. If this ends up showing up in +# profiles, we can use this version only on Python 3, and forward +# binascii.unhexlify like we used to on Python 2. +def bin(s): +try: +return binascii.unhexlify(s) +except binascii.Error as e: +raise TypeError(e) nullrev = -1 nullid = b"\0" * 20 diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -183,7 +183,6 @@ from __future__ import absolute_import -import binascii import errno import os @@ -426,7 +425,7 @@ rulehash = rule.strip().split(' ', 1)[0] try: rev = node.bin(rulehash) -except (TypeError, binascii.Error): +except TypeError: raise error.ParseError("invalid changeset %s" % rulehash) return cls(state, rev) To: durin42, #hg-reviewers, martinvonz, indygreg Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2279: node: make bin() be a wrapper instead of just an alias
durin42 added a comment. In https://phab.mercurial-scm.org/D2279#37680, @martinvonz wrote: > Also make this commit back out https://phab.mercurial-scm.org/rHG30d0cb279bacf791577e90124b2a94018588f0b8? done REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2279 To: durin42, #hg-reviewers, martinvonz, indygreg Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2279: node: make bin() be a wrapper instead of just an alias
martinvonz requested changes to this revision. martinvonz added a comment. This revision now requires changes to proceed. Also make this commit back out https://phab.mercurial-scm.org/rHG30d0cb279bacf791577e90124b2a94018588f0b8? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2279 To: durin42, #hg-reviewers, martinvonz Cc: martinvonz, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2279: node: make bin() be a wrapper instead of just an alias
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This includes a full backout of https://phab.mercurial-scm.org/rHG59affe7e01d4df54acc91829fe7caf4e8020eea1. Per the review, we'd rather adapt the API to behave like it used to (at least for now), and take a second run at it if it shows up in our performance numbers. I ran perfrevlogindex with and without this change and it didn't make a measurable difference, so maybe it's fine (despite my intuition to the contrary). REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2279 AFFECTED FILES hgext/histedit.py mercurial/node.py CHANGE DETAILS diff --git a/mercurial/node.py b/mercurial/node.py --- a/mercurial/node.py +++ b/mercurial/node.py @@ -11,7 +11,14 @@ # This ugly style has a noticeable effect in manifest parsing hex = binascii.hexlify -bin = binascii.unhexlify +# Adapt to Python 3 API changes. If this ends up showing up in +# profiles, we can use this version only on Python 3, and forward +# binascii.unhexlify like we used to on Python 2. +def bin(s): +try: +return binascii.unhexlify(s) +except binascii.Error as e: +raise TypeError(e) nullrev = -1 nullid = b"\0" * 20 diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -183,7 +183,6 @@ from __future__ import absolute_import -import binascii import errno import os @@ -426,7 +425,7 @@ rulehash = rule.strip().split(' ', 1)[0] try: rev = node.bin(rulehash) -except (TypeError, binascii.Error): +except TypeError: raise error.ParseError("invalid changeset %s" % rulehash) return cls(state, rev) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel