evolve: issue the "%i new unstable changeset" in more place
most command able to create unstability now issue the warning
--- a/docs/tutorials/tutorial.t Mon Apr 23 18:53:26 2012 +0200
+++ b/docs/tutorials/tutorial.t Mon Apr 23 18:54:17 2012 +0200
@@ -453,7 +453,7 @@
9ca060c80d74 (public): SPAM
7e82d3f3c2cb (public): Monthy Python Shopping list
-Rebasing unstable change after update
+Rebasing unstable change after pull
----------------------------------------------
Remotely someone add a new changeset on top of our mutable "bathroom" on.
@@ -484,6 +484,7 @@
When we pull from remote again we get an unstable state!
+
$ hg pull remote
pulling from $TESTTMP/remote
searching for changes
@@ -492,6 +493,7 @@
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads .' to see heads, 'hg merge' to merge)
+ 1 new unstables changesets
$ hg log
9ac5d0e790a2 (secret): animals
ffa278c50818 (draft): bathroom stuff
@@ -611,9 +613,10 @@
In the mean time I noticed you can't buy animals in a super market and I kill the animal changeset:
- $ hg kill 437efbcaf700 # XXX issue a warning here
+ $ hg kill 437efbcaf700
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
working directory now at ffa278c50818
+ 1 new unstables changesets
The animals changeset is still displayed because the "SPAM SPAM SPAM" changeset
--- a/hgext/evolve.py Mon Apr 23 18:53:26 2012 +0200
+++ b/hgext/evolve.py Mon Apr 23 18:54:17 2012 +0200
@@ -31,18 +31,26 @@
return map(repo.changelog.node,
scmutil.revrange(repo, revsets))
+
+
+def warnunstable(orig, ui, repo, *args, **kwargs):
+ """display warning is the command resulted in more instable changeset"""
+ priorunstables = len(repo.revs('unstable()'))
+ #print orig, priorunstables
+ #print len(repo.revs('secret() - obsolete()'))
+ try:
+ return orig(ui, repo, *args, **kwargs)
+ finally:
+ newunstables = len(repo.revs('unstable()')) - priorunstables
+ #print orig, newunstables
+ #print len(repo.revs('secret() - obsolete()'))
+ if newunstables > 0:
+ ui.warn(_('%i new unstables changesets\n') % newunstables)
+
+
### extension check
#############################
-def extsetup(ui):
- try:
- obsolete = extensions.find('obsolete')
- except KeyError:
- raise error.Abort(_('evolution extension require obsolete extension.'))
- try:
- rebase = extensions.find('rebase')
- except KeyError:
- raise error.Abort(_('evolution extension require rebase extension.'))
### changeset rewriting logic
#############################
@@ -374,13 +382,6 @@
if not old.phase():
raise util.Abort(_("can not rewrite immutable changeset %s") % old)
- # store the amount of unstable prior update
- if old.children():
- priorunstables = len(repo.revs('unstable()'))
- else:
- #no children mean no change for unstable changeset
- priorunstables = None
-
# commit current changes as update
# code copied from commands.commit to avoid noisy messages
ciopts = dict(opts)
@@ -420,15 +421,14 @@
phases.retractboundary(repo, old.phase(), [newid])
repo.dirstate.setparents(newid, node.nullid)
- if priorunstables is not None:
- newunstables = len(repo.revs('unstable()')) - priorunstables
- if newunstables > 0:
- ui.warn(_('%i new unstables changesets\n') % newunstables)
finally:
wlock.release()
finally:
lock.release()
+
+
+
def commitwrapper(orig, ui, repo, *arg, **kwargs):
lock = repo.lock()
try:
@@ -472,8 +472,27 @@
lock.release()
def extsetup(ui):
+ try:
+ obsolete = extensions.find('obsolete')
+ except KeyError:
+ raise error.Abort(_('evolution extension require obsolete extension.'))
+ try:
+ rebase = extensions.find('rebase')
+ except KeyError:
+ rebase = None
+ raise error.Abort(_('evolution extension require rebase extension.'))
+
entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper)
entry[1].append(('o', 'obsolete', [], _("this commit obsolet this revision")))
entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper)
entry[1].append(('o', 'obsolete', [], _("this graft obsolet this revision")))
entry[1].append(('O', 'old-obsolete', False, _("graft result obsolete graft source")))
+
+ # warning about more obsolete
+ for cmd in ['commit', 'push', 'pull', 'graft']:
+ entry = extensions.wrapcommand(commands.table, cmd, warnunstable)
+ for cmd in ['kill', 'amend']:
+ entry = extensions.wrapcommand(cmdtable, cmd, warnunstable)
+
+ if rebase is not None:
+ entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnunstable)