Mercurial > evolve
comparison hgext/evolve.py @ 1202:4099b087f672 stable
evolve: handle invalid obsmarkers in the `debugobsconvert`
User can now recover from such situation, The error message is also changed to
point the `debugobsconvert` commands.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 06 Feb 2015 17:01:28 +0000 |
parents | bfe9be352453 |
children | 936aa82884ab |
comparison
equal
deleted
inserted
replaced
1201:ee9c10728b68 | 1202:4099b087f672 |
---|---|
2767 for chg, obs in _obsrelsethashtree(repo): | 2767 for chg, obs in _obsrelsethashtree(repo): |
2768 ui.status('%s %s\n' % (node.hex(chg), node.hex(obs))) | 2768 ui.status('%s %s\n' % (node.hex(chg), node.hex(obs))) |
2769 | 2769 |
2770 _bestformat = max(obsolete.formats.keys()) | 2770 _bestformat = max(obsolete.formats.keys()) |
2771 | 2771 |
2772 | |
2773 if getattr(obsolete, '_checkinvalidmarkers', None) is not None: | |
2774 @eh.wrapfunction(obsolete, '_checkinvalidmarkers') | |
2775 def _checkinvalidmarkers(orig, markers): | |
2776 """search for marker with invalid data and raise error if needed | |
2777 | |
2778 Exist as a separated function to allow the evolve extension for a more | |
2779 subtle handling. | |
2780 """ | |
2781 if 'debugobsconvert' in sys.argv: | |
2782 return | |
2783 for mark in markers: | |
2784 if node.nullid in mark[1]: | |
2785 raise util.Abort(_('bad obsolescence marker detected: ' | |
2786 'invalid successors nullid'), | |
2787 hint=_('You should run `hg debugobsconvert`')) | |
2788 | |
2772 @command( | 2789 @command( |
2773 'debugobsconvert', | 2790 'debugobsconvert', |
2774 [('', 'new-format', _bestformat, _('Destination format for markers.'))], | 2791 [('', 'new-format', _bestformat, _('Destination format for markers.'))], |
2775 '') | 2792 '') |
2776 def debugobsconvert(ui, repo, new_format): | 2793 def debugobsconvert(ui, repo, new_format): |
2780 f = repo.sopener('obsstore', 'wb', atomictemp=True) | 2797 f = repo.sopener('obsstore', 'wb', atomictemp=True) |
2781 origmarkers = repo.obsstore._all | 2798 origmarkers = repo.obsstore._all |
2782 known = set() | 2799 known = set() |
2783 markers = [] | 2800 markers = [] |
2784 for m in origmarkers: | 2801 for m in origmarkers: |
2802 # filter out invalid markers | |
2803 if nullid in m[1]: | |
2804 m = list(m) | |
2805 m[1] = tuple(s for s in m[1] if s != nullid) | |
2806 m = tuple(m) | |
2785 if m in known: | 2807 if m in known: |
2786 continue | 2808 continue |
2787 known.add(m) | 2809 known.add(m) |
2788 markers.append(m) | 2810 markers.append(m) |
2789 ui.write(_('Old store is version %d, will rewrite in version %d\n') % ( | 2811 ui.write(_('Old store is version %d, will rewrite in version %d\n') % ( |