Commits

Pierre-Yves David committed 9906560

[obsolete] issue a warning when parent of current directory is obsolete.

Comments (0)

Files changed (2)

hgext/obsolete.py

 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
 
 
 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
 #############################
 

tests/test-obsolete.t

   3
   - 0d3f46688ccc
   $ hg up 3 -q
+  Working directory parent is obsolete
   $ mkcommit d # 5 (on 3)
   $ qlog -r 'obsolete()'
   3
   0
   - 1f0dee641bb7
   $ hg up 3 -q
+  Working directory parent is obsolete
   $ mkcommit obsol_d # 6
   created new head
   $ hg debugobsolete 6 5
   $ 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
 
 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