--- a/hgext/evolve.py Sun May 11 01:17:02 2014 -0700
+++ b/hgext/evolve.py Fri May 09 03:06:36 2014 -0700
@@ -52,6 +52,7 @@
from mercurial import merge
from mercurial import node
from mercurial import phases
+from mercurial import patch
from mercurial import revset
from mercurial import scmutil
from mercurial import templatekw
@@ -823,6 +824,37 @@
_('record the specified user in metadata'), _('USER')),
]
+if getattr(mercurial.cmdutil, 'tryimportone', None) is not None:
+ # hg 3.0 and greate
+ @eh.uisetup
+ def _installimportobsolete(ui):
+ entry = cmdutil.findcmd('import', commands.table)[1]
+ entry[1].append(('', 'obsolete', False,
+ _('mark the old node as obsoleted by'
+ 'the created commit')))
+
+ @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
+ def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
+ extracted = patch.extract(ui, hunk)
+ expected = extracted[5]
+ oldextract = patch.extract
+ try:
+ patch.extract = lambda ui, hunk: extracted
+ ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
+ finally:
+ patch.extract = oldextract
+ created = ret[1]
+ if opts['obsolete'] and created is not None and created != expected:
+ tr = repo.transaction('import-obs')
+ try:
+ metadata = {'user': ui.username()}
+ repo.obsstore.create(tr, node.bin(expected), (created,),
+ metadata=metadata)
+ tr.close()
+ finally:
+ tr.release()
+ return ret
+
@command('^evolve|stabilize|solve',
[('n', 'dry-run', False, 'do not perform actions, just print what would be done'),