diff mercurial/localrepo.py @ 23416:53a65929ef1f stable

pushkey: gracefully handle prepushkey hook failure (issue4455) This allow to gracefully report the failure of the bookmark push and carry on. Before this change set. Local push would plain quit and wireprotocol would failed in various ungraceful way.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 29 Nov 2014 19:17:47 -0800
parents eb315418224c
children 19ebd2f88fc7
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Nov 29 19:13:35 2014 -0800
+++ b/mercurial/localrepo.py	Sat Nov 29 19:17:47 2014 -0800
@@ -1754,8 +1754,14 @@
         return ret
 
     def pushkey(self, namespace, key, old, new):
-        self.hook('prepushkey', throw=True, namespace=namespace, key=key,
-                  old=old, new=new)
+        try:
+            self.hook('prepushkey', throw=True, namespace=namespace, key=key,
+                      old=old, new=new)
+        except error.HookAbort, exc:
+            self.ui.write_err(_("pushkey-abort: %s\n") % exc)
+            if exc.hint:
+                self.ui.write_err(_("(%s)\n") % exc.hint)
+            return False
         self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
         ret = pushkey.push(self, namespace, key, old, new)
         self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,