Mercurial > public > mercurial-scm > evolve
diff hgext/evolution.py @ 116:64ca29eef349
Add a -o option to commit
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 28 Dec 2011 12:38:01 +0100 |
parents | 3bdabdbb4140 |
children | 438fe133b068 |
line wrap: on
line diff
--- a/hgext/evolution.py Thu Dec 22 15:26:42 2011 +0100 +++ b/hgext/evolution.py Wed Dec 28 12:38:01 2011 +0100 @@ -18,6 +18,7 @@ from mercurial import bookmarks from mercurial import phases from mercurial import context +from mercurial import commands from mercurial import util from mercurial.i18n import _ from mercurial.commands import walkopts, commitopts, commitopts2, logopts @@ -300,3 +301,19 @@ finally: wlock.release() + +def commitwrapper(orig, ui, repo, *arg, **kwargs): + obsoleted = kwargs.get('obsolete', []) + if obsoleted: + obsoleted = repo.set('%lr', obsoleted) + result = orig(ui, repo, *arg, **kwargs) + if not result: # commit successed + new = repo['-1'] + for old in obsoleted: + repo.addobsolete(new.node(), old.node()) + return result + +def extsetup(ui): + entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper) + entry[1].append(('o', 'obsolete', [], _("this commit obsolet this revision"))) +