mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-10 22:41:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bb901eab0 | ||
|
|
b2e30cef91 | ||
|
|
27402ddb25 | ||
|
|
5b04e6e7c5 | ||
|
|
eb668be30d |
No files matched your search
@@ -10,32 +10,12 @@ per-file-ignores =
|
||||
git_status.py: IMR241,
|
||||
main.py: IMR241,
|
||||
manifest_xml.py: IMR241,
|
||||
subcmds/abandon.py: IMR241,
|
||||
subcmds/branches.py: IMR241,
|
||||
subcmds/checkout.py: IMR241,
|
||||
subcmds/cherry_pick.py: IMR241,
|
||||
subcmds/diffmanifests.py: IMR241,
|
||||
subcmds/diff.py: IMR241,
|
||||
subcmds/download.py: IMR241,
|
||||
subcmds/forall.py: IMR241,
|
||||
subcmds/gc.py: IMR241,
|
||||
subcmds/grep.py: IMR241,
|
||||
subcmds/help.py: IMR241,
|
||||
subcmds/info.py: IMR241,
|
||||
subcmds/init.py: IMR241,
|
||||
subcmds/list.py: IMR241,
|
||||
subcmds/manifest.py: IMR241,
|
||||
subcmds/overview.py: IMR241,
|
||||
subcmds/prune.py: IMR241,
|
||||
subcmds/rebase.py: IMR241,
|
||||
subcmds/selfupdate.py: IMR241,
|
||||
subcmds/smartsync.py: IMR241,
|
||||
subcmds/stage.py: IMR241,
|
||||
subcmds/start.py: IMR241,
|
||||
subcmds/status.py: IMR241,
|
||||
subcmds/sync.py: IMR241,
|
||||
subcmds/upload.py: IMR241,
|
||||
subcmds/version.py: IMR241,
|
||||
subcmds/wipe.py: IMR241,
|
||||
tests/e2e/test_failures.py: IMR241,
|
||||
tests/e2e/test_groups.py: IMR241,
|
||||
@@ -44,10 +24,6 @@ per-file-ignores =
|
||||
tests/e2e/test_partial_clone.py: IMR241,
|
||||
tests/e2e/test_sync_modes.py: IMR241,
|
||||
tests/e2e/test_workflows.py: IMR241,
|
||||
tests/test_command.py: IMR241,
|
||||
tests/test_error.py: IMR241,
|
||||
tests/test_main.py: IMR241,
|
||||
tests/test_subcmds.py: IMR241,
|
||||
tests/test_subcmds_sync.py: IMR241,
|
||||
extend-ignore =
|
||||
# E203: Whitespace before ':'
|
||||
|
||||
@@ -42,8 +42,7 @@ except ImportError:
|
||||
kerberos = None
|
||||
|
||||
import color
|
||||
from command import InteractiveCommand
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
import editor
|
||||
import error
|
||||
import event_log
|
||||
@@ -53,7 +52,7 @@ import git_trace2_event_log
|
||||
import manifest_xml
|
||||
import pager
|
||||
import repo_trace
|
||||
from subcmds import all_commands
|
||||
import subcmds
|
||||
from subcmds.version import Version
|
||||
import wrapper
|
||||
|
||||
@@ -181,7 +180,7 @@ global_options.add_option(
|
||||
class _Repo:
|
||||
def __init__(self, repodir):
|
||||
self.repodir = repodir
|
||||
self.commands = all_commands
|
||||
self.commands = subcmds.all_commands
|
||||
|
||||
def _PrintHelp(self, short: bool = False, all_commands: bool = False):
|
||||
"""Show --help screen."""
|
||||
@@ -415,7 +414,10 @@ class _Repo:
|
||||
|
||||
editor.Editor.globalConfig = cmd.client.globalConfig
|
||||
|
||||
if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
|
||||
if (
|
||||
not isinstance(cmd, command.MirrorSafeCommand)
|
||||
and cmd.manifest.IsMirror
|
||||
):
|
||||
logger.error("fatal: '%s' requires a working directory", name)
|
||||
return 1
|
||||
|
||||
@@ -432,7 +434,9 @@ class _Repo:
|
||||
cmd.CommonValidateOptions(copts, cargs)
|
||||
git_trace2_event_log.verbose = copts.verbose
|
||||
|
||||
if gopts.pager is not False and not isinstance(cmd, InteractiveCommand):
|
||||
if gopts.pager is not False and not isinstance(
|
||||
cmd, command.InteractiveCommand
|
||||
):
|
||||
config = cmd.client.globalConfig
|
||||
if gopts.pager:
|
||||
use_pager = True
|
||||
|
||||
+3
-4
@@ -16,8 +16,7 @@ import collections
|
||||
import functools
|
||||
import itertools
|
||||
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
import progress
|
||||
@@ -31,7 +30,7 @@ class AbandonError(error.RepoExitError):
|
||||
"""Exit error when abandon command fails."""
|
||||
|
||||
|
||||
class Abandon(Command):
|
||||
class Abandon(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Permanently abandon a development branch"
|
||||
helpUsage = """
|
||||
@@ -42,7 +41,7 @@ deleting it (and all its history) from your local repository.
|
||||
|
||||
It is equivalent to "git branch -D <branchname>".
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
|
||||
+3
-4
@@ -16,8 +16,7 @@ import itertools
|
||||
import sys
|
||||
|
||||
import color
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import command
|
||||
|
||||
|
||||
class BranchColoring(color.Coloring):
|
||||
@@ -62,7 +61,7 @@ class BranchInfo:
|
||||
return self.published_equal == len(self.projects)
|
||||
|
||||
|
||||
class Branches(Command):
|
||||
class Branches(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "View current topic branches"
|
||||
helpUsage = """
|
||||
@@ -96,7 +95,7 @@ the branch appears in, or does not appear in. If no project list
|
||||
is shown, then the branch appears in all projects.
|
||||
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
@classmethod
|
||||
def _ExpandProjectToBranches(cls, project_idx):
|
||||
|
||||
+3
-4
@@ -15,8 +15,7 @@
|
||||
import functools
|
||||
from typing import NamedTuple
|
||||
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import command
|
||||
import error
|
||||
import progress
|
||||
import repo_logging
|
||||
@@ -40,7 +39,7 @@ class MissingBranchError(error.RepoExitError):
|
||||
"""Exception thrown when no project has specified branch."""
|
||||
|
||||
|
||||
class Checkout(Command):
|
||||
class Checkout(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Checkout a branch for development"
|
||||
helpUsage = """
|
||||
@@ -54,7 +53,7 @@ The command is equivalent to:
|
||||
|
||||
repo forall [<project>...] -c git checkout <branchname>
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def ValidateOptions(self, opt, args):
|
||||
if not args:
|
||||
|
||||
@@ -16,7 +16,7 @@ import re
|
||||
import sys
|
||||
from typing import Tuple
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
import repo_logging
|
||||
@@ -26,7 +26,7 @@ CHANGE_ID_RE = re.compile(r"^\s*Change-Id: I([0-9a-f]{40})\s*$")
|
||||
logger = repo_logging.RepoLogger(__file__)
|
||||
|
||||
|
||||
class CherryPick(Command):
|
||||
class CherryPick(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Cherry-pick a change."
|
||||
helpUsage = """
|
||||
|
||||
+3
-4
@@ -15,11 +15,10 @@
|
||||
import functools
|
||||
import io
|
||||
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import PagedCommand
|
||||
import command
|
||||
|
||||
|
||||
class Diff(PagedCommand):
|
||||
class Diff(command.PagedCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Show changes between commit and working tree"
|
||||
helpUsage = """
|
||||
@@ -29,7 +28,7 @@ The -u option causes '%prog' to generate diff output with file paths
|
||||
relative to the repository root, so the output can be applied
|
||||
to the Unix 'patch' command.
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import color
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import manifest_xml
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class _Coloring(color.Coloring):
|
||||
super().__init__(config, "status")
|
||||
|
||||
|
||||
class Diffmanifests(PagedCommand):
|
||||
class Diffmanifests(command.PagedCommand):
|
||||
"""A command to see logs in projects represented by manifests
|
||||
|
||||
This is used to see deeper differences between manifests. Where a simple
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
import error
|
||||
import repo_logging
|
||||
|
||||
@@ -28,7 +28,7 @@ class DownloadCommandError(error.RepoExitError):
|
||||
"""Error raised when download command fails."""
|
||||
|
||||
|
||||
class Download(Command):
|
||||
class Download(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Download and checkout a change"
|
||||
helpUsage = """
|
||||
|
||||
+3
-5
@@ -22,9 +22,7 @@ import subprocess
|
||||
import sys
|
||||
|
||||
import color
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
import repo_logging
|
||||
|
||||
|
||||
@@ -43,7 +41,7 @@ class ForallColoring(color.Coloring):
|
||||
self.project = self.printer("project", attr="bold")
|
||||
|
||||
|
||||
class Forall(Command, MirrorSafeCommand):
|
||||
class Forall(command.Command, command.MirrorSafeCommand):
|
||||
COMMON = False
|
||||
helpSummary = "Run a shell command in each project"
|
||||
helpUsage = """
|
||||
@@ -136,7 +134,7 @@ terminal and are not redirected.
|
||||
If -e is used, when a command exits unsuccessfully, '%prog' will abort
|
||||
without iterating through the remaining projects.
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
@staticmethod
|
||||
def _cmd_option(option, _opt_str, _value, parser):
|
||||
|
||||
+2
-2
@@ -15,14 +15,14 @@
|
||||
import os
|
||||
from typing import List, Set
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
import git_command
|
||||
import platform_utils
|
||||
import progress
|
||||
from project import Project
|
||||
|
||||
|
||||
class Gc(Command):
|
||||
class Gc(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Cleaning up internal repo and Git state."
|
||||
helpUsage = """
|
||||
|
||||
+3
-4
@@ -17,8 +17,7 @@ import sys
|
||||
from typing import NamedTuple
|
||||
|
||||
import color
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
import repo_logging
|
||||
@@ -50,7 +49,7 @@ class GrepCommandError(error.SilentRepoExitError):
|
||||
aggregate errors exit silently."""
|
||||
|
||||
|
||||
class Grep(PagedCommand):
|
||||
class Grep(command.PagedCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Print lines matching a pattern"
|
||||
helpUsage = """
|
||||
@@ -84,7 +83,7 @@ contain a line that matches both expressions:
|
||||
repo grep --all-match -e NODE -e Unexpected
|
||||
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
@staticmethod
|
||||
def _carry_option(_option, opt_str, value, parser):
|
||||
|
||||
+18
-18
@@ -15,12 +15,12 @@
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
from typing import Sequence
|
||||
|
||||
import color
|
||||
from command import MirrorSafeCommand
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import error
|
||||
from subcmds import all_commands
|
||||
import subcmds
|
||||
import wrapper
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class InvalidHelpCommand(error.RepoExitError):
|
||||
"""Invalid command passed into help."""
|
||||
|
||||
|
||||
class Help(PagedCommand, MirrorSafeCommand):
|
||||
class Help(command.PagedCommand, command.MirrorSafeCommand):
|
||||
COMMON = False
|
||||
helpSummary = "Display detailed help on a command"
|
||||
helpUsage = """
|
||||
@@ -38,17 +38,17 @@ class Help(PagedCommand, MirrorSafeCommand):
|
||||
Displays detailed usage information about a command.
|
||||
"""
|
||||
|
||||
def _PrintCommands(self, commandNames):
|
||||
"""Helper to display |commandNames| summaries."""
|
||||
def _PrintCommands(self, names: Sequence[str]) -> None:
|
||||
"""Helper to display |names| summaries."""
|
||||
maxlen = 0
|
||||
for name in commandNames:
|
||||
for name in names:
|
||||
maxlen = max(maxlen, len(name))
|
||||
fmt = " %%-%ds %%s" % maxlen
|
||||
|
||||
for name in commandNames:
|
||||
command = all_commands[name]()
|
||||
for name in names:
|
||||
cmd = subcmds.all_commands[name]()
|
||||
try:
|
||||
summary = command.helpSummary.strip()
|
||||
summary = cmd.helpSummary.strip()
|
||||
except AttributeError:
|
||||
summary = ""
|
||||
print(fmt % (name, summary))
|
||||
@@ -59,8 +59,8 @@ Displays detailed usage information about a command.
|
||||
|
||||
def PrintAllCommandsBody(self):
|
||||
print("The complete list of recognized repo commands is:")
|
||||
commandNames = sorted(all_commands)
|
||||
self._PrintCommands(commandNames)
|
||||
names = sorted(subcmds.all_commands)
|
||||
self._PrintCommands(names)
|
||||
print(
|
||||
"See 'repo help <command>' for more information on a "
|
||||
"specific command."
|
||||
@@ -74,10 +74,10 @@ Displays detailed usage information about a command.
|
||||
def PrintCommonCommandsBody(self):
|
||||
print("The most commonly used repo commands are:")
|
||||
|
||||
commandNames = sorted(
|
||||
name for name, command in all_commands.items() if command.COMMON
|
||||
names = sorted(
|
||||
name for name, cmd in subcmds.all_commands.items() if cmd.COMMON
|
||||
)
|
||||
self._PrintCommands(commandNames)
|
||||
self._PrintCommands(names)
|
||||
|
||||
print(
|
||||
"See 'repo help <command>' for more information on a specific "
|
||||
@@ -146,8 +146,8 @@ Displays detailed usage information about a command.
|
||||
out._PrintSection("Description", "helpDescription")
|
||||
|
||||
def _PrintAllCommandHelp(self):
|
||||
for name in sorted(all_commands):
|
||||
cmd = all_commands[name](manifest=self.manifest)
|
||||
for name in sorted(subcmds.all_commands):
|
||||
cmd = subcmds.all_commands[name](manifest=self.manifest)
|
||||
self._PrintCommandHelp(cmd, header_prefix=f"[{name}] ")
|
||||
|
||||
def _Options(self, p):
|
||||
@@ -178,7 +178,7 @@ Displays detailed usage information about a command.
|
||||
name = args[0]
|
||||
|
||||
try:
|
||||
cmd = all_commands[name](manifest=self.manifest)
|
||||
cmd = subcmds.all_commands[name](manifest=self.manifest)
|
||||
except KeyError:
|
||||
print(
|
||||
"repo: '%s' is not a repo command." % name, file=sys.stderr
|
||||
|
||||
+3
-4
@@ -21,8 +21,7 @@ import sys
|
||||
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
|
||||
|
||||
import color
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import git_refs
|
||||
|
||||
|
||||
@@ -51,9 +50,9 @@ class _Coloring(color.Coloring):
|
||||
super().__init__(config, "status")
|
||||
|
||||
|
||||
class Info(PagedCommand):
|
||||
class Info(command.PagedCommand):
|
||||
COMMON = True
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
helpSummary = (
|
||||
"Get info on the manifest branch, current branch or unmerged branches"
|
||||
)
|
||||
|
||||
+2
-3
@@ -16,8 +16,7 @@ import os
|
||||
import sys
|
||||
|
||||
import color
|
||||
from command import InteractiveCommand
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
import repo_logging
|
||||
@@ -29,7 +28,7 @@ logger = repo_logging.RepoLogger(__file__)
|
||||
_REPO_ALLOW_SHALLOW = os.environ.get("REPO_ALLOW_SHALLOW")
|
||||
|
||||
|
||||
class Init(InteractiveCommand, MirrorSafeCommand):
|
||||
class Init(command.InteractiveCommand, command.MirrorSafeCommand):
|
||||
COMMON = True
|
||||
RESPECT_SMART_SYNC_OVERRIDE = False
|
||||
MULTI_MANIFEST_SUPPORT = True
|
||||
|
||||
+2
-3
@@ -14,11 +14,10 @@
|
||||
|
||||
import os
|
||||
|
||||
from command import Command
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
|
||||
|
||||
class List(Command, MirrorSafeCommand):
|
||||
class List(command.Command, command.MirrorSafeCommand):
|
||||
COMMON = True
|
||||
helpSummary = "List projects and their associated directories"
|
||||
helpUsage = """
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import repo_logging
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class OutputFormat(enum.Enum):
|
||||
JSON = enum.auto()
|
||||
|
||||
|
||||
class Manifest(PagedCommand):
|
||||
class Manifest(command.PagedCommand):
|
||||
COMMON = False
|
||||
helpSummary = "Manifest inspection utility"
|
||||
helpUsage = """
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
import optparse
|
||||
|
||||
import color
|
||||
from command import PagedCommand
|
||||
import command
|
||||
|
||||
|
||||
class Overview(PagedCommand):
|
||||
class Overview(command.PagedCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Display overview of unmerged project branches"
|
||||
helpUsage = """
|
||||
|
||||
+3
-4
@@ -15,17 +15,16 @@
|
||||
import itertools
|
||||
|
||||
import color
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import PagedCommand
|
||||
import command
|
||||
|
||||
|
||||
class Prune(PagedCommand):
|
||||
class Prune(command.PagedCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Prune (delete) already merged topics"
|
||||
helpUsage = """
|
||||
%prog [<project>...]
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
@classmethod
|
||||
def _ExecuteOne(cls, project_idx):
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
import sys
|
||||
|
||||
import color
|
||||
from command import Command
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
from project import Project
|
||||
@@ -43,7 +43,7 @@ def _ResolveOntoManifest(project: Project) -> str:
|
||||
return project.revisionExpr
|
||||
|
||||
|
||||
class Rebase(Command):
|
||||
class Rebase(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Rebase local branches on upstream branch"
|
||||
helpUsage = """
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
import optparse
|
||||
|
||||
from command import Command
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
import error
|
||||
import repo_logging
|
||||
from subcmds.sync import _PostRepoFetch
|
||||
@@ -29,7 +28,7 @@ class SelfupdateError(error.RepoExitError):
|
||||
"""Exit error for failed selfupdate command."""
|
||||
|
||||
|
||||
class Selfupdate(Command, MirrorSafeCommand):
|
||||
class Selfupdate(command.Command, command.MirrorSafeCommand):
|
||||
COMMON = False
|
||||
helpSummary = "Update repo to the latest version"
|
||||
helpUsage = """
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
import sys
|
||||
|
||||
import color
|
||||
from command import InteractiveCommand
|
||||
import command
|
||||
import git_command
|
||||
import repo_logging
|
||||
|
||||
@@ -31,7 +31,7 @@ class _ProjectList(color.Coloring):
|
||||
self.help = self.printer("help", fg="red", attr="bold")
|
||||
|
||||
|
||||
class Stage(InteractiveCommand):
|
||||
class Stage(command.InteractiveCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Stage file(s) for commit"
|
||||
helpUsage = """
|
||||
|
||||
+3
-4
@@ -15,8 +15,7 @@
|
||||
import functools
|
||||
from typing import NamedTuple
|
||||
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import command
|
||||
import error
|
||||
import git_command
|
||||
import git_config
|
||||
@@ -36,7 +35,7 @@ class StartError(error.RepoExitError):
|
||||
"""Exit error for failed start command."""
|
||||
|
||||
|
||||
class Start(Command):
|
||||
class Start(command.Command):
|
||||
COMMON = True
|
||||
helpSummary = "Start a new branch for development"
|
||||
helpUsage = """
|
||||
@@ -46,7 +45,7 @@ class Start(Command):
|
||||
'%prog' begins a new branch of development, starting from the
|
||||
revision specified in the manifest.
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
|
||||
+3
-4
@@ -18,12 +18,11 @@ import io
|
||||
import os
|
||||
|
||||
import color
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import PagedCommand
|
||||
import command
|
||||
import platform_utils
|
||||
|
||||
|
||||
class Status(PagedCommand):
|
||||
class Status(command.PagedCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Show the working tree status"
|
||||
helpUsage = """
|
||||
@@ -82,7 +81,7 @@ the following meanings:
|
||||
d: deleted ( in index, not in work tree )
|
||||
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
|
||||
+7
-8
@@ -53,10 +53,7 @@ except ImportError:
|
||||
return (256, 256)
|
||||
|
||||
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import MirrorSafeCommand
|
||||
from command import WORKER_BATCH_SIZE
|
||||
import command
|
||||
import error
|
||||
import event_log
|
||||
import git_command
|
||||
@@ -294,7 +291,7 @@ def _WithoutProjects(
|
||||
|
||||
def _chunksize(projects: int, jobs: int) -> int:
|
||||
"""Calculate chunk size for the given number of projects and jobs."""
|
||||
return min(max(1, projects // jobs), WORKER_BATCH_SIZE)
|
||||
return min(max(1, projects // jobs), command.WORKER_BATCH_SIZE)
|
||||
|
||||
|
||||
class _FetchOneResult(NamedTuple):
|
||||
@@ -447,7 +444,7 @@ class TeeStringIO(io.StringIO):
|
||||
return ret
|
||||
|
||||
|
||||
class Sync(Command, MirrorSafeCommand):
|
||||
class Sync(command.Command, command.MirrorSafeCommand):
|
||||
COMMON = True
|
||||
RESPECT_SMART_SYNC_OVERRIDE = False
|
||||
MULTI_MANIFEST_SUPPORT = True
|
||||
@@ -592,7 +589,9 @@ later is required to fix a server side protocol bug.
|
||||
"--jobs or 1). Ignored unless --no-interleaved is set",
|
||||
)
|
||||
|
||||
jobs_checkout_default = self._GetHelpForCpuJobCount(DEFAULT_LOCAL_JOBS)
|
||||
jobs_checkout_default = self._GetHelpForCpuJobCount(
|
||||
command.DEFAULT_LOCAL_JOBS
|
||||
)
|
||||
p.add_option(
|
||||
"--jobs-checkout",
|
||||
default=None,
|
||||
@@ -2389,7 +2388,7 @@ later is required to fix a server side protocol bug.
|
||||
if not opt.jobs_network:
|
||||
opt.jobs_network = 1
|
||||
if not opt.jobs_checkout:
|
||||
opt.jobs_checkout = DEFAULT_LOCAL_JOBS
|
||||
opt.jobs_checkout = command.DEFAULT_LOCAL_JOBS
|
||||
opt.jobs = os.cpu_count()
|
||||
|
||||
# Try to stay under user rlimit settings.
|
||||
|
||||
+3
-4
@@ -19,8 +19,7 @@ import re
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
from command import InteractiveCommand
|
||||
import command
|
||||
import editor
|
||||
import error
|
||||
import git_refs
|
||||
@@ -104,7 +103,7 @@ def _SplitEmails(values):
|
||||
return result
|
||||
|
||||
|
||||
class Upload(InteractiveCommand):
|
||||
class Upload(command.InteractiveCommand):
|
||||
COMMON = True
|
||||
helpSummary = "Upload changes for code review"
|
||||
helpUsage = """
|
||||
@@ -211,7 +210,7 @@ threshold to a different value.
|
||||
Gerrit Code Review: https://www.gerritcodereview.com/
|
||||
|
||||
"""
|
||||
PARALLEL_JOBS = DEFAULT_LOCAL_JOBS
|
||||
PARALLEL_JOBS = command.DEFAULT_LOCAL_JOBS
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
|
||||
+2
-3
@@ -16,14 +16,13 @@ import platform
|
||||
import sys
|
||||
from typing import Any, Tuple
|
||||
|
||||
from command import Command
|
||||
from command import MirrorSafeCommand
|
||||
import command
|
||||
import git_command
|
||||
import git_refs
|
||||
import wrapper
|
||||
|
||||
|
||||
class Version(Command, MirrorSafeCommand):
|
||||
class Version(command.Command, command.MirrorSafeCommand):
|
||||
wrapper_version = None
|
||||
wrapper_path = None
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import os
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
import error
|
||||
import platform_utils
|
||||
from project import DeleteWorktreeError
|
||||
@@ -26,7 +26,7 @@ class Error(error.RepoExitError):
|
||||
"""Exit error when wipe command fails."""
|
||||
|
||||
|
||||
class Wipe(Command):
|
||||
class Wipe(command.Command):
|
||||
"""Delete projects from the worktree and .repo"""
|
||||
|
||||
COMMON = True
|
||||
|
||||
@@ -18,7 +18,7 @@ from typing import Iterable, List, Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
|
||||
|
||||
class FakeProject:
|
||||
@@ -136,7 +136,7 @@ def test_get_projects_keeps_derived_subprojects_for_repeated_repo():
|
||||
sync_s=True,
|
||||
)
|
||||
manifest = FakeManifest([project_a, project_b])
|
||||
cmd = Command(manifest=manifest)
|
||||
cmd = command.Command(manifest=manifest)
|
||||
|
||||
projects = cmd.GetProjects([])
|
||||
|
||||
@@ -165,7 +165,7 @@ def test_get_projects_submodule_override(
|
||||
derived_subprojects=[submodule],
|
||||
sync_s=sync_s,
|
||||
)
|
||||
cmd = Command(manifest=FakeManifest([project]))
|
||||
cmd = command.Command(manifest=FakeManifest([project]))
|
||||
|
||||
projects = cmd.GetProjects([], submodules_ok=submodules_ok)
|
||||
|
||||
@@ -214,7 +214,7 @@ def test_get_projects_uses_groups_from_each_manifest_unless_overridden(
|
||||
all_projects=[outer_project, *child_manifest.projects],
|
||||
effective_groups="outer-group",
|
||||
)
|
||||
cmd = Command(manifest=outer_manifest)
|
||||
cmd = command.Command(manifest=outer_manifest)
|
||||
|
||||
projects = cmd.GetProjects(
|
||||
[],
|
||||
@@ -248,7 +248,7 @@ def test_get_projects_by_name_uses_groups_from_each_manifest() -> None:
|
||||
all_projects=[outer_project, *child_manifest.projects],
|
||||
effective_groups="outer-group",
|
||||
)
|
||||
cmd = Command(manifest=outer_manifest)
|
||||
cmd = command.Command(manifest=outer_manifest)
|
||||
|
||||
projects = cmd.GetProjects(
|
||||
["shared"],
|
||||
@@ -296,7 +296,7 @@ def test_find_projects_uses_groups_from_each_manifest() -> None:
|
||||
)
|
||||
outer_manifest.outer_client = outer_manifest
|
||||
|
||||
cmd = Command(manifest=outer_manifest)
|
||||
cmd = command.Command(manifest=outer_manifest)
|
||||
|
||||
projects = cmd.FindProjects(["match"], all_manifests=True)
|
||||
|
||||
@@ -322,7 +322,7 @@ def test_find_projects_uses_explicit_groups() -> None:
|
||||
[default_project, override_project],
|
||||
effective_groups="default-group",
|
||||
)
|
||||
cmd = Command(manifest=manifest)
|
||||
cmd = command.Command(manifest=manifest)
|
||||
|
||||
projects = cmd.FindProjects(
|
||||
["override"],
|
||||
@@ -339,7 +339,7 @@ def test_find_projects_allows_missing_projects() -> None:
|
||||
"missing",
|
||||
exists=False,
|
||||
)
|
||||
cmd = Command(manifest=FakeManifest([project]))
|
||||
cmd = command.Command(manifest=FakeManifest([project]))
|
||||
|
||||
projects = cmd.FindProjects(
|
||||
["missing"],
|
||||
|
||||
+2
-2
@@ -25,10 +25,10 @@ import error
|
||||
import fetch
|
||||
import git_command
|
||||
import project
|
||||
from subcmds import all_modules
|
||||
import subcmds
|
||||
|
||||
|
||||
_IMPORTS = all_modules + [
|
||||
_IMPORTS = subcmds.all_modules + [
|
||||
error,
|
||||
project,
|
||||
git_command,
|
||||
|
||||
@@ -65,60 +65,6 @@ class GitCommandTest(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class GitCommandWaitTest(unittest.TestCase):
|
||||
"""Tests the GitCommand class .Wait()"""
|
||||
|
||||
def setUp(self):
|
||||
class MockPopen:
|
||||
rc = 0
|
||||
|
||||
def __init__(self):
|
||||
self.stdout = io.BufferedReader(io.BytesIO())
|
||||
self.stderr = io.BufferedReader(io.BytesIO())
|
||||
|
||||
def communicate(
|
||||
self, input: str = None, timeout: float = None
|
||||
) -> [str, str]:
|
||||
"""Mock communicate fn."""
|
||||
return ["", ""]
|
||||
|
||||
def wait(self, timeout=None):
|
||||
return self.rc
|
||||
|
||||
self.popen = popen = MockPopen()
|
||||
|
||||
def popen_mock(*args, **kwargs):
|
||||
return popen
|
||||
|
||||
def realpath_mock(val):
|
||||
return val
|
||||
|
||||
mock.patch.object(subprocess, "Popen", side_effect=popen_mock).start()
|
||||
|
||||
mock.patch.object(
|
||||
os.path, "realpath", side_effect=realpath_mock
|
||||
).start()
|
||||
|
||||
def tearDown(self):
|
||||
mock.patch.stopall()
|
||||
|
||||
def test_raises_when_verify_non_zero_result(self):
|
||||
self.popen.rc = 1
|
||||
r = git_command.GitCommand(None, ["status"], verify_command=True)
|
||||
with self.assertRaises(git_command.GitCommandError):
|
||||
r.Wait()
|
||||
|
||||
def test_returns_when_no_verify_non_zero_result(self):
|
||||
self.popen.rc = 1
|
||||
r = git_command.GitCommand(None, ["status"], verify_command=False)
|
||||
self.assertEqual(1, r.Wait())
|
||||
|
||||
def test_default_returns_non_zero_result(self):
|
||||
self.popen.rc = 1
|
||||
r = git_command.GitCommand(None, ["status"])
|
||||
self.assertEqual(1, r.Wait())
|
||||
|
||||
|
||||
class GitCommandStreamLogsTest(unittest.TestCase):
|
||||
"""Tests the GitCommand class stderr log streaming cases."""
|
||||
|
||||
|
||||
+3
-3
@@ -20,12 +20,12 @@ from unittest import mock
|
||||
import pytest
|
||||
|
||||
import event_log
|
||||
from main import _Repo
|
||||
import main
|
||||
|
||||
|
||||
@pytest.fixture(name="repo")
|
||||
def fixture_repo():
|
||||
repo = _Repo("repodir")
|
||||
repo = main._Repo("repodir")
|
||||
# Overriding the command list here ensures that we are only testing
|
||||
# against a fixed set of commands, reducing fragility to new
|
||||
# subcommands being added to the main repo tool.
|
||||
@@ -189,7 +189,7 @@ def test_run_long_gates_event_log_on_flag(
|
||||
client = mock_client_cls.return_value
|
||||
client.manifest.IsMirror = False
|
||||
client.manifest.manifestProject.config.DumpConfigDict.return_value = {}
|
||||
repo = _Repo("repodir")
|
||||
repo = main._Repo("repodir")
|
||||
|
||||
for log_path, expected in (
|
||||
(None, False),
|
||||
|
||||
@@ -19,7 +19,7 @@ from typing import Type
|
||||
|
||||
import pytest
|
||||
|
||||
from command import Command
|
||||
import command
|
||||
import subcmds
|
||||
from subcmds import sync
|
||||
|
||||
@@ -49,7 +49,7 @@ def test_naming(name: str) -> None:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, cls", subcmds.all_commands.items())
|
||||
def test_help_desc_style(name: str, cls: Type[Command]) -> None:
|
||||
def test_help_desc_style(name: str, cls: Type[command.Command]) -> None:
|
||||
"""Force some consistency in option descriptions.
|
||||
|
||||
Python's optparse & argparse has a few default options like --help.
|
||||
@@ -79,7 +79,7 @@ def test_help_desc_style(name: str, cls: Type[Command]) -> None:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, cls", subcmds.all_commands.items())
|
||||
def test_cli_option_style(name: str, cls: Type[Command]) -> None:
|
||||
def test_cli_option_style(name: str, cls: Type[command.Command]) -> None:
|
||||
"""Force some consistency in option flags."""
|
||||
cmd = cls()
|
||||
parser = cmd.OptionParser
|
||||
@@ -142,7 +142,7 @@ def test_cli_option_dest() -> None:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, cls", subcmds.all_commands.items())
|
||||
def test_common_validate_options(name: str, cls: Type[Command]) -> None:
|
||||
def test_common_validate_options(name: str, cls: Type[command.Command]) -> None:
|
||||
"""Verify CommonValidateOptions sets up expected fields."""
|
||||
cmd = cls()
|
||||
opts, args = cmd.OptionParser.parse_args([])
|
||||
|
||||
@@ -360,7 +360,7 @@ def test_jobs_checkout_help_default(
|
||||
expected_default: str,
|
||||
) -> None:
|
||||
"""Test checkout-jobs default help in interactive and manpage modes."""
|
||||
with mock.patch.object(sync, "DEFAULT_LOCAL_JOBS", 7), mock.patch.object(
|
||||
with mock.patch.object(command, "DEFAULT_LOCAL_JOBS", 7), mock.patch.object(
|
||||
command,
|
||||
"GENERATE_MANPAGES",
|
||||
generate_manpages,
|
||||
|
||||
Reference in new issue
Block a user