##// END OF EJS Templates
narrow: migrate `opts` to native kwargs
Matt Harbison -
r51774:4803cea1 default
parent child Browse files
Show More
@@ -87,9 +87,8 b' def setup():'
87 87
88 88 def clonenarrowcmd(orig, ui, repo, *args, **opts):
89 89 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
90 opts = pycompat.byteskwargs(opts)
91 90 wrappedextraprepare = util.nullcontextmanager()
92 narrowspecfile = opts[b'narrowspec']
91 narrowspecfile = opts['narrowspec']
93 92
94 93 if narrowspecfile:
95 94 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
@@ -115,24 +114,25 b' def clonenarrowcmd(orig, ui, repo, *args'
115 114 narrowspec.validatepatterns(excludes)
116 115
117 116 # narrowspec is passed so we should assume that user wants narrow clone
118 opts[b'narrow'] = True
119 opts[b'include'].extend(includes)
120 opts[b'exclude'].extend(excludes)
117 opts['narrow'] = True
118 opts['include'].extend(includes)
119 opts['exclude'].extend(excludes)
121 120
122 if opts[b'narrow']:
121 if opts['narrow']:
123 122
124 123 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
125 124 orig(pullop, kwargs)
126 125
127 if opts.get(b'depth'):
128 kwargs[b'depth'] = opts[b'depth']
126 if opts.get('depth'):
127 # TODO: fix exchange._pullbundle2extraprepare()
128 kwargs[b'depth'] = opts['depth']
129 129
130 130 wrappedextraprepare = extensions.wrappedfunction(
131 131 exchange, '_pullbundle2extraprepare', pullbundle2extraprepare_widen
132 132 )
133 133
134 134 with wrappedextraprepare:
135 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
135 return orig(ui, repo, *args, **opts)
136 136
137 137
138 138 def pullnarrowcmd(orig, ui, repo, *args, **opts):
@@ -511,7 +511,6 b' def trackedcmd(ui, repo, remotepath=None'
511 511 add --addinclude, --addexclude rules in bulk. Like the other include and
512 512 exclude switches, the changes are applied immediately.
513 513 """
514 opts = pycompat.byteskwargs(opts)
515 514 if requirements.NARROW_REQUIREMENT not in repo.requirements:
516 515 raise error.InputError(
517 516 _(
@@ -522,11 +521,11 b' def trackedcmd(ui, repo, remotepath=None'
522 521
523 522 # Before supporting, decide whether it "hg tracked --clear" should mean
524 523 # tracking no paths or all paths.
525 if opts[b'clear']:
524 if opts['clear']:
526 525 raise error.InputError(_(b'the --clear option is not yet supported'))
527 526
528 527 # import rules from a file
529 newrules = opts.get(b'import_rules')
528 newrules = opts.get('import_rules')
530 529 if newrules:
531 530 try:
532 531 filepath = os.path.join(encoding.getcwd(), newrules)
@@ -546,16 +545,16 b' def trackedcmd(ui, repo, remotepath=None'
546 545 b"is not supported in narrowspec"
547 546 )
548 547 )
549 opts[b'addinclude'].extend(includepats)
550 opts[b'addexclude'].extend(excludepats)
548 opts['addinclude'].extend(includepats)
549 opts['addexclude'].extend(excludepats)
551 550
552 addedincludes = narrowspec.parsepatterns(opts[b'addinclude'])
553 removedincludes = narrowspec.parsepatterns(opts[b'removeinclude'])
554 addedexcludes = narrowspec.parsepatterns(opts[b'addexclude'])
555 removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude'])
556 autoremoveincludes = opts[b'auto_remove_includes']
551 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
552 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
553 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
554 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
555 autoremoveincludes = opts['auto_remove_includes']
557 556
558 update_working_copy = opts[b'update_working_copy']
557 update_working_copy = opts['update_working_copy']
559 558 only_show = not (
560 559 addedincludes
561 560 or removedincludes
@@ -570,7 +569,7 b' def trackedcmd(ui, repo, remotepath=None'
570 569 if only_show:
571 570 oldincludes, oldexcludes = repo.narrowpats
572 571 ui.pager(b'tracked')
573 fm = ui.formatter(b'narrow', opts)
572 fm = ui.formatter(b'narrow', pycompat.byteskwargs(opts))
574 573 for i in sorted(oldincludes):
575 574 fm.startitem()
576 575 fm.write(b'status', b'%s ', b'I', label=b'narrow.included')
@@ -614,7 +613,7 b' def trackedcmd(ui, repo, remotepath=None'
614 613 # also define the set of revisions to update for widening.
615 614 path = urlutil.get_unique_pull_path_obj(b'tracked', ui, remotepath)
616 615 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc))
617 remote = hg.peer(repo, opts, path)
616 remote = hg.peer(repo, pycompat.byteskwargs(opts), path)
618 617
619 618 try:
620 619 # check narrow support before doing anything if widening needs to be
@@ -670,8 +669,8 b' def trackedcmd(ui, repo, remotepath=None'
670 669 oldexcludes,
671 670 newincludes,
672 671 newexcludes,
673 opts[b'force_delete_local_changes'],
674 opts[b'backup'],
672 opts['force_delete_local_changes'],
673 opts['backup'],
675 674 )
676 675 # _narrow() updated the narrowspec and _widen() below needs to
677 676 # use the updated values as its base (otherwise removed includes
General Comments 0
You need to be logged in to leave comments. Login now