Commit Graph

245 Commits (3edda8d185b5b46d43ea19ad3e2d1de91b6f8ba0)

Author SHA1 Message Date
Aravind Vasudevan 3edda8d185 Update gclient to use git config caching
This change updates all the modules used by gclient to use `scm.GIT` for git config calls over directly invoking the subprocess.

This change currently doesn't modify git_cache since the config reads and writes within it are done on bare repository. A follow-up CL will update git_cache.

A follow-up CL will also update git_cl and git_map_branches since they have shown performance improvements too: https://crrev.com/c/4697786.

Benchmarking
============
With chromium/src as the baseline super project, this change reduces about 380 git config calls out of 507 total calls on cache hits during no-op. The below numbers are benchmarked with `update_depot_tools` turned off.

Windows Benchmark
=================
Baseline (gpaste/6360045736951808): ~1min 12 sec.
With Caching (gpaste/6480065209040896): ~1min 3sec.
~12.5% decrease in gclient sync noop runtime.

Linux Benchmark
===============
Baseline (gpaste/4730436763254784): ~3.739 sec.
With Caching (gpaste/4849870978940928): ~3.534 sec.
~5.5% decrease in gclient sync noop runtime.

Bug: 1501984
Change-Id: Ib48df2d26a0c742a9b555a1e2ed6366221c7db17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5252498
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Gavin Mak edba22d4eb Fix multiline comment formatting
Many incorrectly formatted comments exist from the switch to
4 space indent: https://crrev.com/c/4836379

Bug: 1514505
Change-Id: I6366f9da812919bd35b999f18fa8a49b7a66c09b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5153633
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Aravind Vasudevan 259774c3ac [gclient_scm] Update _CheckClean() to use `git status`
This change updates the `_CheckClean()` fn to use `git status` instead
of `git update-index` and `git diff-index`. The `_CheckClean()` fn is
run during every update and this change reduces the subprocess calls
made by it by half.

Change-Id: Ie9a23b0bce748bec4cac88df09655569e88e4841
Bug: 1501984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5076224
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 year ago
Josip Sokcevic 4cf6518959 scm: Remove usage of distutil
The package is deprecated and will be removed in py 3.12.

R=ddoman@google.com

Bug: 1500415
Change-Id: Ia130c556ad3f2135fac4a9b1d9bb4ecc088cfe9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5030818
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Jonathan Nieder <jrn@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Commit-Queue: Jonathan Nieder <jrn@google.com>
1 year ago
Josip Sokcevic 88cc0b8ca8 Remove old Cog detection
This is no longer needed.

R=aravindvasudev@google.com

Change-Id: Ic1b2bbf0f00ca9d288c21fa1623c4ada80d59644
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5014581
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Gavin Mak f936d540e1 Remove __future__ imports
All __future__ imports (unicode_literals, print_function) are already
mandatory in py3. Also remove an outdated py2 comment in
presubmit_canned_checks.py

Bug: 1475402
Change-Id: I27cf6a8268f6dd1081f22af782c4c29a975376ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4867135
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Josip Sokcevic 3b9212b7ee [gclient_scm] Disable push recurseSubmodule
This option can lead to high `git cl upload` latency. We never want to
use this option for gclient managed repositories anyways since changes
need to go through code review.

Note: the default value is off, but it will be set to on if
`submodule.recurse` is set to true.

R=jojwang@google.com

Bug: b/299969165
Change-Id: I2173a2d96d478bf96bfe6e78ef0c5b21d4ac8015
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4874177
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Mike Frysinger 677616322a tests: switch to 4 space indent
Reformat this dir by itself to help merging with conflicts with other CLs.

Reformatted using:
parallel ./yapf -i -- tests/*.py
~/chromiumos/chromite/contrib/reflow_overlong_comments tests/*.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
tests/bot_update_coverage_test.py
tests/cipd_bootstrap_test.py
tests/gclient_eval_unittest.py
tests/gclient_git_smoketest.py
tests/gclient_scm_test.py
tests/gclient_smoketest.py
tests/gclient_test.py
tests/gclient_transitions_smoketest.py
tests/gclient_utils_test.py
tests/git_cl_test.py
tests/git_hyper_blame_test.py
tests/git_rebase_update_test.py
tests/lockfile_test.py
tests/metrics_test.py
tests/presubmit_canned_checks_test.py
tests/presubmit_unittest.py
tests/roll_dep_test.py

Change-Id: I8fed04b4ba81d54b8f45da612213aad27a9e1a2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4842592
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
2 years ago
Josip Sokcevic 1a8bf9e370 Improve error message on gclient sync failure
The new error message should clarify what we expect from user to do.

Also, git v2.42.0 introduced new advice on merge failure, which breaks
existing regex match. Instead, use search.

R=aravindvasudev@google.com

Fixed: 1475622
Change-Id: Ib4e60947aaa7994715cfae3260dd27f85f2380b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4823716
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
2 years ago
Gavin Mak 65c49b18b9 Drop py2 support in gclient and related files
python3 is the only supported version of python in depot_tools.

Bug: 1475402
Change-Id: I17174d7252b5cbf698700333d3cd561c6591d0a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809190
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Joanna Wang d9ea072747 Use diff.ignoreSubmodules=dirty.
With this, modified files from submodules won't be reported,
but new ones will and this makes things much faster than not
having diff.ignoreSubmodules set at all.

Bug: 1470194
Change-Id: I041b6fb3151c0b06cff3cc77d6735ad2ebe27f21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4793910
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
2 years ago
Joanna Wang 4e6c1071bd Unset diff.ignoreSubmodules=all when running gclient sync.
Bug: 1470195
Change-Id: I1317e5f12d6cc7fae44b2a463ddf6d0f85629759
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4767516
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
2 years ago
Josip Sokcevic 84c0bbaf04 Disable git's recurse submodule fetch
Git fetches submodules sequentially by default, which slows down gclient
sync. Instead of relying on git to fetch submodules, we can just
continue to rely on gclient to do the right thing.

R=jojwang@google.com

Bug: 1471702
Change-Id: Id0b104e76f702752bd7fecc7edac9245624bbb90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4766998
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Joanna Wang a654ff36bb Convert branch revision to remote branch in status call.
We pull the revision from the DEPS url, but if the revision is a branch,  the string must be converted into the local branch names we have for remote branches.

Bug: 1464985
Change-Id: I32c89c947319a04421c46d09d057e42043594e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4699021
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
2 years ago
Joanna Wang e1753f63df Set ignoreSubmodule=all for all repos.
Bug: 1415507

Change-Id: I840508c6972e4640793a12aba287ed8dedfe64c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4641611
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
2 years ago
Dan Le Febvre 456d085e75 Adding batch CIPD version resolution to gclient.
At the moment on repo's with many CIPD packages the number
of CLI calls to 'cipd describe' can make it very slow.

This mechanism will call cipd ensure-file-resolve with the entire
list in one call then reference items from the list before trying
individual cipd describe commands.

Bug:b/279097790
Change-Id: Ieb4bc77853357cfadb3ea6311fa0013aa7999ac6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4551125
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Dan Le Febvre <dlf@google.com>
2 years ago
Josip Sokcevic 7958e30579 Revert "Move scm.py to lib/"
This reverts commit 688adfe276.

Reason for revert: breaks try jobs

Original change's description:
> Move scm.py to lib/
>
> It belongs there.
>
> Change-Id: I286b50c43c587c39557fc508175efbd4b0f51d51
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4289680
> Reviewed-by: Joanna Wang <jojwang@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>

Change-Id: I662907b8bb4b2e7db82409bd34c3905db7961a12
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4300261
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2 years ago
Josip Sokcevic 688adfe276 Move scm.py to lib/
It belongs there.

Change-Id: I286b50c43c587c39557fc508175efbd4b0f51d51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4289680
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Joanna Wang 5a7c824fee [no-sync] Add method to check for diffs between the current checkout and another commit.
Bug: 1339472

Change-Id: If97d2fad7e5c61ec907e15a00db225b653a62bef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3738365
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
3 years ago
Joanna Wang a9467d8216 Remove duplicate sparse-checkout call.
Bug:1330629
Change-Id: Ieccf72c75dda7cbec473fcfa07d25fb59f8eb7c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3689728
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
3 years ago
Joanna Wang 1a977bdc2d Update gclient cloning to work with cog.
Bug:1330629
Change-Id: I522255528e36d4806eada70c22afee1277a6778d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3668429
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
3 years ago
Ravi Mistry c848a4ed33 Fix host and repo parsing for download-topics
Previous code was incorrectly assuming that the repo name always matched the host name.

Bug: chromium:1298922
Change-Id: Ic90ed585503d721f4d771b4f390a04c7f5b26622
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3507359
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Ravi Mistry <rmistry@chromium.org>
3 years ago
Ravi Mistry ecda782811 Reland "Reland "Add support for Gerrit topics in gclient syncs""
This is a reland of fc9a40e3c6

Hopefully the cause of the 2nd revert was fixed in https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3489327

Original change's description:
> Reland "Add support for Gerrit topics in gclient syncs"
>
> This is a reland of 0f13273f1f
>
> Hopefully the cause of the original revert was fixed in https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3480835
>
> Original change's description:
> > Add support for Gerrit topics in gclient syncs
> >
> >
> > If the new flag "--download-topics" is specified with a "--patch-ref" then:
> > * Finds the topic of the Gerrit change.
> > * Finds all open changes in the same repo as the Gerrit change.
> > * Cherrypicks all changes locally.
> >
> > This functionality can be used by developers and bots to apply all changes with the same topic in the checkout to be tested at the same time (similar to how Android's TreeHugger handles topics).
> >
> >
> > Tested by:
> >
> > * Running the new unit test with `python gclient_scm_test.py GerritChangesTest.testDownloadsTopics` from the `tests/` directory.
> >
> > * Running an end-to-end test with `DEPOT_TOOLS_UPDATE=0 gclient sync --patch-ref "skia@d831da5b8ac2d257c5b0cf2ec6645a148f05e662:refs/changes/17/505217/2" --download-topics` in a skia checkout.
> >
> >
> > Bug: chromium:1298922
> > Change-Id: Ieace5e27fbc9c5d0ea90a037bf80a95062c1b164
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3444003
> > Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> > Commit-Queue: Ravi Mistry <rmistry@chromium.org>
>
> Bug: chromium:1298922
> Change-Id: I80747d797234bba06c17ef5c5e85b310281922c4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3484976
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Ravi Mistry <rmistry@chromium.org>

Bug: chromium:1298922
Change-Id: I21d7251bafff808b1144d6e522fa9f384f4541bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3490488
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Ravi Mistry <rmistry@chromium.org>
3 years ago
Josip Sokcevic 368f980b6d Revert "Reland "Add support for Gerrit topics in gclient syncs""
This reverts commit fc9a40e3c6.

Reason for revert: at least one tryjob if failing:
Gerrit Plugins Tester

Original change's description:
> Reland "Add support for Gerrit topics in gclient syncs"
>
> This is a reland of 0f13273f1f
>
> Hopefully the cause of the original revert was fixed in https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3480835
>
> Original change's description:
> > Add support for Gerrit topics in gclient syncs
> >
> >
> > If the new flag "--download-topics" is specified with a "--patch-ref" then:
> > * Finds the topic of the Gerrit change.
> > * Finds all open changes in the same repo as the Gerrit change.
> > * Cherrypicks all changes locally.
> >
> > This functionality can be used by developers and bots to apply all changes with the same topic in the checkout to be tested at the same time (similar to how Android's TreeHugger handles topics).
> >
> >
> > Tested by:
> >
> > * Running the new unit test with `python gclient_scm_test.py GerritChangesTest.testDownloadsTopics` from the `tests/` directory.
> >
> > * Running an end-to-end test with `DEPOT_TOOLS_UPDATE=0 gclient sync --patch-ref "skia@d831da5b8ac2d257c5b0cf2ec6645a148f05e662:refs/changes/17/505217/2" --download-topics` in a skia checkout.
> >
> >
> > Bug: chromium:1298922
> > Change-Id: Ieace5e27fbc9c5d0ea90a037bf80a95062c1b164
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3444003
> > Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> > Commit-Queue: Ravi Mistry <rmistry@chromium.org>
>
> Bug: chromium:1298922
> Change-Id: I80747d797234bba06c17ef5c5e85b310281922c4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3484976
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Ravi Mistry <rmistry@chromium.org>

Bug: chromium:1298922
Change-Id: I845321941157ab55d026488b7ce59787ba5e57f2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3488245
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Ravi Mistry fc9a40e3c6 Reland "Add support for Gerrit topics in gclient syncs"
This is a reland of 0f13273f1f

Hopefully the cause of the original revert was fixed in https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3480835

Original change's description:
> Add support for Gerrit topics in gclient syncs
>
>
> If the new flag "--download-topics" is specified with a "--patch-ref" then:
> * Finds the topic of the Gerrit change.
> * Finds all open changes in the same repo as the Gerrit change.
> * Cherrypicks all changes locally.
>
> This functionality can be used by developers and bots to apply all changes with the same topic in the checkout to be tested at the same time (similar to how Android's TreeHugger handles topics).
>
>
> Tested by:
>
> * Running the new unit test with `python gclient_scm_test.py GerritChangesTest.testDownloadsTopics` from the `tests/` directory.
>
> * Running an end-to-end test with `DEPOT_TOOLS_UPDATE=0 gclient sync --patch-ref "skia@d831da5b8ac2d257c5b0cf2ec6645a148f05e662:refs/changes/17/505217/2" --download-topics` in a skia checkout.
>
>
> Bug: chromium:1298922
> Change-Id: Ieace5e27fbc9c5d0ea90a037bf80a95062c1b164
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3444003
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Ravi Mistry <rmistry@chromium.org>

Bug: chromium:1298922
Change-Id: I80747d797234bba06c17ef5c5e85b310281922c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3484976
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Ravi Mistry <rmistry@chromium.org>
3 years ago
Josip Sokcevic 63343b07f3 Revert "Add support for Gerrit topics in gclient syncs"
This reverts commit 0f13273f1f.

Reason for revert: breaks codesearch recipes and autorollers

crbug.com/1298961

Original change's description:
> Add support for Gerrit topics in gclient syncs
>
>
> If the new flag "--download-topics" is specified with a "--patch-ref" then:
> * Finds the topic of the Gerrit change.
> * Finds all open changes in the same repo as the Gerrit change.
> * Cherrypicks all changes locally.
>
> This functionality can be used by developers and bots to apply all changes with the same topic in the checkout to be tested at the same time (similar to how Android's TreeHugger handles topics).
>
>
> Tested by:
>
> * Running the new unit test with `python gclient_scm_test.py GerritChangesTest.testDownloadsTopics` from the `tests/` directory.
>
> * Running an end-to-end test with `DEPOT_TOOLS_UPDATE=0 gclient sync --patch-ref "skia@d831da5b8ac2d257c5b0cf2ec6645a148f05e662:refs/changes/17/505217/2" --download-topics` in a skia checkout.
>
>
> Bug: chromium:1298922
> Change-Id: Ieace5e27fbc9c5d0ea90a037bf80a95062c1b164
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3444003
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Ravi Mistry <rmistry@chromium.org>

Bug: chromium:1298922
Bug: chromium:1298961
Change-Id: I88c56cd68372bad09b612de7de1a45f9a0c6c681
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3474793
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Ravi Mistry 0f13273f1f Add support for Gerrit topics in gclient syncs
If the new flag "--download-topics" is specified with a "--patch-ref" then:
* Finds the topic of the Gerrit change.
* Finds all open changes in the same repo as the Gerrit change.
* Cherrypicks all changes locally.

This functionality can be used by developers and bots to apply all changes with the same topic in the checkout to be tested at the same time (similar to how Android's TreeHugger handles topics).


Tested by:

* Running the new unit test with `python gclient_scm_test.py GerritChangesTest.testDownloadsTopics` from the `tests/` directory.

* Running an end-to-end test with `DEPOT_TOOLS_UPDATE=0 gclient sync --patch-ref "skia@d831da5b8ac2d257c5b0cf2ec6645a148f05e662:refs/changes/17/505217/2" --download-topics` in a skia checkout.


Bug: chromium:1298922
Change-Id: Ieace5e27fbc9c5d0ea90a037bf80a95062c1b164
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3444003
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Ravi Mistry <rmistry@chromium.org>
3 years ago
Aravind Vasudevan c5f0cbb865 Use pylint 2.7 for depot_tools
This includes a few fixes for specific errors, and disables several new
warnings introduced in this version, in order to allow for an incremental migration.

Bug:1262286
Change-Id: I4b8f8fc521386419a3121bbb07edc8ac83170a94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3413679
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
3 years ago
Josip Sokcevic 42c5bbbc96 Revert "Use pylint 2.7 for depot_tools"
This reverts commit 22bf605bb6.

Reason for revert: breaks gclient sync

Original change's description:
> Use pylint 2.7 for depot_tools
>
> This includes a few fixes for specific errors, and disables several new
> warnings introduced in this version, in order to allow for an incremental migration.
>
> Bug:1262286
> Change-Id: Ie97d686748c9c952e87718a65f401c5f6f80a5c9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3400616
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>

Bug: 1262286
Change-Id: Ieb946073c7886c7bf056ce843a5a48e82becf7a5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3413672
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Aravind Vasudevan 22bf605bb6 Use pylint 2.7 for depot_tools
This includes a few fixes for specific errors, and disables several new
warnings introduced in this version, in order to allow for an incremental migration.

Bug:1262286
Change-Id: Ie97d686748c9c952e87718a65f401c5f6f80a5c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3400616
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
3 years ago
Josip Sokcevic 7e133ff177 Use main branch as the default branch
R=apolito@google.com

Change-Id: I6a2ed557b9e8d45194b2fe4ea5327ce62020733c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3000134
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic 091f5ac0a6 Use real default branch in gclient
Currently, gclient sync assumes the default branch is master, and
it doesn't work at all if such branch doesn't exist. This change queries
local git copy to get remote HEAD. If local git version is not
available, it queries remote git server using ls-remote.

This change requires git version 2.28 (depot_tools comes with 2.29).

R=ehmaldonado@chromium.org

Bug: 1156318
Change-Id: Id348e0f1004093f395139e8f4d62adb66b94ca9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2628359
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Ben Pastene d410c664e6 gclient: Preserve ANSI color codes when calling hooks.
If a hook prints error/warning output that's color-coded, gclient
will cause the coloring to be disabled since those hooks aren't
called directly from a terminal.

By emulating a terminal when launching subprocs from gclient, we can
convince them to keep the color escape codes.

LED builds with both //third_party/depot_tools rolled to this CL, as
well as depot_tools in the recipe bundle rolled to this CL:
linux: https://ci.chromium.org/swarming/task/4e40237985888310
mac: https://ci.chromium.org/swarming/task/4e4023ea0c829710
win: https://ci.chromium.org/swarming/task/4e4024612e03dc10

Bug: 1034063
Change-Id: I4150f66ef215ece06f4c32482dcd4ded14eb1bfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2368435
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
5 years ago
Edward Lesmes 8073a50204 gclient: Set with_branch_heads if asked to sync to refs/branch-heads/*
The bug is caused because we already have refs/branch-heads/XXXX locally,
so we don't attempt to fetch it again, even if it has been updated.

This solution is a bit of a hack to make sure that we fetch
refs/branch-heads/*, which is the most common case for this to fail.

Bug: 1070545
Change-Id: Iec7cfff18219794230188e2b9e901c587acd274b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2149849
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
5 years ago
Edward Lesmes 50da7706ce Reland "git-cl: Remove unused and duplicate functions."
This is a reland of e3a49aa405

GetRelativeRoot was fixed to use '.' instead of None

Original change's description:
> git-cl: Remove unused and duplicate functions.
>
> Remove unused functions, and use scm.GIT where possible to reduce
> duplication.
>
> Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Change-Id: I54bd1d34d3501a38bf8af2f9e70059d58fa538a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2125293
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes cba460828f Revert "git-cl: Remove unused and duplicate functions."
This reverts commit e3a49aa405.

Reason for revert:

TypeError: expected str, bytes or os.PathLike object, not NoneType

Original change's description:
> git-cl: Remove unused and duplicate functions.
> 
> Remove unused functions, and use scm.GIT where possible to reduce
> duplication.
> 
> Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com

Change-Id: I334a6289eb2c1f3e20feddd428307542d2aa38a9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2119411
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes e3a49aa405 git-cl: Remove unused and duplicate functions.
Remove unused functions, and use scm.GIT where possible to reduce
duplication.

Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur a81450253f depot_tools: Use mock from vpython (or unittest.mock) instead of third_party/mock
Change-Id: I3a188b34ae5f62649108afe08fe0e389a408c2ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1947933
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
5 years ago
Anthony Polito bb45734988 Changed "gclient sync -D" logic to compare against the expected DEPS version
Also add a better warning if 'gclient sync -D' fails due to a modified file.
I've tested this code via deleting a DEP and running gclient sync -D.

Bug: 981149
Change-Id: I97035ac238d163ccb1684c3ee423c223ed0f6299
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1891830
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Anthony Polito <apolito@google.com>
6 years ago
Robert Iannucci c39a77883d [gclient] Reset to parent commit with rebase_patch_ref=False instead of master.
This makes no-rebase-patch-ref correctly populate `file_list` and work with
`git diff --cached` (i.e. they will show only the files affected by the
patchset).

Previously gclient would `reset --soft` to master. Because we didn't rebase
on top of master with `no-rebase-patch-ref`, it has roughly nothing to do
with the patchref we just checked out.

R=gbeaty@chromium.org, ltina@google.com, tandrii@chromium.org

Context:
Tricium recipes sometimes need to use no-rebase-patch-ref in order to get
accurate linenumbers in the diff (i.e. so that the tricium comments will
actually line up correctly with the patchset the user uploaded); Tricium
recipes also need to accurately get the diff file list in this mode.
Change-Id: I5f3c95cd4958cf407a83b96c238b8c55c452ac81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1895041
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Commit-Queue: Andrii Shyshkalov <tandrii@google.com>
6 years ago
Edward Lesmes e79107e01b gclient_scm: Fix tests on windows
Change-Id: I649bee199e52ecbd66467cfaf850a7a57e2eedf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1874506
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Erik Chen e16ffffc28 Add logging to bot_update.py and gclient_scm.py
Bug: chromium:1014216
Change-Id: I620f197fe26d8817ddb51e7a30ae774439d79bdf
Recipe-Nontrivial-Roll: chromiumos
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1860854
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Auto-Submit: Erik Chen <erikchen@chromium.org>
6 years ago
Raul Tambre a79f0e50bb tests/gclient_scm_test.py: Fix invalid escape sequences in regex strings
Note that on line 504 I also fixed the test on windows by allowing \. Also properly escaped /.

Errors:
C:\Google\depot_tools\tests\gclient_scm_test.py:42: SyntaxWarning: invalid escape sequence \[
  TIMESTAMP_RE = re.compile('\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL)
C:\Google\depot_tools\tests\gclient_scm_test.py:504: SyntaxWarning: invalid escape sequence \.
  "breaking lock.*\.git/index\.lock")

Bug: 958138
Change-Id: I19ef98538a1c172d7139ca2d7097a7fbc33ebe80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1815866
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Edward Lemur a877ee62b1 depot_tools: Run some tests on Python 3 on the bots.
Bug: 984182
Change-Id: I0b7f1e3e056548a27a416c9b4078e54c9e5d60d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1769400
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
6 years ago
Edward Lemur 9f4b37db0e depot_tools: Make watchlist tests use mock and remove pymox.
Bug: 984182
Change-Id: Iaacb10dfc5ce7c624ac52edb76a9a74c6e2fd1cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1757122
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Edward Lemur 9cafbf4b35 depot_tools: Separate TestCaseUtils into its own file.
This will make it easier to get rid of super_mox.py

Bug: 984182
Change-Id: Ic6c9646b8a96ef05ac59293a62f68ad7db7dc2d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1754977
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Edward Lemur 979fa780ce depot_tools: Make gclient_scm Python 3 compatible.
Bug: 984182
Change-Id: Ib9c5d2762546f29eaca5eae89b0428431067da4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1753029
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Edward Lemur 24146be833 depot_tools: Simplify CheckCallAndFilter[AndHeader]
- Merge CheckCallAndFilter[AndHeader]
- print_stdout will cause command output to be redirected to sys.stdout.
- Made compatible with Python 3.

Bug: 984182
Change-Id: Ida30e295b872c8c1a1474a376a90aecea924f307
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1727404
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Edward Lemur 4c5c8ab626 Reland "Reland "gclient: Require a target ref when applying patches.""
This is a reland of 822dbc51a2

Skia has fixed the test.

Original change's description:
> Reland "gclient: Require a target ref when applying patches."
>
> This is a reland of 1d6478a5ff
>
> Original change's description:
> > gclient: Require a target ref when applying patches.
> >
> > Bug: 956807
> > Change-Id: Icfffe965f9f4651f22e8ba32c60133a5620bb350
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1616804
> > Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> > Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
>
> Bug: 956807
> Change-Id: I3de8475a091ce6a2a14ff7dcfb92507a205ef78c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1623594
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=tandrii@chromium.org

Bug: 956807
Change-Id: Ie273dafb921206f6346678c1861320129ad5b6fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1649695
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Edward Lesmes 42b03c3453 Revert "Reland "gclient: Require a target ref when applying patches.""
This reverts commit 822dbc51a2.

Reason for revert:
Skia autoroller is complaining
https://skia-review.googlesource.com/c/buildbot/+/219338

Original change's description:
> Reland "gclient: Require a target ref when applying patches."
> 
> This is a reland of 1d6478a5ff
> 
> Original change's description:
> > gclient: Require a target ref when applying patches.
> > 
> > Bug: 956807
> > Change-Id: Icfffe965f9f4651f22e8ba32c60133a5620bb350
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1616804
> > Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> > Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> 
> Bug: 956807
> Change-Id: I3de8475a091ce6a2a14ff7dcfb92507a205ef78c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1623594
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=borenet@chromium.org,tandrii@chromium.org,ehmaldonado@chromium.org

Change-Id: I14a70206a34f7024abc21039806f23dc7cf56bb6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 956807
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1648321
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago