diff -r 72642a6970e0 -r 56d4c6207ef9 hgext/obsolete.py --- a/hgext/obsolete.py Wed Jul 11 13:38:48 2012 +0200 +++ b/hgext/obsolete.py Wed Jul 11 13:59:02 2012 +0200 @@ -414,9 +414,13 @@ templatekw.keywords['obsolete'] = obsoletekw + # warning about more obsolete + for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']: + entry = extensions.wrapcommand(commands.table, cmd, warnobserrors) try: rebase = extensions.find('rebase') if rebase: + entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) extensions.wrapfunction(rebase, 'buildstate', buildstate) extensions.wrapfunction(rebase, 'defineparents', defineparents) extensions.wrapfunction(rebase, 'concludenode', concludenode) @@ -691,6 +695,28 @@ ui.warn(_('Working directory parent is obsolete\n')) return res +def warnobserrors(orig, ui, repo, *args, **kwargs): + """display warning is the command resulted in more instable changeset""" + priorunstables = len(repo.revs('unstable()')) + priorlatecomers = len(repo.revs('latecomer()')) + priorconflictings = len(repo.revs('conflicting()')) + #print orig, priorunstables + #print len(repo.revs('secret() - obsolete()')) + try: + return orig(ui, repo, *args, **kwargs) + finally: + newunstables = len(repo.revs('unstable()')) - priorunstables + newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers + newconflictings = len(repo.revs('conflicting()')) - priorconflictings + #print orig, newunstables + #print len(repo.revs('secret() - obsolete()')) + if newunstables > 0: + ui.warn(_('%i new unstables changesets\n') % newunstables) + if newlatecomers > 0: + ui.warn(_('%i new latecomers changesets\n') % newlatecomers) + if newconflictings > 0: + ui.warn(_('%i new conflictings changesets\n') % newconflictings) + def noextinctsvisibleheads(orig, repo): repo._turn_extinct_secret() return orig(repo)