Show More
@@ -3041,6 +3041,7 b' def debuglocks(ui, repo, **opts):' | |||||
3041 | _('record parent information for the precursor')), |
|
3041 | _('record parent information for the precursor')), | |
3042 | ('r', 'rev', [], _('display markers relevant to REV')), |
|
3042 | ('r', 'rev', [], _('display markers relevant to REV')), | |
3043 | ('', 'index', False, _('display index of the marker')), |
|
3043 | ('', 'index', False, _('display index of the marker')), | |
|
3044 | ('', 'delete', [], _('delete markers specified by indices')), | |||
3044 | ] + commitopts2, |
|
3045 | ] + commitopts2, | |
3045 | _('[OBSOLETED [REPLACEMENT ...]]')) |
|
3046 | _('[OBSOLETED [REPLACEMENT ...]]')) | |
3046 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): |
|
3047 | def debugobsolete(ui, repo, precursor=None, *successors, **opts): | |
@@ -3061,6 +3062,32 b' def debugobsolete(ui, repo, precursor=No' | |||||
3061 | raise error.Abort('changeset references must be full hexadecimal ' |
|
3062 | raise error.Abort('changeset references must be full hexadecimal ' | |
3062 | 'node identifiers') |
|
3063 | 'node identifiers') | |
3063 |
|
3064 | |||
|
3065 | if opts.get('delete'): | |||
|
3066 | try: | |||
|
3067 | indices = [int(v) for v in opts.get('delete')] | |||
|
3068 | except ValueError: | |||
|
3069 | raise error.Abort(_('invalid index value'), | |||
|
3070 | hint=_('use integers fro indices')) | |||
|
3071 | ||||
|
3072 | if repo.currenttransaction(): | |||
|
3073 | raise error.Abort(_('Cannot delete obsmarkers in the middle ' | |||
|
3074 | 'of transaction.')) | |||
|
3075 | ||||
|
3076 | w = repo.wlock() | |||
|
3077 | l = repo.lock() | |||
|
3078 | try: | |||
|
3079 | tr = repo.transaction('debugobsolete') | |||
|
3080 | try: | |||
|
3081 | n = repo.obsstore.delete(indices) | |||
|
3082 | ui.write(_('Deleted %i obsolescense markers\n') % n) | |||
|
3083 | tr.close() | |||
|
3084 | finally: | |||
|
3085 | tr.release() | |||
|
3086 | finally: | |||
|
3087 | l.release() | |||
|
3088 | w.release() | |||
|
3089 | return | |||
|
3090 | ||||
3064 | if precursor is not None: |
|
3091 | if precursor is not None: | |
3065 | if opts['rev']: |
|
3092 | if opts['rev']: | |
3066 | raise error.Abort('cannot select revision when creating marker') |
|
3093 | raise error.Abort('cannot select revision when creating marker') |
@@ -628,6 +628,30 b' class obsstore(object):' | |||||
628 | transaction.hookargs['new_obsmarkers'] = str(previous + len(new)) |
|
628 | transaction.hookargs['new_obsmarkers'] = str(previous + len(new)) | |
629 | return len(new) |
|
629 | return len(new) | |
630 |
|
630 | |||
|
631 | def delete(self, indices): | |||
|
632 | """Delete some obsmarkers from store and return the number of them | |||
|
633 | ||||
|
634 | Indices is a list of ints which are the indices | |||
|
635 | of the markers to be deleted.""" | |||
|
636 | if not indices: | |||
|
637 | # we don't want to rewrite the obsstore with the same content | |||
|
638 | return | |||
|
639 | ||||
|
640 | left = [] | |||
|
641 | current = self._all | |||
|
642 | n = 0 | |||
|
643 | for i, m in enumerate(current): | |||
|
644 | if i in indices: | |||
|
645 | n += 1 | |||
|
646 | continue | |||
|
647 | left.append(m) | |||
|
648 | ||||
|
649 | newobsstore = self.svfs('obsstore', 'w', atomictemp=True) | |||
|
650 | for bytes in encodemarkers(left, True, self._version): | |||
|
651 | newobsstore.write(bytes) | |||
|
652 | newobsstore.close() | |||
|
653 | return n | |||
|
654 | ||||
631 | def mergemarkers(self, transaction, data): |
|
655 | def mergemarkers(self, transaction, data): | |
632 | """merge a binary stream of markers inside the obsstore |
|
656 | """merge a binary stream of markers inside the obsstore | |
633 |
|
657 |
@@ -261,7 +261,7 b' Show all commands + options' | |||||
261 | debuglocks: force-lock, force-wlock |
|
261 | debuglocks: force-lock, force-wlock | |
262 | debugmergestate: |
|
262 | debugmergestate: | |
263 | debugnamecomplete: |
|
263 | debugnamecomplete: | |
264 | debugobsolete: flags, record-parents, rev, index, date, user |
|
264 | debugobsolete: flags, record-parents, rev, index, delete, date, user | |
265 | debugpathcomplete: full, normal, added, removed |
|
265 | debugpathcomplete: full, normal, added, removed | |
266 | debugpushkey: |
|
266 | debugpushkey: | |
267 | debugpvec: |
|
267 | debugpvec: |
@@ -1083,4 +1083,17 b' Test ability to pull changeset with loca' | |||||
1083 | | |
|
1083 | | | |
1084 | @ 0:a78f55e5508c (draft) [ ] 0 |
|
1084 | @ 0:a78f55e5508c (draft) [ ] 0 | |
1085 |
|
1085 | |||
|
1086 | $ cd .. | |||
1086 |
|
1087 | |||
|
1088 | Test the --delete option of debugobsolete command | |||
|
1089 | $ hg init dorepo | |||
|
1090 | $ cd dorepo | |||
|
1091 | $ echo a > a && hg ci -Am a | |||
|
1092 | adding a | |||
|
1093 | $ hg ci --amend -m aa | |||
|
1094 | $ hg debugobsolete | |||
|
1095 | cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (.*) {'user': 'test'} (re) | |||
|
1096 | $ hg debugobsolete --delete 0 | |||
|
1097 | Deleted 1 obsolescense markers | |||
|
1098 | $ hg debugobsolete | |||
|
1099 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now