changeset 5077:39029a6d33d4 stable

obsdiscovery: compatibility when importing forcebytestr()
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 21 Jan 2020 23:48:41 +0700
parents 47f9ba943bb1
children 6db9e2350948
files hgext3rd/evolve/obsdiscovery.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py	Mon Jan 20 22:52:05 2020 +0700
+++ b/hgext3rd/evolve/obsdiscovery.py	Tue Jan 21 23:48:41 2020 +0700
@@ -33,7 +33,12 @@
     util,
 )
 from mercurial.i18n import _
-from mercurial.utils import stringutil
+
+try:
+    from mercurial.utils.stringutil import forcebytestr
+except ImportError:
+    # hg <= 4.5 (f99d64e8a4e4)
+    from mercurial.util import forcebytestr
 
 from . import (
     compat,
@@ -450,7 +455,7 @@
                     except (sqlite3.DatabaseError, sqlite3.OperationalError) as exc:
                         repo.ui.log(b'evoext-cache',
                                     b'error while updating obshashrange cache: %s'
-                                    % stringutil.forcebytestr(exc))
+                                    % forcebytestr(exc))
                         del self._updating
                         return
 
@@ -556,9 +561,9 @@
             self._new.clear()
             repo.ui.log(b'evoext-cache',
                         b'error while saving new data: %s'
-                        % stringutil.forcebytestr(exc))
+                        % forcebytestr(exc))
             repo.ui.debug(b'evoext-cache: error while saving new data: %s'
-                          % stringutil.forcebytestr(exc))
+                          % forcebytestr(exc))
 
     def _trysave(self, repo):
         if self._con is None: