obsdiscovery: compatibility when importing forcebytestr() stable
authorAnton Shestakov <av6@dwimlabs.net>
Tue, 21 Jan 2020 23:48:41 +0700
branchstable
changeset 5077 39029a6d33d4
parent 5074 47f9ba943bb1
child 5080 6db9e2350948
obsdiscovery: compatibility when importing forcebytestr()
hgext3rd/evolve/obsdiscovery.py
--- 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: