summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix an issue when syncing with --use-superproject and clone bundles.Xin Li2021-06-302-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | It is possible that a clone bundle contained the object referenced by the branch in the manifest and in the superproject, but not the branch itself (for example, the branch may be newly created from an existing branch, or is not vislble to the user downloading the clone bundle). When --use-superproject is enabled, because we are overriding revisionExpr with the SHA1 revision provided by the superproject, the verification step would succeed, but because the expected branch do not exist, it would confuse git-repo at a later time, as it is expecting the remote branch to exist in the local clone. In project.py, fix this by making SetRevisionId() to always remember the actual branch name and verify it in _CheckForImmutableRevision() so that we only skip the fetch step when both objects exists locally. Bug: [google internal] b/191974277 Change-Id: I49d3ca0667f524c8c45f416492faf95b1dd822fb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310802 Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Xin Li <delphij@google.com>
* superproject - don't update the commit ids of projects that have revisionId.Raman Tenneti2021-06-291-2/+49
| | | | | | | | | | | | | | | | | | | | Pinned manifests and release manifest have revisionId set for all projects. For such projects don't update the commit ids. Tested the code with the following commands. $ ./run_tests -v $ repo_dev sync --use-superproject -j8 $ repo_dev sync -n -c -j32 -m $(pwd)/manifest_7482982.xml Bug: [google internal] b/191995372 Change-Id: I4681135b1d15f4a63527b6f0356d76ec842485d6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310582 Reviewed-by: Xin Li <delphij@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* superproject: Don't exit if superproject tag doesn't exist in manifest.v2.16Raman Tenneti2021-06-161-18/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't exit if there are missing commit ids in superproject. This change implements the following suggestion from delphij@: "we should note the event (so we know that --use-superproject but there were some errors, e.g. manifest didn't specify commit id for some reason, or if there is no superproject but --use-superproject is used), print out a message telling the use that this is not support, but continue as if --no-use-superproject was specified?" Changes: superproject: + Added git_trace2_event_log as an argument to the constructor. + Sync method returns SyncResult a NamedTuple of ++ success - True if sync of superproject is successful, or False. ++ fatal - True if caller should exit, Or False. + UpdateProjectsRevisionId returns UpdateProjectsResult a NamedTuple of ++ manifest_path - path name of the overriding manifest file instead of None ++ fatal - True if caller should exit, Or False + _GetAllProjectsCommitIds returns CommitIdsResult a NamedTuple of ++ commit_ids - a dictionary with the projects/commit ids on success, otherwise None ++ fatal - True if caller should exit, Or False + Added _SkipUpdatingProjectRevisionId a helper function to see if a project's revision id needs to be updated or not. This function is used to exclude projects from local manifest file. + Added the following error events into git_trace2_event_log ++ If superproject is missing in a manifest ++ If there are missing commit ids for projects. command.py: + Deleted unused import - platform + Added git_trace2_event_log as a member so all subcmds can log error events. main.py: + Initialized git_trace2_event_log as a member of command object. init.py: + Deleted unused import - optparse init.py: + Called sys.exit only if Sync returns exit=True sync.py: + Called sys.exit only if Superproject's UpdateProjectsRevisionId returns exit=True + Reloaded the manifest only if manifest path is returned by UpdateProjectsRevisionId. If not, fall back to the old way of doing repo sync. test_git_superproject: + Added code to verify error events are being logged. + Added a test for no superproject tag + Added test for UpdateProjectsRevisionId not updating the revision id with the commit ids. Tested the code with the following commands. + Positive test case with aosp-master. $ repo_dev init -u persistent-https://android.git.corp.google.com/platform/manifest -b master --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. Your identity is: Raman Tenneti <rtenneti@google.com> If you want to change this, please re-run 'repo init' with --config-name repo has been initialized in .../android/aosp $ repo_dev sync -j40 --use-superproject remote: Total 12 (delta 4), reused 12 (delta 4) NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. ... repo sync has finished successfully. + Negative test case without superproject tag. $ repo_dev sync -j40 --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` repo error: superproject tag is not defined in manifest: .../android/aosp/.repo/manifest.xml error: Cannot get project commit ids from manifest error: Update of revsionId from superproject has failed. Please resync with --no-use-superproject option ... Checking out: 100% (1022/1022), done in 3.589s repo sync has finished successfully. + Test for missing commit_id for a project. $ repo_dev sync -j40 --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../android/aosp/.repo/exp-superproject/925043f706ba64db713e9bf3b55987e2-superproject.git: Initial setup for superproject completed. error: please file a bug using go/repo-bug to report missing commit_ids for: ['build/blueprint'] error: Update of revsionId from superproject has failed. Please resync with --no-use-superproject option ... Checking out: 100% (1022/1022), done in 3.364s repo sync has finished successfully. $ ./run_tests -v ... ...== 164 passed in 2.87s ==... Bug: [google internal] b/189371541 Change-Id: I5ea49f87e8fa41be590fc0c914573e16c8cdfcfa Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/309162 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* repo: properly handle NoneType in Default/Remote equality checksJack Neus2021-06-111-0/+31
| | | | | | | | | | BUG=none TEST=none Change-Id: I4ccdbbc7ba4b6f6e20c6959db1b46fdb44ea2819 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308982 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Jack Neus <jackneus@google.com>
* superproject: add projects from local manifest to local::<filename> group.Raman Tenneti2021-06-101-4/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With repo sync --use-superproject, don't update the commit ids of every project that comes from local manifest. Tested the code with the following commands. $ ./run_tests -v + Test with local.xml 1. repo init --use-superproject -u persistent-https://googleplex-android.git.corp.google.com/a/platform/manifest 2. cd .repo cp -r /google/src/head/depot/google3/wireless/android/build_tools/translations/pipeline/local_manifests local_manifests cd .. local$ time repo_dev sync --use-superproject NOTICE: --use-superproject is in beta; report any issues to the address described in `repo version` .../local/.repo/exp-superproject/feb2c2847da5e274f3d530d5ab438af8-superproject.git: Initial setup for superproject completed. ... Bug: [google internal] b/189360443 Bug: [google internal] b/189139268 Bug: https://crbug.com/gerrit/14499 Change-Id: Ideaf268c294e9b500b2b9726ffbd733dd8d63004 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308822 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* trace2_event_log: Added logging of error events.Raman Tenneti2021-06-091-0/+24
| | | | | | | | | | | | | | | Added error event in preperation for superproject to log errors. Testing: + Unit tests ./run_tests -v Bug: [google internal] b/189371541 Change-Id: Ife1dd28d52d9e9925b7b34ae913f8eb5fa19037c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308863 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Xin Li <delphij@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* superproject: revert not updating commit ids if remote is different.Raman Tenneti2021-06-081-45/+0
| | | | | | | | | | | | | | superproject supports multiple remotes. Get all commit ids from superproject for all projects that are in the manifest. $ ./run_tests -v Bug: [google internal] b/186395810 Change-Id: I6edce3918853a7a3a65aec5528e6a43a544eff53 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308862 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* tests: Make the tests pass for Python < 3.8Peter Kjellerstedt2021-05-262-28/+55
| | | | | | | | | | | | | | Before Python 3.8, xml.dom.minidom sorted the attributes of an element when writing it to a file, while later versions output the attributes in the order they were created. Avoid these differences by sorting the attributes for each element before comparing the generated manifests with the expected ones. Bug: https://crbug.com/gerrit/14382 Change-Id: Ie2597727afcc48f9063a7261ad970e8a549f0587 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303326 Reviewed-by: Mike Frysinger <vapier@google.com>
* superproject: Use bugurl from contactinfo in the missing commits error message.v2.15.1Raman Tenneti2021-05-181-1/+1
| | | | | | | | | | | | | | | | | | + In XmlManifest._Unload set 'bugurl' to Wrapper().BUG_URL. + contactinfo returns a namedtuple. + bug_url can be accessed as self._manifest.contactinfo.bugurl. Tested the code with the following commands. $ ./run_tests -v Added contactinfo tag to default.xml and verified that bugurl is used. Bug: [google internal] b/186220520. Change-Id: Iaafd6465e072b2e47a0a0b548bf6cb608a0b0a04 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/306342 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* ssh: rewrite proxy management for multiprocessing usagev2.15Mike Frysinger2021-05-101-4/+26
| | | | | | | | | | | | | | | | We changed sync to use multiprocessing for parallel work. This broke the ssh proxy code as it's all based on threads. Rewrite the logic to be multiprocessing safe. Now instead of the module acting as a stateful object, callers have to instantiate a new ProxyManager class that holds all the state, an pass that down to any users. Bug: https://crbug.com/gerrit/12389 Change-Id: I4b1af116f7306b91e825d3c56fb4274c9b033562 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305486 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
* ssh: move all ssh logic to a common placeMike Frysinger2021-05-062-32/+52
| | | | | | | | | | | | We had ssh logic sprinkled between two git modules, and neither was quite the right home for it. This largely moves the logic as-is to its new home. We'll leave major refactoring to followup commits. Bug: https://crbug.com/gerrit/12389 Change-Id: I300a8f7dba74f2bd132232a5eb1e856a8490e0e9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305483 Reviewed-by: Chris Mcdonald <cjmcdonald@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* git_command: switch version caches to functoolsMike Frysinger2021-05-061-2/+7
| | | | | | | | | Simplifies the code a bit to use the stdlib cache helper. Change-Id: I778e90100ce748a71cc3a5a5d67dda403334315e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305482 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* manifest_xml: cleanup of contactinfo test for readability with f-strings.Raman Tenneti2021-05-051-1/+3
| | | | | | | | | | | | Tested the code with the following commands. $ ./run_tests -v Bug: [google internal] b/186220520. Change-Id: I1c0f8958ff4c615707eec218250e8de753ec6562 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305282 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* manifest_xml: initial support for <contactinfo>Raman Tenneti2021-05-041-21/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | It will be used to let manifest authors self-register contact info. This element can be repeated, and any later entries will clobber earlier ones. This would allow manifest authors who extend manifests to specify their own contact info. It would have 1 required attribute: bugurl. "bugurl" specifies the URL to file a bug against the manifest owner. <contactinfo bugurl="bug-url"/> TODO: This CL only implements the parsing logic and further work will be in followup CLs. Tested the code with the following commands. $ ./run_tests tests/test_manifest_xml.py $ ./run_tests -v Bug: [google internal] b/186220520. Change-Id: I47e765ba2dab5cdf850191129f4d4cd6b803f451 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305203 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* subcmds: force consistent help text formatMike Frysinger2021-05-041-0/+30
| | | | | | | | | | | | We're inconsistent with help text as to whether it uses title case and whether it ends in a period. Add a test to enforce a standard, and use the style that Python optparse & argparse use themselves (e.g. with the --help option): always lowercase, and never trailing period. Change-Id: Ic1defae23daeac0ac9116aaf487427f50b34050d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305144 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* superproject: Don't update the commit ids of projects if remote is different.Raman Tenneti2021-05-031-13/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | 1) Skip setting the revision id (commit id) for the projects whose remote doesn't match superproject's remote. 2) exp-superproject/superproject_override.xml includes local_manfiest's projects. When we load this XML, don't reload projects from local.xml (otherwise we will get duplicate projects errors). Tested the code with the following commands. $ ./run_tests -v + Test with local.xml $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --use-superproject --partial-clone --clone-filter=blob:limit=10M && mkdir -p .repo/local_manifests && (gcertstatus -quiet=true || gcert) && ln -s /google/src/head/depot/google3/wireless/android/build_tools/aosp/manifests/mirror-aosp-master-with-vendor/local.xml .repo/local_manifests/local.xml $ repo_dev sync -c -j8 + Test without local.xml $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject $ repo_dev sync -c -j8 Bug: [google internal] b/186395810 Change-Id: I4e9d4ac2d94a9fc0cef0ccd787b6310758009e86 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304882 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_xml: ban use of newlines in pathsMike Frysinger2021-04-301-0/+16
| | | | | | | | | | | | There should be no valid use of these anywhere, so just ban them to make things easier for people. Bug: https://crbug.com/gerrit/14156 Bug: https://crbug.com/gerrit/14200 Change-Id: I8d2cf988c510c98194c43a329a2b9bf313a3f0a8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304662 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* tests: Make ReviewableBranchTests.test_smoke work with git < 2.28.0Peter Kjellerstedt2021-04-141-1/+1
| | | | | | | | Bug: https://crbug.com/gerrit/14380 Change-Id: Id015bd98b008e1530ada2c7e4332c67e8e208e25 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303325 Reviewed-by: Mike Frysinger <vapier@google.com>
* repo: Add a new "command" event type to git trace2 logging in repo.Raman Tenneti2021-03-181-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new "event": "command", which is emitted at when all command arguments have been processed. Additional fields: "name": Name of the primary command (ex: repo, git) "subcommands"': List of the sub-commands once command-line arguments are processed Examples: Command: repo --version Event: {"event": "command", <common fields>, "name": "repo", "subcommands": ["version"] } Bug: [google internal] b/178507266 Testing: - Unit tests - Verified repo git trace2 logs had expected data Change-Id: I825bd0ecedee45135382461a4ba10f987f09aef3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/300343 Reviewed-by: Ian Kasprzak <iankaz@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* manifest: allow toplevel project checkoutsv2.13.5Mike Frysinger2021-03-121-2/+28
| | | | | | | | | | | | | | Re-allow checking out projects to the top of the repo client checkout. We add checks to prevent checking out files under .repo/ as that path is only managed by us, and projects cannot inject content or settings into it. Bug: https://crbug.com/gerrit/14156 Bug: https://crbug.com/gerrit/14200 Change-Id: Id6bf9e882f5be748442b2c35bbeaee3549410b25 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299623 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* superproject: pass groups to ToXml method.Raman Tenneti2021-03-112-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added the following methods to XmlManifest class. + GetDefaultGroupsStr() - return 'default,platform-' + platform.system().lower() + GetGroupsStr() - Same as gitc_utils.py's _manifest_groups func. + Replaced gitc_utils.py's_manifest_groups calls with GetGroupsStr. + Used the above methods to get groups in command.py::GetProjects and part of init.py. TODO: clean up these funcs to take structured group data more instead of passing strings around everywhere that need parsing. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL and verified prebuilts/fullsdk-linux directory has all the folders. Tested repo init and repo sync with --use-superproject and without --use-superproject argument. $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b androidx-main --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject $ repo_dev sync -c -j32 Bug: [google internal] b/181804931 Bug: https://crbug.com/gerrit/13707 Change-Id: Ia98585cbfa3a1449710655af55d56241794242b6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299422 Reviewed-by: Jonathan Nieder <jrn@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* Log repo.* config variables in git trace2 logger.Ian Kasprzak2021-03-081-0/+49
| | | | | | | | | | | | | Bug: [google internal] b/181758736 Testing: - Unit tests - Verified repo git trace2 logs had expected data Change-Id: I9af8a574377bd91115f085808c1271e9dee16a36 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299182 Tested-by: Ian Kasprzak <iankaz@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com>
* tests: fix duplicate method from copy & paste errorMike Frysinger2021-03-041-2/+2
| | | | | | | | | Change-Id: Ib748c61b1e65aee6dff8b97a9753d14c470a827f Reported-by: Daniel Kutik <daniel.kutik@lavawerk.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299002 Reviewed-by: Daniel Kutik <daniel.kutik@lavawerk.com> Reviewed-by: Ian Kasprzak <iankaz@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* manifest: relax include name rules for user-specified pathv2.13.1Mike Frysinger2021-03-021-2/+30
| | | | | | | | | | | | | Allow the user to specify relative or absolute or any other funky path that they want when using `repo init` or `repo sync`. Our goal is to restrict the paths in the remote manifest git repo we cloned from the network, not protect the user from themselves. Bug: https://crbug.com/gerrit/14156 Change-Id: I1ccfb2a6bd1dce2bd765e261bef0bbf0f8a9beb6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298823 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* manifest: validate project name & path and include name attributesMike Frysinger2021-02-281-71/+159
| | | | | | | | | | | These attribute values are used to construct local filesystem paths, so apply the existing filesystem checks to them. Bug: https://crbug.com/gerrit/14156 Change-Id: Ibcceecd60fa74f0eb97cd9ed1a9792e139534ed4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298443 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* manifest: refactor the filesystem checking logic for more reuseMike Frysinger2021-02-281-0/+2
| | | | | | | | | | | | | | | | | | | | | This function is currently written with copyfile & linkfile in mind. Generalize the logic & function arguments slightly so we can reuse in more places that make sense. This changes the validation logic slightly too in that we no longer allow "." for the dest attribute with copyfile & linkfile, nor for the src attribute with copyfile. We already rejected those later on when checking against the active filesystem, but now we reject them a little sooner when parsing. The empty path check isn't a new requirement exactly -- repo used to crash on it, so it was effectively blocked, but now we diagnosis it. Bug: https://crbug.com/gerrit/14156 Change-Id: I0fdb42a3da60ed149ff1997c5dd4b85da70eec3d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298442 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* sync: superproject - support for switching hosts and switching branches.Raman Tenneti2021-02-251-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | + superproject will be fetched into a directory with the name “<remote name>-superproject.git” instead of the current “superproject.git” folder. + Deleted _Clone method and added _Init method. + _Init method will do “git init --bare <remote>-superproject.git”. It will create the folder and set up a bare repository in <remote>-superproject.git folder. + _Fetch method, will pass <remote url>, <branch> arguments. Moved the --filter argument from “git clone” to “git fetch”. _Fetch method will execute the following command to fetch superproject. Added --no-tags argument. master: git fetch <remote url> --force --no-tags --filter blob:none branch: git fetch <remote url> --force --no-tags --filter blob:none \ <branch>:<branch> + Performance improvements for aosp-master ++ repo init performance improved from 35 seconds to 17 seconds. ++ repo init --use-superproject is around 5 to 7 secsonds slower. ++ repo sync --use-superproject is around 3 to 4 minutes faster. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ time repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject ... real 0m20.648s user 0m8.046s sys 0m3.271s + Without superproject $ time repo init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main real 0m13.078s user 0m9.783s sys 0m2.528s $ time repo_dev sync -c -j32 --use-superproject ... real 15m7.072s user 110m7.216s sys 20m17.559s + Without superproject $ time repo sync -c -j32 ... real 19m25.644s user 91m56.331s sys 20m59.170s Bug: [google internal] b/180492484 Bug: [google internal] b/179470886 Bug: [google internal] b/180124069 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Change-Id: Ib04bd7f1e25ceb75532643e58ad0129300ba3299 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297702 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* tests: fix init subcmd after url changeMike Frysinger2021-02-251-1/+1
| | | | | | | | | | My recent 401c6f072564966437a74dc2f33280a85d79dc84 ("init: make --manifest-url flag optional") commit broke the unittest. Change-Id: I19ad0e8c8cbb84ab5474ebc370e00acfe957e136 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298223 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* tests: refactor manifest testsMike Frysinger2021-02-251-90/+98
| | | | | | | | | | | The XmlManifestTests class is getting to be large and we're only adding more to it. Factor out the core logic into a new TestCase so we can reuse it to better group more tests. Change-Id: I5113444a4649a70ecfa8d83d3305959a953693f7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298222 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* error: fix pickling of all exceptionsMike Frysinger2021-02-191-0/+53
| | | | | | | | | | | | | | Make sure all our custom exceptions can be pickled so that if they get thrown in a multiprocess subprocess, we don't crash & hang due to multiprocessing being unable to pickle+unpickle the exception. Details/examples can be seen in Python reports like: https://bugs.python.org/issue13751 Change-Id: Iddf14d3952ad4e2867cfc71891d6b6559130df4b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297382 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* init: added --use-superproject option to clone superproject.v2.12.2Raman Tenneti2021-02-111-51/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added --no-use-superproject to repo and init.py to disable use of manifest superprojects. Replaced the term "sha" with "commit id". Added _GetBranch method to Superproject object. Moved shared code between init and sync into SyncSuperproject function. This function either does git clone or git fetch. If git fetch fails it does git clone. Changed Superproject constructor to accept manifest, repodir and branch to avoid passing them to multiple functions as argument. Changed functions that were raising exceptions to return either True or False. Saved the --use-superproject option in config as repo.superproject. Updated internal-fs-layout.md document. Updated the tests to work with the new API changes in Superproject. Performance for the first time sync has improved from 20 minutes to around 15 minutes. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ repo init took around 20 seconds longer because of cloning of superproject. $ time repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject ... real 0m35.919s user 0m21.947s sys 0m8.977s First run $ time repo sync --use-superproject ... real 16m41.982s user 100m6.916s sys 19m18.753s No difference in repo sync time after the first run. Bug: [google internal] b/179090734 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Change-Id: I12df92112f46e001dfbc6f12cd633c3a15cf924b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296382 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* git_config: add SetBoolean helperMike Frysinger2021-02-111-3/+67
| | | | | | | | | A little sugar simplifies the code a bit. Change-Id: Ie2b8a965faa9f9ca05c7be479d03e8e073cd816d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296522 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* sync: pass --bare option when doing git clone of superproject.v2.12.1Raman Tenneti2021-02-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Changed "git pull" to "git fetch" as we are using --bare option. Used the following command to fetch: git fetch origin +refs/heads/*:refs/heads/* --prune Pass --branch argument to Superproject's UpdateProjectsRevisionId function. Returned False/None when directories don't exist instead of raise GitError exception from _Fetch and _LsTree functions. The caller of Fetch does Clone if Fetch fails. Tested the code with the following commands. $ ./run_tests -v Tested the init and sync code by copying all the repo changes into my Android AOSP checkout and running repo sync with --use-superproject option. Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I3e441ecdfc87c735f46eff0eb98efa63cc2eb22a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296222 Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: superproject performance changes.Raman Tenneti2021-02-071-7/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After updating all project’s revsionIds with the SHAs from superproject, write the updated manifest into superproject_override.xml file. Reload that file for future Reloads. This file is created in exp-superproject directory. Moved most of the code that is superproject specific into git_superproject.py and wrote test code. If git pull fails, did a git clone of the superproject. We saw performance gains for consecutive repo sync's. The time to sync went down from around 120 secs to 40 secs when repo sync is executed consecutively. Tested the code with the following commands. $ ./run_tests -v tests/test_git_superproject.py $ ./run_tests -v Tested the sync code by copying all the repo changes into my Android AOSP checkout and doing a repo sync --use-superproject twice. First run $ time repo sync --use-superproject ... real 21m3.745s user 97m59.380s sys 19m11.286s After two consecutive sync runs $ time repo sync -c -j8 --use-superproject real 0m39.626s user 0m29.937s sys 0m38.155s Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: Id79a0d7c4d20babd65e9bd485196c6f8fbe9de5e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296082 Reviewed-by: Ian Kasprzak <iankaz@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* manifest: set revisionId as revision attribute it it is not being set in ToXml.Raman Tenneti2021-02-071-0/+20
| | | | | | | | | | | | | | | | | As we were testing superproject setting revisionId attribute to SHA and reloading the manifest, we found out revisionId attribute is not being saved. Made the change to save the revisionId if it is not being saved. Tested the code with the following commands. $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I95fdf655b19648ad3e9aba10b9bed8bb9439deb6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296182 Reviewed-by: Ian Kasprzak <iankaz@google.com>
* sync: Do a git pull with --use-superproject if superproject tree already exists.Raman Tenneti2021-02-011-0/+7
| | | | | | | | | | | | | | | | | Tested the code with the following commands. $ ./run_tests -v tests/test_git_superproject.py $ ./run_tests -v Tested the sync code by copying all the repo changes into my Android AOSP checkout and doing a repo sync --use-superproject twice. .../WORKING_DIRECTORY$ repo sync --use-superproject Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I7e4b1e51ca1d18b836a5fa8d139a0765262ba500
* sync: Added --use-superproject option and support for superproject.v2.12Raman Tenneti2021-01-212-6/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added "--use-superporject" option to sync.py to fetch project SHAs from superproject. If there are any missing projects in superprojects, it prints the missing entries and exits. If there are no missing entries, it will use SHAs from superproject to fetch the projects from git. Tested the code with the following commands. $ ./run_tests tests/test_manifest_xml.py $ ./run_tests -v tests/test_git_superproject.py $ ./run_tests -v Tested the sync code by copying all the repo changes into my Android AOSP checkout and adding <superporject> tag to default.xml. With local modification to the code to print the status, .../WORKING_DIRECTORY$ repo sync --use-superproject repo: executing 'git clone' url: sso://android/platform/superproject repo: executing 'git ls-tree' Success: [] Bug: https://crbug.com/gerrit/13709 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: Id18665992428dd684c04b0e0b3a52f46316873a0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293822 Reviewed-by: Mike Frysinger <vapier@google.com>
* Update "evt" field to be logged as a string type.Ian Kasprzak2021-01-191-0/+2
| | | | | | | | | | | | Testing: - Unit tests - Verified git trace log has "evt": "2" (vs "evt": 2 previously) Bug: https://crbug.com/gerrit/13966 Change-Id: I2e0c98dda0cccdd5cb6328105c11b93cd42676eb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/294123 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Ian Kasprzak <iankaz@google.com>
* launcher: add a requirements framework to declare version dependenciesMike Frysinger2021-01-191-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we don't have a way for the checked out repo version to declare the version of tools it needs before we start running it. For somethings, like git, it's not a big deal as it can handle all the asserts itself. But for things like Python, it's impossible to reliably check before executing. We're in this state now: - we've been allowing Python 3.4, so the launcher accepts it - the repo codebase starts using Python 3.6 features - launcher tries to import us but hits syntax errors - user is left confused and assuming new repo is broken because they're seeing syntax errors This scenario is playing out with old launchers that still accept Python 2, and will continue to play out as time goes on and we want to require newer versions of Python 3. Lets create a JSON file to declare all these system requirements. That file format is extremely stable, so loading & parsing from even ancient versions of Python shouldn't be a problem. Then the launcher can read these settings and check the system state before attempting to execute any code. If the tools are too old, it can clearly diagnose & display information to the user as to the real problem (and not emit tracebacks or syntax errors). We have a couple of different tool version checks already (git, python, ssh) and can harmonize them in a single place. This also allows us to assert a reverse dependency if the need ever comes up: force the user to upgrade their `repo` launcher before we'll let them run us. Even though the launcher warns whenever a newer release is available, some users seem to ignore that, or they don't use repo that often (on the scale of years), and their upgrade jump is so dramatic that they fall back into the syntax error pit. Hopefully by the end of the year we can assume enough people have upgraded their launcher such that we can delete all of the duplicate version checks in the codebase. But until then, we'll keep them to maintain coverage. Change-Id: I5c12bbffdfd0a8ce978f39aa7f4674026fe9f4f8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293003 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* manifest_xml: - Added doc and testing of unknown tags/elements.Raman Tenneti2021-01-121-0/+21
| | | | | | | | | | | | | | | | Added this test to verify that older versions of repo can handle "<superproject" element. Tested by adding "<iankaz" unknown element. Tested the code with the following commands. $ ./run_tests tests/test_manifest_xml.py $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I858d56f38cefcfcd14474efdd631a5a940c3ce47 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293482 Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_xml: initial support for <superproject>Raman Tenneti2021-01-081-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | At most one superproject may be specified. It will be used to specify the URL of superproject. It would have 3 attributes: remote, name, and default. Only "name" is required while the others have reasonable defaults. <remote name="superproject-url" review="<url>" /> <superproject remote="superproject-url" name="platform/superproject"/> TODO: This CL only implements the parsing logic and further work will be in followup CLs. Tested the code with the following commands. $ ./run_tests tests/test_manifest_xml.py $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I5b4bba02c8b59601c754cf6b5e4d07a1e16ce167 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292982 Reviewed-by: Mike Frysinger <vapier@google.com>
* Fix bug in git trace2 event Write() function when no config present.Ian Kasprzak2021-01-071-6/+23
| | | | | | | | | | | | | | | | | | See https://bugs.chromium.org/p/gerrit/issues/detail?id=13706#c9 Added additional unit tests for Write() for additional test coverage. Testing: - Unit tests - Verified repo works with: - Valid trace2.eventtarget - Invalid trace2.eventtarget Bug: https://crbug.com/gerrit/13706 Tested-by: Ian Kasprzak <iankaz@google.com> Change-Id: I6b027cb2399bd03e453a132ad82e022a1f48476e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292762 Reviewed-by: Mike Frysinger <vapier@google.com>
* drop pyversion & is_python3 checkingMike Frysinger2021-01-061-12/+2
| | | | | | | | | | | We're committed to Python 3 at this point, so purge all the is_python3 related dynamic checks. Bug: https://crbug.com/gerrit/10418 Change-Id: I4c8b405d6de359b8b83223c9f4b9c8ffa18ea1a2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292383 Reviewed-by: Chris Mcdonald <cjmcdonald@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* strip python2-only coding:utf-8 & print_function settingsMike Frysinger2021-01-067-29/+0
| | | | | | | | | | We're committed to Python 3 at this point, so clean up boilerplate. Bug: https://crbug.com/gerrit/10418 Change-Id: Ib1719ba2eb65c53b94881a1a1bf203ddfcaaafed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292382 Reviewed-by: Chris Mcdonald <cjmcdonald@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* launcher: add test for version requirementsv2.11Mike Frysinger2021-01-061-0/+11
| | | | | | | | | | | Make sure the modules stay in sync in case one is updated but we forgot to update the other. Bug: https://crbug.com/gerrit/13795 Change-Id: I6de9533d45c083e5f7ad792ee6d541e23647de3f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292444 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Enable git trace2 event format logging.Ian Kasprzak2021-01-061-0/+169
| | | | | | | | | | | | | | | | | | | | | Ways to enable logging: 1) Set git's trace2.eventtarget config variable to desired logging path 2) Specify path via --git_trace2_event_log option A unique logfile name is generated per repo execution (based on the repo session-id). Testing: 1) Verified git config 'trace2.eventtarget' and flag enable logging. 2) Verified version/start/end events are expected format: https://git-scm.com/docs/api-trace2#_event_format 3) Unit tests Bug: https://crbug.com/gerrit/13706 Change-Id: I335eba68124055321c4149979bec36ac16ef81eb Tested-by: Ian Kasprzak <iankaz@google.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292262 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
* manifest_xml: harmonize list fieldsMike Frysinger2020-12-041-0/+13
| | | | | | | | | | | | | | | We allow project.groups to be whitespace or comma delimited, but repo-hooks.enabled-list is only whitespace delimited. This hasn't been a big deal as it's only ever had one valid value, but if we want to add more, we should harmonize these a bit. Refactor the groups method to be more generic, and run the enabled- list attribute through it. Then add missing docs for it. Change-Id: Iaa96a0faa9c4a68b313b49336751831b73bf855d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/290743 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Fix tests after "use new main branch"Fredrik de Groot2020-12-032-2/+28
| | | | | | | | | | | | | | | | | | Tests worked fine if init.defaultBranch main was used, but failed due to git branch reasons if master was still used. Since we can only use init.defaultBranch if git version >= 2.28, I also went with a template dir HEAD main tweak if lower so tests now pass regardless of client git default branch and version. Test: Ran tests with ~/.gitconfig:init.defaultBranch=master Test: Ran tests with ~/.gitconfig:init.defaultBranch=main Test: Ran tests for both code branches of git require Change-Id: I49fa1e4ae45b8aec16a093132ee9fa466cbc11ec Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/290404 Tested-by: Fredrik de Groot <fredrik.de.groot@volvocars.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest: add support for groups in includev2.10Fredrik de Groot2020-11-261-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | Attrib groups can now be added to manifest include, thus all projects in an included manifest file can easily be tagged with a group without modifying all projects in that manifest file. Include groups will add and recurse, meaning included manifest projects will carry all parent includes. Intentionally, no support added for group remove, to keep complexity down. Group handling for projects is untouched, meaning a group set on a project will still append to whatever was or was not inherited in parent manifest includes, resulting in union of groups inherited and set for the project itself. Test: manual multi-level manifest include structure, in serial and parallel, with different groups set on init Test: added unit tests to cover the inheritance Change-Id: Id2229aa6fd78d355ba598cc15c701b2ee71e5c6f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/283587 Tested-by: Fredrik de Groot <fredrik.de.groot@volvocars.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_xml: refactor manifest parsing from client managementMike Frysinger2020-11-181-0/+89
| | | | | | | | | | | | | | We conflate the manifest & parsing logic with the management of the repo client checkout in a single class. This makes testing just one part (the manifest parsing) hard as it requires a full checkout too. Start splitting the two apart into separate classes to make it easy to reason about & test. Change-Id: Iaf897c93db9c724baba6044bfe7a589c024523b2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/288682 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>