diff options
| author | LaMont Jones <lamontjones@google.com> | 2022-06-01 21:03:34 +0000 |
|---|---|---|
| committer | LaMont Jones <lamontjones@google.com> | 2022-06-08 16:49:08 +0000 |
| commit | ff6b1dae1e9f2e7405690c1aeedf7e0c7d768460 (patch) | |
| tree | c0ffaeea5ed6ccee683f47e6cef5a8897b130cb7 /manifest_xml.py | |
| parent | bdcba7dc36f1c8e6041681eb5b3b5229c93c7c5c (diff) | |
| download | git-repo-ff6b1dae1e9f2e7405690c1aeedf7e0c7d768460.tar.gz | |
Only sync superproject if it will be used.
If the user says `--no-use-superproject`, then do not bother syncing the
superproject.
Also add/update docstrings and comments throughout.
Change-Id: I9cdad706130501bab9a22d3099a1dae605e9c194
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/338975
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index db7a9286..32f6b687 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -348,7 +348,7 @@ class XmlManifest(object): | |||
| 348 | be |repodir|/|MANIFEST_FILE_NAME|. | 348 | be |repodir|/|MANIFEST_FILE_NAME|. |
| 349 | local_manifests: Full path to the directory of local override manifests. | 349 | local_manifests: Full path to the directory of local override manifests. |
| 350 | This will usually be |repodir|/|LOCAL_MANIFESTS_DIR_NAME|. | 350 | This will usually be |repodir|/|LOCAL_MANIFESTS_DIR_NAME|. |
| 351 | outer_client: RepoClient of the outertree. | 351 | outer_client: RepoClient of the outer manifest. |
| 352 | parent_groups: a string, the groups to apply to this projects. | 352 | parent_groups: a string, the groups to apply to this projects. |
| 353 | submanifest_path: The submanifest root relative to the repo root. | 353 | submanifest_path: The submanifest root relative to the repo root. |
| 354 | default_groups: a string, the default manifest groups to use. | 354 | default_groups: a string, the default manifest groups to use. |
| @@ -776,18 +776,21 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 776 | 776 | ||
| 777 | @property | 777 | @property |
| 778 | def is_submanifest(self): | 778 | def is_submanifest(self): |
| 779 | """Whether this manifest is a submanifest""" | 779 | """Whether this manifest is a submanifest. |
| 780 | |||
| 781 | This is safe to use as long as the outermost manifest XML has been parsed. | ||
| 782 | """ | ||
| 780 | return self._outer_client and self._outer_client != self | 783 | return self._outer_client and self._outer_client != self |
| 781 | 784 | ||
| 782 | @property | 785 | @property |
| 783 | def outer_client(self): | 786 | def outer_client(self): |
| 784 | """The instance of the outermost manifest client""" | 787 | """The instance of the outermost manifest client.""" |
| 785 | self._Load() | 788 | self._Load() |
| 786 | return self._outer_client | 789 | return self._outer_client |
| 787 | 790 | ||
| 788 | @property | 791 | @property |
| 789 | def all_manifests(self): | 792 | def all_manifests(self): |
| 790 | """Generator yielding all (sub)manifests.""" | 793 | """Generator yielding all (sub)manifests, in depth-first order.""" |
| 791 | self._Load() | 794 | self._Load() |
| 792 | outer = self._outer_client | 795 | outer = self._outer_client |
| 793 | yield outer | 796 | yield outer |
| @@ -796,7 +799,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 796 | 799 | ||
| 797 | @property | 800 | @property |
| 798 | def all_children(self): | 801 | def all_children(self): |
| 799 | """Generator yielding all child submanifests.""" | 802 | """Generator yielding all (present) child submanifests.""" |
| 800 | self._Load() | 803 | self._Load() |
| 801 | for child in self._submanifests.values(): | 804 | for child in self._submanifests.values(): |
| 802 | if child.repo_client: | 805 | if child.repo_client: |
| @@ -813,7 +816,14 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 813 | 816 | ||
| 814 | @property | 817 | @property |
| 815 | def all_paths(self): | 818 | def all_paths(self): |
| 816 | """All project paths for all (sub)manifests. See `paths`.""" | 819 | """All project paths for all (sub)manifests. |
| 820 | |||
| 821 | See also `paths`. | ||
| 822 | |||
| 823 | Returns: | ||
| 824 | A dictionary of {path: Project()}. `path` is relative to the outer | ||
| 825 | manifest. | ||
| 826 | """ | ||
| 817 | ret = {} | 827 | ret = {} |
| 818 | for tree in self.all_manifests: | 828 | for tree in self.all_manifests: |
| 819 | prefix = tree.path_prefix | 829 | prefix = tree.path_prefix |
| @@ -829,7 +839,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 829 | def paths(self): | 839 | def paths(self): |
| 830 | """Return all paths for this manifest. | 840 | """Return all paths for this manifest. |
| 831 | 841 | ||
| 832 | Return: | 842 | Returns: |
| 833 | A dictionary of {path: Project()}. `path` is relative to this manifest. | 843 | A dictionary of {path: Project()}. `path` is relative to this manifest. |
| 834 | """ | 844 | """ |
| 835 | self._Load() | 845 | self._Load() |
| @@ -843,11 +853,13 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 843 | 853 | ||
| 844 | @property | 854 | @property |
| 845 | def remotes(self): | 855 | def remotes(self): |
| 856 | """Return a list of remotes for this manifest.""" | ||
| 846 | self._Load() | 857 | self._Load() |
| 847 | return self._remotes | 858 | return self._remotes |
| 848 | 859 | ||
| 849 | @property | 860 | @property |
| 850 | def default(self): | 861 | def default(self): |
| 862 | """Return default values for this manifest.""" | ||
| 851 | self._Load() | 863 | self._Load() |
| 852 | return self._default | 864 | return self._default |
| 853 | 865 | ||
| @@ -1090,8 +1102,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1090 | if override: | 1102 | if override: |
| 1091 | self.manifestFile = savedManifestFile | 1103 | self.manifestFile = savedManifestFile |
| 1092 | 1104 | ||
| 1093 | # Now that we have loaded this manifest, load any submanifest manifests | 1105 | # Now that we have loaded this manifest, load any submanifests as well. |
| 1094 | # as well. We need to do this after self._loaded is set to avoid looping. | 1106 | # We need to do this after self._loaded is set to avoid looping. |
| 1095 | for name in self._submanifests: | 1107 | for name in self._submanifests: |
| 1096 | tree = self._submanifests[name] | 1108 | tree = self._submanifests[name] |
| 1097 | spec = tree.ToSubmanifestSpec() | 1109 | spec = tree.ToSubmanifestSpec() |
| @@ -1659,6 +1671,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1659 | name: a string, the name of the project. | 1671 | name: a string, the name of the project. |
| 1660 | path: a string, the path of the project. | 1672 | path: a string, the path of the project. |
| 1661 | remote: a string, the remote.name of the project. | 1673 | remote: a string, the remote.name of the project. |
| 1674 | |||
| 1675 | Returns: | ||
| 1676 | A tuple of (relpath, worktree, gitdir, objdir, use_git_worktrees) for the | ||
| 1677 | project with |name| and |path|. | ||
| 1662 | """ | 1678 | """ |
| 1663 | # The manifest entries might have trailing slashes. Normalize them to avoid | 1679 | # The manifest entries might have trailing slashes. Normalize them to avoid |
| 1664 | # unexpected filesystem behavior since we do string concatenation below. | 1680 | # unexpected filesystem behavior since we do string concatenation below. |
| @@ -1666,7 +1682,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1666 | name = name.rstrip('/') | 1682 | name = name.rstrip('/') |
| 1667 | remote = remote.rstrip('/') | 1683 | remote = remote.rstrip('/') |
| 1668 | use_git_worktrees = False | 1684 | use_git_worktrees = False |
| 1669 | use_remote_name = bool(self._outer_client._submanifests) | 1685 | use_remote_name = self.is_multimanifest |
| 1670 | relpath = path | 1686 | relpath = path |
| 1671 | if self.IsMirror: | 1687 | if self.IsMirror: |
| 1672 | worktree = None | 1688 | worktree = None |
| @@ -1696,6 +1712,9 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1696 | name: a string, the name of the project. | 1712 | name: a string, the name of the project. |
| 1697 | all_manifests: a boolean, if True, then all manifests are searched. If | 1713 | all_manifests: a boolean, if True, then all manifests are searched. If |
| 1698 | False, then only this manifest is searched. | 1714 | False, then only this manifest is searched. |
| 1715 | |||
| 1716 | Returns: | ||
| 1717 | A list of Project instances with name |name|. | ||
| 1699 | """ | 1718 | """ |
| 1700 | if all_manifests: | 1719 | if all_manifests: |
| 1701 | return list(itertools.chain.from_iterable( | 1720 | return list(itertools.chain.from_iterable( |
| @@ -1956,6 +1975,16 @@ class RepoClient(XmlManifest): | |||
| 1956 | """Manages a repo client checkout.""" | 1975 | """Manages a repo client checkout.""" |
| 1957 | 1976 | ||
| 1958 | def __init__(self, repodir, manifest_file=None, submanifest_path='', **kwargs): | 1977 | def __init__(self, repodir, manifest_file=None, submanifest_path='', **kwargs): |
| 1978 | """Initialize. | ||
| 1979 | |||
| 1980 | Args: | ||
| 1981 | repodir: Path to the .repo/ dir for holding all internal checkout state. | ||
| 1982 | It must be in the top directory of the repo client checkout. | ||
| 1983 | manifest_file: Full path to the manifest file to parse. This will usually | ||
| 1984 | be |repodir|/|MANIFEST_FILE_NAME|. | ||
| 1985 | submanifest_path: The submanifest root relative to the repo root. | ||
| 1986 | **kwargs: Additional keyword arguments, passed to XmlManifest. | ||
| 1987 | """ | ||
| 1959 | self.isGitcClient = False | 1988 | self.isGitcClient = False |
| 1960 | submanifest_path = submanifest_path or '' | 1989 | submanifest_path = submanifest_path or '' |
| 1961 | if submanifest_path: | 1990 | if submanifest_path: |
