comparison hgext/evolve.py @ 356:56d4c6207ef9 stable

Move obserror warning into the obsolete extension.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 11 Jul 2012 13:59:02 +0200
parents 72642a6970e0
children 88cee22c89f1
comparison
equal deleted inserted replaced
355:72642a6970e0 356:56d4c6207ef9
30 30
31 def noderange(repo, revsets): 31 def noderange(repo, revsets):
32 """The same as revrange but return node""" 32 """The same as revrange but return node"""
33 return map(repo.changelog.node, 33 return map(repo.changelog.node,
34 scmutil.revrange(repo, revsets)) 34 scmutil.revrange(repo, revsets))
35
36 def warnobserrors(orig, ui, repo, *args, **kwargs):
37 """display warning is the command resulted in more instable changeset"""
38 priorunstables = len(repo.revs('unstable()'))
39 priorlatecomers = len(repo.revs('latecomer()'))
40 priorconflictings = len(repo.revs('conflicting()'))
41 #print orig, priorunstables
42 #print len(repo.revs('secret() - obsolete()'))
43 try:
44 return orig(ui, repo, *args, **kwargs)
45 finally:
46 newunstables = len(repo.revs('unstable()')) - priorunstables
47 newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers
48 newconflictings = len(repo.revs('conflicting()')) - priorconflictings
49 #print orig, newunstables
50 #print len(repo.revs('secret() - obsolete()'))
51 if newunstables > 0:
52 ui.warn(_('%i new unstables changesets\n') % newunstables)
53 if newlatecomers > 0:
54 ui.warn(_('%i new latecomers changesets\n') % newlatecomers)
55 if newconflictings > 0:
56 ui.warn(_('%i new conflictings changesets\n') % newconflictings)
57 35
58 ### changeset rewriting logic 36 ### changeset rewriting logic
59 ############################# 37 #############################
60 38
61 def rewrite(repo, old, updates, head, newbases, commitopts): 39 def rewrite(repo, old, updates, head, newbases, commitopts):
679 rebase = extensions.find('rebase') 657 rebase = extensions.find('rebase')
680 except KeyError: 658 except KeyError:
681 rebase = None 659 rebase = None
682 raise error.Abort(_('evolution extension require rebase extension.')) 660 raise error.Abort(_('evolution extension require rebase extension.'))
683 661
662 for cmd in ['amend', 'kill', 'uncommit']:
663 entry = extensions.wrapcommand(cmdtable, cmd,
664 obsolete.warnobserrors)
665
684 entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper) 666 entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper)
685 entry[1].append(('o', 'obsolete', [], 667 entry[1].append(('o', 'obsolete', [],
686 _("make commit obsolete this revision"))) 668 _("make commit obsolete this revision")))
687 entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper) 669 entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper)
688 entry[1].append(('o', 'obsolete', [], 670 entry[1].append(('o', 'obsolete', [],
689 _("make graft obsoletes this revision"))) 671 _("make graft obsoletes this revision")))
690 entry[1].append(('O', 'old-obsolete', False, 672 entry[1].append(('O', 'old-obsolete', False,
691 _("make graft obsoletes its source"))) 673 _("make graft obsoletes its source")))
692 674
693 # warning about more obsolete
694 for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']:
695 entry = extensions.wrapcommand(commands.table, cmd, warnobserrors)
696 for cmd in ['amend', 'kill', 'uncommit']:
697 entry = extensions.wrapcommand(cmdtable, cmd, warnobserrors)
698
699 if rebase is not None:
700 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)