changeset 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 ddcc4bb6c4d4
children 5d029a358252
files hgext/obsolete.py tests/test-obsolete.t
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
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
 #############################
 
--- a/tests/test-obsolete.t	Wed Sep 14 17:55:17 2011 +0200
+++ b/tests/test-obsolete.t	Wed Sep 14 19:20:38 2011 +0200
@@ -67,6 +67,7 @@
   3
   - 0d3f46688ccc
   $ hg up 3 -q
+  Working directory parent is obsolete
   $ mkcommit d # 5 (on 3)
   $ qlog -r 'obsolete()'
   3
@@ -98,6 +99,7 @@
   0
   - 1f0dee641bb7
   $ hg up 3 -q
+  Working directory parent is obsolete
   $ mkcommit obsol_d # 6
   created new head
   $ hg debugobsolete 6 5
@@ -136,7 +138,8 @@
   $ qlog -R ../other-new -r 'obsolete()'
   2
   - 0d3f46688ccc
-  $ hg up -q .^
+  $ hg up -q .^ # 3
+  Working directory parent is obsolete
   $ mkcommit "obsol_d'" # 7
   created new head
   $ hg debugobsolete 7 6
@@ -218,7 +221,8 @@
 
 Test rollback support
 
-  $ hg up .^ -q
+  $ hg up .^ -q # 3
+  Working directory parent is obsolete
   $ mkcommit "obsol_d''"
   created new head
   $ hg debugobsolete 8 7