diff hgsubversion/compathacks.py @ 1601:5d8603f080c5

compathacks: add compat code for ui.makeprogress() deprecation ui.makeprogress() is deprecated and will be dropped in 5.1. This patch adds compat code for that. The compat code is plain copy of compat code available in evolve extension.
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 04 Feb 2019 20:56:39 +0300
parents 7bb6562feb85
children 6a6ce9d9da35
line wrap: on
line diff
--- a/hgsubversion/compathacks.py
+++ b/hgsubversion/compathacks.py
@@ -3,7 +3,19 @@
 import errno
 import sys
 
-from mercurial import util
+from mercurial import ui as uimod, util
+
+# ui.makeprogress will be dropped after hg-5.1
+if util.safehasattr(uimod.ui, 'makeprogress'):
+    def progress(ui, topic, pos, item="", unit="", total=None):
+        progress = ui.makeprogress(topic, unit, total)
+        if pos is not None:
+            progress.update(pos, item=item)
+        else:
+            progress.complete()
+else:
+    def progress(ui, topic, pos, item="", unit="", total=None):
+        ui.progress(topic, pos, item="", unit="", total=None)
 
 def pickle_load(f):
     import cPickle as pickle