Commits

Yuya Nishihara  committed 1946399

add extension for debugging thg/issue/1947

  • Participants
  • Parent commits 3314c4f

Comments (0)

Files changed (1)

File hgext/debugthgissue1947.py

+# https://bitbucket.org/tortoisehg/thg/issue/1947/
+import time
+from mercurial import cmdutil, error, extensions
+
+_maxtry = 5
+
+def _bailifchanged(orig, repo):
+    for t in xrange(_maxtry):
+        try:
+            orig(repo)
+            return
+        except error.Abort, err:
+            repo.ui.write('debugthgissue1947:%d: %s\n' % (t, err))
+            repo.ui.write('debugthgissue1947:%d: status = %r\n'
+                          % (t, repo.status()[:4]))
+            if t == _maxtry - 1:
+                raise
+        time.sleep(1)
+
+def uisetup(ui):
+    extensions.wrapfunction(cmdutil, 'bailifchanged', _bailifchanged)