Mercurial > hg
diff mercurial/commands.py @ 28795:f456834b2f7e
commands: allow debugobsolete to delete arbitrary obsmarkers
Sample usage is:
'$ hg debugobsolete --delete 0 5'
This is a debug feature that will help people working on evolution and
obsolescense.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Fri, 01 Apr 2016 15:12:50 -0700 |
parents | 2637d6ad3e61 |
children | 9b52094bb04d |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Apr 01 15:20:31 2016 -0700 +++ b/mercurial/commands.py Fri Apr 01 15:12:50 2016 -0700 @@ -3041,6 +3041,7 @@ _('record parent information for the precursor')), ('r', 'rev', [], _('display markers relevant to REV')), ('', 'index', False, _('display index of the marker')), + ('', 'delete', [], _('delete markers specified by indices')), ] + commitopts2, _('[OBSOLETED [REPLACEMENT ...]]')) def debugobsolete(ui, repo, precursor=None, *successors, **opts): @@ -3061,6 +3062,32 @@ raise error.Abort('changeset references must be full hexadecimal ' 'node identifiers') + if opts.get('delete'): + try: + indices = [int(v) for v in opts.get('delete')] + except ValueError: + raise error.Abort(_('invalid index value'), + hint=_('use integers fro indices')) + + if repo.currenttransaction(): + raise error.Abort(_('Cannot delete obsmarkers in the middle ' + 'of transaction.')) + + w = repo.wlock() + l = repo.lock() + try: + tr = repo.transaction('debugobsolete') + try: + n = repo.obsstore.delete(indices) + ui.write(_('Deleted %i obsolescense markers\n') % n) + tr.close() + finally: + tr.release() + finally: + l.release() + w.release() + return + if precursor is not None: if opts['rev']: raise error.Abort('cannot select revision when creating marker')