diff mercurial/dispatch.py @ 28623:38dc3f28f478

dispatch: show deprecation warning if command has no attributes (issue5137) norepo/optionalrepo/inferrepo were removed by aa73d6a5d9ea, which would be significant API change. This patch tries to avoid crash even if ancient third-party extensions are enabled.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jan 2016 22:46:26 +0900
parents 527cf881d000
children 6b3b958daf03
line wrap: on
line diff
--- a/mercurial/dispatch.py	Mon Mar 14 00:14:43 2016 +0900
+++ b/mercurial/dispatch.py	Sat Jan 09 22:46:26 2016 +0900
@@ -747,7 +747,12 @@
                                   [], {})
 
 def _cmdattr(ui, cmd, func, attr):
-    return getattr(func, attr)
+    try:
+        return getattr(func, attr)
+    except AttributeError:
+        ui.deprecwarn("missing attribute '%s', use @command decorator "
+                      "to register '%s'" % (attr, cmd), '3.8')
+        return False
 
 _loaded = set()