Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 28845:5a398627db92
commands: make --rev and --index compatible in debugobsolete
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Mon, 04 Apr 2016 02:05:10 -0700 |
parents | 9b52094bb04d |
children | 02be5fc18c0c |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Apr 03 19:38:57 2016 +0900 +++ b/mercurial/commands.py Mon Apr 04 02:05:10 2016 -0700 @@ -3122,9 +3122,6 @@ finally: l.release() else: - if opts.get('rev') and opts.get('index'): - hint = _("call 'hg debugobsolete --index' without other arguments") - raise error.Abort(_("cannot use --index with --rev"), hint=hint) if opts['rev']: revs = scmutil.revrange(repo, opts['rev']) nodes = [repo[r].node() for r in revs] @@ -3133,7 +3130,23 @@ else: markers = obsolete.getmarkers(repo) - for i, m in enumerate(markers): + markerstoiter = markers + isrelevant = lambda m: True + if opts.get('rev') and opts.get('index'): + markerstoiter = obsolete.getmarkers(repo) + markerset = set(markers) + isrelevant = lambda m: m in markerset + + for i, m in enumerate(markerstoiter): + if not isrelevant(m): + # marker can be irrelevant when we're iterating over a set + # of markers (markerstoiter) which is bigger than the set + # of markers we want to display (markers) + # this can happen if both --index and --rev options are + # provided and thus we need to iterate over all of the markers + # to get the correct indices, but only display the ones that + # are relevant to --rev value + continue ind = i if opts.get('index') else None cmdutil.showmarker(ui, m, index=ind)