##// END OF EJS Templates
debugobsolete: migrate `opts` to native kwargs
Matt Harbison -
r51851:55c28ffa default
parent child Browse files
Show More
@@ -2699,8 +2699,6 b' def debugobsolete(ui, repo, precursor=No'
2699
2699
2700 With no arguments, displays the list of obsolescence markers."""
2700 With no arguments, displays the list of obsolescence markers."""
2701
2701
2702 opts = pycompat.byteskwargs(opts)
2703
2704 def parsenodeid(s):
2702 def parsenodeid(s):
2705 try:
2703 try:
2706 # We do not use revsingle/revrange functions here to accept
2704 # We do not use revsingle/revrange functions here to accept
@@ -2716,9 +2714,9 b' def debugobsolete(ui, repo, precursor=No'
2716 b'node identifiers'
2714 b'node identifiers'
2717 )
2715 )
2718
2716
2719 if opts.get(b'delete'):
2717 if opts.get('delete'):
2720 indices = []
2718 indices = []
2721 for v in opts.get(b'delete'):
2719 for v in opts.get('delete'):
2722 try:
2720 try:
2723 indices.append(int(v))
2721 indices.append(int(v))
2724 except ValueError:
2722 except ValueError:
@@ -2739,25 +2737,25 b' def debugobsolete(ui, repo, precursor=No'
2739 return
2737 return
2740
2738
2741 if precursor is not None:
2739 if precursor is not None:
2742 if opts[b'rev']:
2740 if opts['rev']:
2743 raise error.InputError(
2741 raise error.InputError(
2744 b'cannot select revision when creating marker'
2742 b'cannot select revision when creating marker'
2745 )
2743 )
2746 metadata = {}
2744 metadata = {}
2747 metadata[b'user'] = encoding.fromlocal(opts[b'user'] or ui.username())
2745 metadata[b'user'] = encoding.fromlocal(opts['user'] or ui.username())
2748 succs = tuple(parsenodeid(succ) for succ in successors)
2746 succs = tuple(parsenodeid(succ) for succ in successors)
2749 l = repo.lock()
2747 l = repo.lock()
2750 try:
2748 try:
2751 tr = repo.transaction(b'debugobsolete')
2749 tr = repo.transaction(b'debugobsolete')
2752 try:
2750 try:
2753 date = opts.get(b'date')
2751 date = opts.get('date')
2754 if date:
2752 if date:
2755 date = dateutil.parsedate(date)
2753 date = dateutil.parsedate(date)
2756 else:
2754 else:
2757 date = None
2755 date = None
2758 prec = parsenodeid(precursor)
2756 prec = parsenodeid(precursor)
2759 parents = None
2757 parents = None
2760 if opts[b'record_parents']:
2758 if opts['record_parents']:
2761 if prec not in repo.unfiltered():
2759 if prec not in repo.unfiltered():
2762 raise error.Abort(
2760 raise error.Abort(
2763 b'cannot used --record-parents on '
2761 b'cannot used --record-parents on '
@@ -2769,7 +2767,7 b' def debugobsolete(ui, repo, precursor=No'
2769 tr,
2767 tr,
2770 prec,
2768 prec,
2771 succs,
2769 succs,
2772 opts[b'flags'],
2770 opts['flags'],
2773 parents=parents,
2771 parents=parents,
2774 date=date,
2772 date=date,
2775 metadata=metadata,
2773 metadata=metadata,
@@ -2785,12 +2783,12 b' def debugobsolete(ui, repo, precursor=No'
2785 finally:
2783 finally:
2786 l.release()
2784 l.release()
2787 else:
2785 else:
2788 if opts[b'rev']:
2786 if opts['rev']:
2789 revs = logcmdutil.revrange(repo, opts[b'rev'])
2787 revs = logcmdutil.revrange(repo, opts['rev'])
2790 nodes = [repo[r].node() for r in revs]
2788 nodes = [repo[r].node() for r in revs]
2791 markers = list(
2789 markers = list(
2792 obsutil.getmarkers(
2790 obsutil.getmarkers(
2793 repo, nodes=nodes, exclusive=opts[b'exclusive']
2791 repo, nodes=nodes, exclusive=opts['exclusive']
2794 )
2792 )
2795 )
2793 )
2796 markers.sort(key=lambda x: x._data)
2794 markers.sort(key=lambda x: x._data)
@@ -2799,12 +2797,12 b' def debugobsolete(ui, repo, precursor=No'
2799
2797
2800 markerstoiter = markers
2798 markerstoiter = markers
2801 isrelevant = lambda m: True
2799 isrelevant = lambda m: True
2802 if opts.get(b'rev') and opts.get(b'index'):
2800 if opts.get('rev') and opts.get('index'):
2803 markerstoiter = obsutil.getmarkers(repo)
2801 markerstoiter = obsutil.getmarkers(repo)
2804 markerset = set(markers)
2802 markerset = set(markers)
2805 isrelevant = lambda m: m in markerset
2803 isrelevant = lambda m: m in markerset
2806
2804
2807 fm = ui.formatter(b'debugobsolete', opts)
2805 fm = ui.formatter(b'debugobsolete', pycompat.byteskwargs(opts))
2808 for i, m in enumerate(markerstoiter):
2806 for i, m in enumerate(markerstoiter):
2809 if not isrelevant(m):
2807 if not isrelevant(m):
2810 # marker can be irrelevant when we're iterating over a set
2808 # marker can be irrelevant when we're iterating over a set
@@ -2816,7 +2814,7 b' def debugobsolete(ui, repo, precursor=No'
2816 # are relevant to --rev value
2814 # are relevant to --rev value
2817 continue
2815 continue
2818 fm.startitem()
2816 fm.startitem()
2819 ind = i if opts.get(b'index') else None
2817 ind = i if opts.get('index') else None
2820 cmdutil.showmarker(fm, m, index=ind)
2818 cmdutil.showmarker(fm, m, index=ind)
2821 fm.end()
2819 fm.end()
2822
2820
General Comments 0
You need to be logged in to leave comments. Login now