diff hgext/obsolete.py @ 79:9906560f585e

[obsolete] issue a warning when parent of current directory is obsolete.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 14 Sep 2011 19:20:38 +0200
parents d7b11772f0b5
children 5d029a358252
line wrap: on
line diff
--- a/hgext/obsolete.py	Wed Sep 14 17:55:17 2011 +0200
+++ b/hgext/obsolete.py	Wed Sep 14 19:20:38 2011 +0200
@@ -86,6 +86,7 @@
 from mercurial import pushkey
 from mercurial import discovery
 from mercurial import error
+from mercurial import commands
 from mercurial.node import hex, bin, short
 from mercurial.lock import release
 
@@ -228,6 +229,19 @@
 
 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>')}
 
+### Altering existing command
+#############################
+
+def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
+    res = origfn(ui, repo, *args, **opts)
+    if repo['.'].obsolete():
+        ui.warn(_('Working directory parent is obsolete\n'))
+    return res
+
+def uisetup(ui):
+    extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
+    extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
+
 ### serialisation
 #############################