D7190: py3: fix fsmonitor's _watchmantofsencoding exception message encoding
Closed by commit rHG29e75689d4a2: py3: fix fsmonitors _watchmantofsencoding exception message encoding (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7190?vs=17444=17464 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7190/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7190 AFFECTED FILES hgext/fsmonitor/__init__.py CHANGE DETAILS diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -245,12 +245,12 @@ try: decoded = path.decode(_watchmanencoding) except UnicodeDecodeError as e: -raise error.Abort(str(e), hint=b'watchman encoding error') +raise error.Abort(forcebytestr(e), hint=b'watchman encoding error') try: encoded = decoded.encode(_fsencoding, 'strict') except UnicodeEncodeError as e: -raise error.Abort(str(e)) +raise error.Abort(forcebytestr(e)) return encoded To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7193: py3: fix exception message encoding in scmutil.py's simplekeyvaluefile.read
Closed by commit rHG8a1d9e252ea4: py3: fix exception message encoding in scmutil.pys simplekeyvaluefile.read (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7193?vs=17447=17454 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7193/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7193 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 @@ -1854,7 +1854,7 @@ raise error.CorruptedState(e % self.firstlinekey) d.update(updatedict) except ValueError as e: -raise error.CorruptedState(str(e)) +raise error.CorruptedState(stringutil.forcebytestr(e)) return d def write(self, data, firstline=None): To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7194: py3: fix crecord.py's editpatchwitheditor exception message encoding
Closed by commit rHGd5437bf42e37: py3: fix crecord.pys editpatchwitheditor exception message encoding (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7194?vs=17448=17453 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7194/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7194 AFFECTED FILES mercurial/crecord.py CHANGE DETAILS diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -1816,7 +1816,7 @@ try: patch = self.ui.edit(patch.getvalue(), b"", action=b"diff") except error.Abort as exc: -self.errorstr = str(exc) +self.errorstr = stringutil.forcebytestr(exc) return None finally: self.stdscr.clear() To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7191: py3: fix exception display encoding in contrib/simplemerge.py
Closed by commit rHGe54da18c421e: py3: fix exception display encoding in contrib/simplemerge.py (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7191?vs=17445=17456 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7191/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7191 AFFECTED FILES contrib/simplemerge CHANGE DETAILS diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -18,6 +18,7 @@ ) from mercurial.utils import ( procutil, +stringutil ) options = [(b'L', b'label', [], _(b'labels to use on conflict markers')), @@ -75,8 +76,7 @@ context.arbitraryfilectx(other), **pycompat.strkwargs(opts))) except ParseError as e: -if pycompat.ispy3: -e = str(e).encode('utf8') +e = stringutil.forcebytestr(e) pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) showhelp() sys.exit(1) To: touilleMan, #hg-reviewers, indygreg Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7195: py3: fix exception message encoding in infinitepush
Closed by commit rHGf8e10e3e001f: py3: fix exception message encoding in infinitepush (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7195?vs=17449=17452 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7195/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7195 AFFECTED FILES hgext/infinitepush/__init__.py CHANGE DETAILS diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -959,7 +959,7 @@ service, eventtype=b'failure', elapsedms=(time.time() - start) * 1000, -errormsg=str(e), +errormsg=stringutil.forcebytestr(e), **kwargs ) raise @@ -1223,7 +1223,7 @@ scratchbranchparttype, eventtype=b'failure', elapsedms=(time.time() - parthandlerstart) * 1000, -errormsg=str(e), +errormsg=stringutil.forcebytestr(e), ) raise finally: To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7192: py3: fix exception message check in test-linerange.py's testOutOfRange
Closed by commit rHG5c12a381fab3: py3: fix exception message check in test-linerange.pys testOutOfRange (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7192?vs=17446=17455 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7192/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7192 AFFECTED FILES tests/test-linerange.py CHANGE DETAILS diff --git a/tests/test-linerange.py b/tests/test-linerange.py --- a/tests/test-linerange.py +++ b/tests/test-linerange.py @@ -2,6 +2,7 @@ import unittest from mercurial import error, mdiff +from mercurial.utils import stringutil # for readability, line numbers are 0-origin text1 = b''' @@ -228,7 +229,7 @@ try: mdiff.blocksinrange(self.blocks, linerange2) except exctype as exc: -self.assertTrue('line range exceeds file size' in str(exc)) +self.assertTrue(b'line range exceeds file size' in stringutil.forcebytestr(exc)) else: self.fail('%s not raised' % exctype.__name__) To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7196: py3: fix fsmonitor's _handleunavailable exception message encoding
Closed by commit rHGb567c4365974: py3: fix fsmonitors _handleunavailable exception message encoding (authored by touilleMan). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7196?vs=17450=17451 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7196/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7196 AFFECTED FILES hgext/fsmonitor/__init__.py CHANGE DETAILS diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -207,8 +207,8 @@ if isinstance(ex, watchmanclient.Unavailable): # experimental config: fsmonitor.verbose if ex.warn and ui.configbool(b'fsmonitor', b'verbose'): -if b'illegal_fstypes' not in str(ex): -ui.warn(str(ex) + b'\n') +if b'illegal_fstypes' not in forcebytestr(ex): +ui.warn(forcebytestr(ex) + b'\n') if ex.invalidate: state.invalidate() # experimental config: fsmonitor.verbose To: touilleMan, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7195: py3: fix exception message encoding in infinitepush
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7195 AFFECTED FILES hgext/infinitepush/__init__.py CHANGE DETAILS diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py --- a/hgext/infinitepush/__init__.py +++ b/hgext/infinitepush/__init__.py @@ -959,7 +959,7 @@ service, eventtype=b'failure', elapsedms=(time.time() - start) * 1000, -errormsg=str(e), +errormsg=stringutil.forcebytestr(e), **kwargs ) raise @@ -1223,7 +1223,7 @@ scratchbranchparttype, eventtype=b'failure', elapsedms=(time.time() - parthandlerstart) * 1000, -errormsg=str(e), +errormsg=stringutil.forcebytestr(e), ) raise finally: To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7194: py3: fix crecord.py's editpatchwitheditor exception message encoding
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7194 AFFECTED FILES mercurial/crecord.py CHANGE DETAILS diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -1816,7 +1816,7 @@ try: patch = self.ui.edit(patch.getvalue(), b"", action=b"diff") except error.Abort as exc: -self.errorstr = str(exc) +self.errorstr = stringutil.forcebytestr(exc) return None finally: self.stdscr.clear() To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7193: py3: fix exception message encoding in scmutil.py's simplekeyvaluefile.read
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7193 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 @@ -1854,7 +1854,7 @@ raise error.CorruptedState(e % self.firstlinekey) d.update(updatedict) except ValueError as e: -raise error.CorruptedState(str(e)) +raise error.CorruptedState(stringutil.forcebytestr(e)) return d def write(self, data, firstline=None): To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7192: py3: fix exception message check in test-linerange.py's testOutOfRange
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7192 AFFECTED FILES tests/test-linerange.py CHANGE DETAILS diff --git a/tests/test-linerange.py b/tests/test-linerange.py --- a/tests/test-linerange.py +++ b/tests/test-linerange.py @@ -2,6 +2,7 @@ import unittest from mercurial import error, mdiff +from mercurial.utils import stringutil # for readability, line numbers are 0-origin text1 = b''' @@ -228,7 +229,7 @@ try: mdiff.blocksinrange(self.blocks, linerange2) except exctype as exc: -self.assertTrue('line range exceeds file size' in str(exc)) +self.assertTrue(b'line range exceeds file size' in stringutil.forcebytestr(exc)) else: self.fail('%s not raised' % exctype.__name__) To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7191: py3: fix exception display encoding in contrib/simplemerge.py
touilleMan created this revision. Herald added subscribers: mercurial-devel, mjpieters. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7191 AFFECTED FILES contrib/simplemerge CHANGE DETAILS diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -18,6 +18,7 @@ ) from mercurial.utils import ( procutil, +stringutil ) options = [(b'L', b'label', [], _(b'labels to use on conflict markers')), @@ -75,8 +76,7 @@ context.arbitraryfilectx(other), **pycompat.strkwargs(opts))) except ParseError as e: -if pycompat.ispy3: -e = str(e).encode('utf8') +e = stringutil.forcebytestr(e) pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) showhelp() sys.exit(1) To: touilleMan, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7190: py3: fix fsmonitor's _watchmantofsencoding exception message encoding
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7190 AFFECTED FILES hgext/fsmonitor/__init__.py CHANGE DETAILS diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -246,12 +246,12 @@ try: decoded = path.decode(_watchmanencoding) except UnicodeDecodeError as e: -raise error.Abort(str(e), hint=b'watchman encoding error') +raise error.Abort(forcebytestr(e), hint=b'watchman encoding error') try: encoded = decoded.encode(_fsencoding, 'strict') except UnicodeEncodeError as e: -raise error.Abort(str(e)) +raise error.Abort(forcebytestr(e)) return encoded To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7187: py3: fix fsmonitor error message formatting under Python3
touilleMan updated this revision to Diff 17435. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7187?vs=17434=17435 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7187/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7187 AFFECTED FILES hgext/fsmonitor/__init__.py hgext/fsmonitor/watchmanclient.py CHANGE DETAILS diff --git a/hgext/fsmonitor/watchmanclient.py b/hgext/fsmonitor/watchmanclient.py --- a/hgext/fsmonitor/watchmanclient.py +++ b/hgext/fsmonitor/watchmanclient.py @@ -10,6 +10,7 @@ import getpass from mercurial import util +from mercurial.utils.stringutil import forcebytestr from . import pywatchman @@ -22,7 +23,7 @@ self.warn = False self.invalidate = invalidate -def __str__(self): +def __bytes__(self): if self.warn: return b'warning: Watchman unavailable: %s' % self.msg else: @@ -100,7 +101,7 @@ raise WatchmanNoRoot(self._root, ex.msg) raise Unavailable(ex.msg) except pywatchman.WatchmanError as ex: -raise Unavailable(str(ex)) +raise Unavailable(forcebytestr(ex)) def command(self, *args): try: diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -132,6 +132,7 @@ util, ) from mercurial import match as matchmod +from mercurial.utils.stringutil import forcebytestr from . import ( pywatchman, @@ -192,7 +193,7 @@ v[b"version"], ) except watchmanclient.Unavailable as e: -err = str(e) +err = forcebytestr(e) fm.condwrite( err, b"fsmonitor-watchman-error", To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7187: py3: fix fsmonitor error message formatting under Python3
touilleMan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The watchmanclient.Unavailable exception got an invalid __str__ method resulting in a crash when watchman is not available. This fix also solve tests/test-install.t. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7187 AFFECTED FILES hgext/fsmonitor/__init__.py hgext/fsmonitor/watchmanclient.py CHANGE DETAILS diff --git a/hgext/fsmonitor/watchmanclient.py b/hgext/fsmonitor/watchmanclient.py --- a/hgext/fsmonitor/watchmanclient.py +++ b/hgext/fsmonitor/watchmanclient.py @@ -10,10 +10,10 @@ import getpass from mercurial import util +from mercurial.utils.stringutil import forcebytestr from . import pywatchman - class Unavailable(Exception): def __init__(self, msg, warn=True, invalidate=False): self.msg = msg @@ -22,7 +22,7 @@ self.warn = False self.invalidate = invalidate -def __str__(self): +def __bytes__(self): if self.warn: return b'warning: Watchman unavailable: %s' % self.msg else: @@ -100,7 +100,7 @@ raise WatchmanNoRoot(self._root, ex.msg) raise Unavailable(ex.msg) except pywatchman.WatchmanError as ex: -raise Unavailable(str(ex)) +raise Unavailable(forcebytestr(ex)) def command(self, *args): try: diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -132,6 +132,7 @@ util, ) from mercurial import match as matchmod +from mercurial.utils.stringutil import forcebytestr from . import ( pywatchman, @@ -192,7 +193,7 @@ v[b"version"], ) except watchmanclient.Unavailable as e: -err = str(e) +err = forcebytestr(e) fm.condwrite( err, b"fsmonitor-watchman-error", To: touilleMan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel