avoid negative variables

Trying to use booleans with names like "no_xxx" are hard to follow due
to the double negatives.  Invert all of them so we only have positive
meanings to follow.

Change-Id: Ifd37d0368f97034d94aa2cf38db52c723ac0c6ed
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255493
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
Mike Frysinger 2020-02-17 14:36:08 -05:00 committed by David Pursehouse
parent e1191b3adb
commit c58ec4dba1
7 changed files with 34 additions and 32 deletions

View File

@ -108,7 +108,7 @@ global_options.add_option('-p', '--paginate',
dest='pager', action='store_true', dest='pager', action='store_true',
help='display command output in the pager') help='display command output in the pager')
global_options.add_option('--no-pager', global_options.add_option('--no-pager',
dest='no_pager', action='store_true', dest='pager', action='store_false',
help='disable the pager') help='disable the pager')
global_options.add_option('--color', global_options.add_option('--color',
choices=('auto', 'always', 'never'), default=None, choices=('auto', 'always', 'never'), default=None,
@ -222,7 +222,7 @@ class _Repo(object):
file=sys.stderr) file=sys.stderr)
return 1 return 1
if not gopts.no_pager and not isinstance(cmd, InteractiveCommand): if gopts.pager and not isinstance(cmd, InteractiveCommand):
config = cmd.manifest.globalConfig config = cmd.manifest.globalConfig
if gopts.pager: if gopts.pager:
use_pager = True use_pager = True

View File

@ -1432,7 +1432,7 @@ class Project(object):
current_branch_only=False, current_branch_only=False,
force_sync=False, force_sync=False,
clone_bundle=True, clone_bundle=True,
no_tags=False, tags=True,
archive=False, archive=False,
optimized_fetch=False, optimized_fetch=False,
prune=False, prune=False,
@ -1501,9 +1501,8 @@ class Project(object):
elif self.manifest.default.sync_c: elif self.manifest.default.sync_c:
current_branch_only = True current_branch_only = True
if not no_tags: if not self.sync_tags:
if not self.sync_tags: tags = False
no_tags = True
if self.clone_depth: if self.clone_depth:
depth = self.clone_depth depth = self.clone_depth
@ -1517,7 +1516,7 @@ class Project(object):
if not self._RemoteFetch( if not self._RemoteFetch(
initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir, initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir,
current_branch_only=current_branch_only, current_branch_only=current_branch_only,
no_tags=no_tags, prune=prune, depth=depth, tags=tags, prune=prune, depth=depth,
submodules=submodules, force_sync=force_sync, submodules=submodules, force_sync=force_sync,
clone_filter=clone_filter): clone_filter=clone_filter):
return False return False
@ -2197,7 +2196,7 @@ class Project(object):
quiet=False, quiet=False,
verbose=False, verbose=False,
alt_dir=None, alt_dir=None,
no_tags=False, tags=True,
prune=False, prune=False,
depth=None, depth=None,
submodules=False, submodules=False,
@ -2355,7 +2354,7 @@ class Project(object):
# If using depth then we should not get all the tags since they may # If using depth then we should not get all the tags since they may
# be outside of the depth. # be outside of the depth.
if no_tags or depth: if not tags or depth:
cmd.append('--no-tags') cmd.append('--no-tags')
else: else:
cmd.append('--tags') cmd.append('--tags')

13
repo
View File

@ -315,9 +315,11 @@ def GetParser(gitc_init=False):
help='restrict manifest projects to ones with a specified ' help='restrict manifest projects to ones with a specified '
'platform group [auto|all|none|linux|darwin|...]', 'platform group [auto|all|none|linux|darwin|...]',
metavar='PLATFORM') metavar='PLATFORM')
group.add_option('--no-clone-bundle', action='store_true', group.add_option('--no-clone-bundle',
dest='clone_bundle', default=True, action='store_false',
help='disable use of /clone.bundle on HTTP/HTTPS') help='disable use of /clone.bundle on HTTP/HTTPS')
group.add_option('--no-tags', action='store_true', group.add_option('--no-tags',
dest='tags', default=True, action='store_false',
help="don't fetch tags in the manifest") help="don't fetch tags in the manifest")
# Tool. # Tool.
@ -326,7 +328,8 @@ def GetParser(gitc_init=False):
help='repo repository location ($REPO_URL)') help='repo repository location ($REPO_URL)')
group.add_option('--repo-branch', metavar='REVISION', group.add_option('--repo-branch', metavar='REVISION',
help='repo branch or revision ($REPO_REV)') help='repo branch or revision ($REPO_REV)')
group.add_option('--no-repo-verify', action='store_true', group.add_option('--no-repo-verify',
dest='repo_verify', default=True, action='store_false',
help='do not verify repo source code') help='do not verify repo source code')
# Other. # Other.
@ -505,7 +508,7 @@ def _Init(args, gitc_init=False):
_CheckGitVersion() _CheckGitVersion()
try: try:
if opt.no_repo_verify: if not opt.repo_verify:
do_verify = False do_verify = False
else: else:
if NeedSetupGnuPG(): if NeedSetupGnuPG():
@ -514,7 +517,7 @@ def _Init(args, gitc_init=False):
do_verify = True do_verify = True
dst = os.path.abspath(os.path.join(repodir, S_repo)) dst = os.path.abspath(os.path.join(repodir, S_repo))
_Clone(url, dst, opt.quiet, not opt.no_clone_bundle) _Clone(url, dst, opt.quiet, opt.clone_bundle)
if do_verify: if do_verify:
rev = _Verify(dst, branch, opt.quiet) rev = _Verify(dst, branch, opt.quiet)

View File

@ -146,10 +146,10 @@ to update the working directory files.
'platform group [auto|all|none|linux|darwin|...]', 'platform group [auto|all|none|linux|darwin|...]',
metavar='PLATFORM') metavar='PLATFORM')
g.add_option('--no-clone-bundle', g.add_option('--no-clone-bundle',
dest='no_clone_bundle', action='store_true', dest='clone_bundle', default=True, action='store_false',
help='disable use of /clone.bundle on HTTP/HTTPS') help='disable use of /clone.bundle on HTTP/HTTPS')
g.add_option('--no-tags', g.add_option('--no-tags',
dest='no_tags', action='store_true', dest='tags', default=True, action='store_false',
help="don't fetch tags in the manifest") help="don't fetch tags in the manifest")
# Tool # Tool
@ -161,7 +161,7 @@ to update the working directory files.
dest='repo_branch', dest='repo_branch',
help='repo branch or revision', metavar='REVISION') help='repo branch or revision', metavar='REVISION')
g.add_option('--no-repo-verify', g.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true', dest='repo_verify', default=True, action='store_false',
help='do not verify repo source code') help='do not verify repo source code')
# Other # Other
@ -281,9 +281,9 @@ to update the working directory files.
m.config.SetString('repo.submodules', 'true') m.config.SetString('repo.submodules', 'true')
if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet,
clone_bundle=not opt.no_clone_bundle, clone_bundle=opt.clone_bundle,
current_branch_only=opt.current_branch_only, current_branch_only=opt.current_branch_only,
no_tags=opt.no_tags, submodules=opt.submodules, tags=opt.tags, submodules=opt.submodules,
clone_filter=opt.clone_filter): clone_filter=opt.clone_filter):
r = m.GetRemote(m.remote.name) r = m.GetRemote(m.remote.name)
print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)

View File

@ -53,7 +53,7 @@ branch but need to incorporate new upstream changes "underneath" them.
dest='force_rebase', action='store_true', dest='force_rebase', action='store_true',
help='Pass --force-rebase to git rebase') help='Pass --force-rebase to git rebase')
p.add_option('--no-ff', p.add_option('--no-ff',
dest='no_ff', action='store_true', dest='ff', default=True, action='store_false',
help='Pass --no-ff to git rebase') help='Pass --no-ff to git rebase')
p.add_option('-q', '--quiet', p.add_option('-q', '--quiet',
dest='quiet', action='store_true', dest='quiet', action='store_true',
@ -93,7 +93,7 @@ branch but need to incorporate new upstream changes "underneath" them.
common_args.append('--quiet') common_args.append('--quiet')
if opt.force_rebase: if opt.force_rebase:
common_args.append('--force-rebase') common_args.append('--force-rebase')
if opt.no_ff: if not opt.ff:
common_args.append('--no-ff') common_args.append('--no-ff')
if opt.autosquash: if opt.autosquash:
common_args.append('--autosquash') common_args.append('--autosquash')

View File

@ -40,7 +40,7 @@ need to be performed by an end-user.
def _Options(self, p): def _Options(self, p):
g = p.add_option_group('repo Version options') g = p.add_option_group('repo Version options')
g.add_option('--no-repo-verify', g.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true', dest='repo_verify', default=True, action='store_false',
help='do not verify repo source code') help='do not verify repo source code')
g.add_option('--repo-upgraded', g.add_option('--repo-upgraded',
dest='repo_upgraded', action='store_true', dest='repo_upgraded', action='store_true',
@ -60,5 +60,5 @@ need to be performed by an end-user.
rp.bare_git.gc('--auto') rp.bare_git.gc('--auto')
_PostRepoFetch(rp, _PostRepoFetch(rp,
no_repo_verify=opt.no_repo_verify, repo_verify=opt.repo_verify,
verbose=True) verbose=True)

View File

@ -247,7 +247,7 @@ later is required to fix a server side protocol bug.
dest='manifest_name', dest='manifest_name',
help='temporary manifest to use for this sync', metavar='NAME.xml') help='temporary manifest to use for this sync', metavar='NAME.xml')
p.add_option('--no-clone-bundle', p.add_option('--no-clone-bundle',
dest='no_clone_bundle', action='store_true', dest='clone_bundle', default=True, action='store_false',
help='disable use of /clone.bundle on HTTP/HTTPS') help='disable use of /clone.bundle on HTTP/HTTPS')
p.add_option('-u', '--manifest-server-username', action='store', p.add_option('-u', '--manifest-server-username', action='store',
dest='manifest_server_username', dest='manifest_server_username',
@ -259,7 +259,7 @@ later is required to fix a server side protocol bug.
dest='fetch_submodules', action='store_true', dest='fetch_submodules', action='store_true',
help='fetch submodules from server') help='fetch submodules from server')
p.add_option('--no-tags', p.add_option('--no-tags',
dest='no_tags', action='store_true', dest='tags', default=True, action='store_false',
help="don't fetch tags") help="don't fetch tags")
p.add_option('--optimized-fetch', p.add_option('--optimized-fetch',
dest='optimized_fetch', action='store_true', dest='optimized_fetch', action='store_true',
@ -276,7 +276,7 @@ later is required to fix a server side protocol bug.
g = p.add_option_group('repo Version options') g = p.add_option_group('repo Version options')
g.add_option('--no-repo-verify', g.add_option('--no-repo-verify',
dest='no_repo_verify', action='store_true', dest='repo_verify', default=True, action='store_false',
help='do not verify repo source code') help='do not verify repo source code')
g.add_option('--repo-upgraded', g.add_option('--repo-upgraded',
dest='repo_upgraded', action='store_true', dest='repo_upgraded', action='store_true',
@ -338,8 +338,8 @@ later is required to fix a server side protocol bug.
verbose=opt.verbose, verbose=opt.verbose,
current_branch_only=opt.current_branch_only, current_branch_only=opt.current_branch_only,
force_sync=opt.force_sync, force_sync=opt.force_sync,
clone_bundle=not opt.no_clone_bundle, clone_bundle=opt.clone_bundle,
no_tags=opt.no_tags, archive=self.manifest.IsArchive, tags=opt.tags, archive=self.manifest.IsArchive,
optimized_fetch=opt.optimized_fetch, optimized_fetch=opt.optimized_fetch,
prune=opt.prune, prune=opt.prune,
clone_filter=clone_filter) clone_filter=clone_filter)
@ -841,7 +841,7 @@ later is required to fix a server side protocol bug.
start = time.time() start = time.time()
success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose, success = mp.Sync_NetworkHalf(quiet=opt.quiet, verbose=opt.verbose,
current_branch_only=opt.current_branch_only, current_branch_only=opt.current_branch_only,
no_tags=opt.no_tags, tags=opt.tags,
optimized_fetch=opt.optimized_fetch, optimized_fetch=opt.optimized_fetch,
submodules=self.manifest.HasSubmodules, submodules=self.manifest.HasSubmodules,
clone_filter=self.manifest.CloneFilter) clone_filter=self.manifest.CloneFilter)
@ -977,7 +977,7 @@ later is required to fix a server side protocol bug.
fetched = self._Fetch(to_fetch, opt, err_event) fetched = self._Fetch(to_fetch, opt, err_event)
_PostRepoFetch(rp, opt.no_repo_verify) _PostRepoFetch(rp, opt.repo_verify)
if opt.network_only: if opt.network_only:
# bail out now; the rest touches the working tree # bail out now; the rest touches the working tree
if err_event.isSet(): if err_event.isSet():
@ -1067,11 +1067,11 @@ def _PostRepoUpgrade(manifest, quiet=False):
project.PostRepoUpgrade() project.PostRepoUpgrade()
def _PostRepoFetch(rp, no_repo_verify=False, verbose=False): def _PostRepoFetch(rp, repo_verify=True, verbose=False):
if rp.HasChanges: if rp.HasChanges:
print('info: A new version of repo is available', file=sys.stderr) print('info: A new version of repo is available', file=sys.stderr)
print(file=sys.stderr) print(file=sys.stderr)
if no_repo_verify or _VerifyTag(rp): if not repo_verify or _VerifyTag(rp):
syncbuf = SyncBuffer(rp.config) syncbuf = SyncBuffer(rp.config)
rp.Sync_LocalHalf(syncbuf) rp.Sync_LocalHalf(syncbuf)
if not syncbuf.Finish(): if not syncbuf.Finish():