Commit Graph

112 Commits (5f6542c176c1c46ca661885b7c9871206c31760a)

Author SHA1 Message Date
Allen Li 7a9aca3708 [git_common] Fix memoize_one type check
pyright doesn't like assigning random functions to function
attributes, as you might imagine.

The new implementation is much cleaner if I say so myself.

The memoize tests also pass FWIW.

Change-Id: Ie37b14f48004b81270c08b4d073c323b8b4ebd54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5762788
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
7 months ago
Allen Li 4c050c6f1a [git_common] Use kwarg syntax for memoize_one
Change-Id: I764670c1a0d90e94e437472d6bc7a8ce1d0a11cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5762198
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Allen Li cdf5599e67 [git_common] Fix all type checking errors
Bug: b/351071334
Change-Id: I130300bebd25a62a14ea10202ea9d369f825ed50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5757941
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Allen Li 0cb94fcfa9 [git_common] Add type annotations
Bug: b/351071334
Change-Id: I876db267bdd8d876a22d4582bd6505705d1c38ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754254
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Allen Li 9173d3dc80 [git_common] Add type annotations
Bug: b/351071334
Change-Id: Ic3166ccdd54f4730b732aa0407da3a77ced4d3a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5744593
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Scott Lee 1c81122f69 [depot_tools] retry git config if it lock-fails
If git config set is executed, it writes the new content into
a temp file (but called lock-file) and then replace .gitconfig
with it.

However, if it cannot create the lock file, it returns an error.
With this CL, if git config fails with the lock file error,
depot_tools will retry it at most 5 times with 0.2s interval.

It's found that there are applications, such as vscode extensions,
executes `git config set` frequently, and those could often cause
unexpected interruptions to ongoing `git rebase-updates`
by the lock failure.

Bug: 351950514
Change-Id: I985af0d8b7458dbf47cd6baa857dc5adccf15031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5705561
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
8 months ago
Allen Li 6355da7032 [git_common] Relocate comment
Change-Id: I489df67dae5607acc4edbb0243b149eae1742733
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5641088
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 months ago
Bruce Dawson 09c232e7c0 Resolve git.bat to git.exe without using shell=True
In order for git to be run on Windows and ultimately run git.exe it is
normally necessary to pass shell=True to Popen or else invoke git.bat,
or both. However this means invoking cmd.exe every time we want to
invoke git.exe, which can end up being over 1,500 invocations of cmd.exe
when running the "update" stage of gclient sync. This makes the "update"
stage take about 1.45x as long to run - it's a significant overhead.
Even with optimizations to the update stage of gclient sync in the NOP
case this repeated invocation of cmd.exe still costs about 0.8 s of a
4.9 s "update" stage.

This change teaches git_common how to find git.exe instead of just
git.bat by parsing the .exe name out of the .bat file.

Bug: 332982922
Change-Id: I4e052444276d55c0496144b9816fe365a95a56d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5462405
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
9 months ago
Aravind Vasudevan 9f9bab25da Reland "Update gclient to use git config caching"
This reverts commit 3569608028.

Reason for revert: This includes a fix for crbug.com/324358728.

The rebase-update command has logic which tries to specifically set a key to an empty string and this has been intentionally set this way[1]. The new SetConfig implementation does treats empty string as None and hence tries to unset the config, resulting in error code 5. The patchset 2 fixes this bug and adds a test to ensure SetConfig can set an empty string to be backward compatible.

[1] https://codereview.chromium.org/228353003

Original change's description:
> Revert "Update gclient to use git config caching"
>
> This reverts commit 3edda8d185.
>
> Reason for revert: Breaks rebase-update; crbug.com/324358728
>
> Original change's description:
> > 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>
>
> Bug: 1501984
> Change-Id: I4a603238d9ed43edafc8e574493800670520a1d9
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5279198
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>

Bug: 1501984
Change-Id: I405abc16c2ef6f0689031c82c61af71aad302122
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5280779
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Aravind Vasudevan 3569608028 Revert "Update gclient to use git config caching"
This reverts commit 3edda8d185.

Reason for revert: Breaks rebase-update; crbug.com/324358728

Original change's description:
> 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>

Bug: 1501984
Change-Id: I4a603238d9ed43edafc8e574493800670520a1d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5279198
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
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
Josip Sokcevic 6c1a07d48a [git_number] Improve error message on parse_commitrefs
We are observing "binascii.Error: Non-hexadecimal digit found" on LUCI,
but it's not reproducible on local env.

This change also triggers the recipe roller.

R=gavinmak@google.com

Bug: 1514645
Change-Id: I4b97c4593b117d145f8304069d569607033babbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5160257
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
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
Joey Arhar 0e40b92d9e Don't try squashing only one commit
This patch makes git rebase-update only try squashing when rebasing
fails if there is more than one commit present in the branch it is
rebasing.

Squashing adds an extra step for the user when rebasing fails, and when
there is only one commit, squashing is guaranteed not to help.

Fixed: 1434450
Change-Id: I1952c1172dbf6a44060ed2da2d79ec07d67893d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5068315
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Helmut Januschka 6444de14d1 fix crash in case HEAD exists as a file
Bug: 1428373
Change-Id: If9d988d542345dbfa0e02f7c3d6f935b48372df4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5018937
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Helmut Januschka <helmut@januschka.com>
1 year ago
Thiago Perrotta 32e7363c50 git: tweak fsmonitor warning message to mention the git version fix
R=avi@chromium.org, sokcevic@chromium.org

Bug: 1475405
Change-Id: Iaa29a2993871837352eb9d02d368102a212edf49
Follow-up-of: https://crrev.com/c/4892305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4911838
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Thiago Perrotta <tperrotta@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Josip Sokcevic d95084e851 Adjust fsmonitor alert for Mac
Version 2.43 contains a fix for fsmonitor. Google managed git already
contains the fix.

R=aravindvasudev

Fixed: 1475405
Change-Id: I388b1e14e070595b8b0c6bca046dd3af2248a0ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4892305
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Josip Sokcevic 4a4428445d Fix squash_current_branch on dirty submodules
If there are dirty submodules, git commit -a will commit those which is
not desired. Turns out we don't need to use -a, since reset --soft
stages all changes anyways and we can just use git commit. Note that
there is a check prior to commit to ensure we are not creating an empty
commit.

R=jojwang

Fixed: 1478668
Change-Id: Iaa1ff8e638b7431511e6e194ad59e3c4adb39deb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4858836
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
1 year ago
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Aravind Vasudevan ce60c47f5d Restrict fsmonitor warning to MacOS
R=sokcevic

Change-Id: Ie1aea3764b7e90ae0337c4a223ca6cba3ff1b499
Bug: 1475405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4833351
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
2 years ago
Aravind Vasudevan c71efb5d73 Fix git freeze command
When a repo has both staged and unstaged changes for a same file, `git
freeze` doesn't work as intended. It freezes only the indexed changes
and has to be run twice to achieve the intended results. This change
fixes this case.

Change-Id: Ie620a111c4a6f721bf6c85200cb05676022041a1
Bug: 1476516
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4820460
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
2 years ago
Aravind Vasudevan c38ebeafb0 Fix fsmonitor warning to not include global
The chromium build instructions for MacOS includes enabling `fsmonitor`
within the repository. With our warning message suggesting to disable it
globally, the fsmonitor still stays enabled within the repo. This CL
fixes this by disabling `fsmonitor` within the repository.

Change-Id: If261af8bc0d0a89bc193c178c8d5b5f80125d7b7
Fixed: 1476695
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4823891
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Gavin Mak cc97655889 Reland "Drop py2 support in gerrit and git related files"
This is a reland of commit b5c7f4b46c

Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 1475402
Change-Id: I194180494071777b7b9dd91a5c8edabbbf5484c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811218
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Aravind Vasudevan b8164180d2 Warn when fsmonitor is enabled and git submodules are used
Change-Id: I181bf180f762282d5b4bc614d12a91125f56e063
Bug: 1475405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4814429
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Gavin Mak 42674f5d2d Revert "Drop py2 support in gerrit and git related files"
This reverts commit b5c7f4b46c.

Reason for revert: missing a replace for urlparse.urlparse

Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 1475402
Change-Id: Idd00fdfe0b3d62785da2789a7dfcc9fbc79b6385
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811623
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Gavin Mak b5c7f4b46c Drop py2 support in gerrit and git related files
python3 is the only supported version of python in depot_tools.

Bug: 1475402
Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Joanna Wang 2541006811 Don't commit unstaged gitlinks in FREEZE.index during rebase-update.
To avoid having users deal with merge conflicts between unstaged
gitlinks modified before and after a git rebase-update we can just
not commit unstaged gitlinks in our freeze index.

This change results in whatever gitlinks are unstaged before
git rebase-update to be just rebased on top of whatever the latest
gitlinks are from remote.

Bug: 1472148

Change-Id: If7dcb82778a0bdd14c408f0a0287780a7bdc5358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771356
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Gregory Nisbet <gregorynisbet@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
2 years ago
Greg NISBET 923bcf8635 [git] add ignore_submodules option to status command in git_common.py
The `git addf` function implemented in the CL given below needs the ability to
ignore submodules in the output of `status`. Therefore, I am adding a flag to
the status command in `git_common` that resembles the git command line flag.

https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771336

Change-Id: I447c0dc853014ef49562f3130b22d038912011c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771343
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gregory Nisbet <gregorynisbet@google.com>
2 years ago
Robert Iannucci 2f0147a57a [git-freeze] Fix error in git-add invocation when not in repo root.
The previous change to git-freeze added an accidental regression
where running `git freeze` from somewhere other than the repo root
would return a mysterious error:

  "Failed to index some unindexed files. Nothing to freeze."

This is because `git add` always treats pathspecs as relative to the
current working directory. Fix this by changing `git add` to always
run from the repo root.

R=ajp@google.com

Change-Id: I451f26fe35a5c6e9f3b917a1d90bdadc7065244c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4703128
Commit-Queue: Andy Perelson <ajp@google.com>
Reviewed-by: Andy Perelson <ajp@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
2 years ago
Orr Bernstein b7e16d28f6 Support dormant branches in the git map-branches output.
This adds support in two ways:
1. Displays a "(dormant)" marker as part of each branch's line when the
   verbosity level is four or above. ('git bmap -v -v -v -v ...'). It's
   worth noting that, with verbosity level 4, each line is now 119
   characters long; verbosity level 3 is 107.
2. Enables callers to hide dormant branches using a new '--hide-dormant'
   option. If the dormant branch is the parent of non-dormant branches,
   it's still shown, despite being dormant, so that it can continue to
   serve as the parent line for non-dormant branches.

Change-Id: I0504419fd12357563288b5d53bc49ca68a876e8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4654849
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Orr Bernstein <orrb@google.com>
2 years ago
Robert Iannucci 4e87f5bfe2 [git-freeze] Ignore submodules when freezing.
It turns out we are already parsing the full output of `git status`,
so we may as well use that. This output already ignores submodules.

This also updates the freeze implementation to avoid unnecessary
calls to `git commit` when we already know if they are needed or
not.

Note that `git stash` (which `git freeze` is emulating) already
ignores submodules as well.

Ignoring submodules while freezing should make `git rebase-update`
work again inside of repos which have dirty submodules.

R=gavinmak,jojwang

Change-Id: Ib3a7784b6e7e7c19687203c1f4c32422a49bf8e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4680288
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
2 years ago
Bruce Dawson 4082f883ab Remove some Python 2 test code
Now that the presubmit system no longer supports Python 2 we can remove
support for it from the presubmit system tests. This change removes all
references to sys.version_info from this file.

This also fixes an unclosed file warning that suddenly appeared and
was stopping this change from landing.

Bug: 1207012
Change-Id: Ib74e9009b9d5cea0caf37c88e3258e9dd818f269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4522416
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
2 years ago
Gavin Mak 2cbe95c7c8 Don't enforce branch limit on rebase-update if only rebasing current
Bug: 1421399
Change-Id: I29ebcef2a88256aac6153556af75158679f44296
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4311855
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Martin Bidlingmaier 6f2321d1de Speed up git thaw
Previously, git thaw would read the whole output of git rev-list HEAD
via readlines(). This was unnecessary, because we almost always only
need to look a few of the most recent commits. Most of the runtime of git-thaw was spend on this.

After this commit, we only read the lines we actually need. This makes git thaw run much faster.

Bug: 1378479
Change-Id: I6f6c06e1df55b4943a94642aa414fc11aeea5718
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3981233
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Martin Bidlingmaier <mbid@google.com>
2 years ago
Josip Sokcevic fcf9fc4c36 Remove freeze as suggestion on git cl upload
Freeze command creates a commit, which then could be uploaded with git
cl upload.

R=gavinmak@google.com

Bug: 630822
Change-Id: I2fdc7bd8579f17680454b046ae80a473c6d420aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3923515
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 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 a3d1aaf112 Revert "[depot_tools] Add --fork-point when computing merge-base"
This reverts commit 934ac6ebdf.

Reason for revert: https://crbug.com/1225658, git reparent-branch
may result in data loss (recoverable if gc doesn't remove it).

Original change's description:
> [depot_tools] Add --fork-point when computing merge-base
>
> Using --fork-point when possible reduces the number of merge conflicts when running merge-base.
>
> Bug: 1111269
> Change-Id: I7240fdc9a613d2eb4e856b5677fc713551d7afe9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2519729
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

R=gavinmak@google.com

Bug: 1111269
Bug: 1225658
Change-Id: I2aeadeb2fbff18abcab5552e07254dfc1c2499a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3034831
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 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
Robert Iannucci d3acb16c9c [git-rebase-update] Disallow `git gc` during git-rebase-update.
In theory this should prevent `git rebase-update` from invoking
potentially expensive `git gc` operations after every `git rebase`
(ideally once per branch, but sometimes as many as three per branch (!)).

This has outsized effects as the size of the repo or number of branches
increases, and additionally has penalties on Windows due to git's
POSIXey assumptions around how disk I/O works.

After doing all rebase stuff, we run `git gc --auto` from rebase-update
once (assuming we were successful; if the command failed then we don't
run gc at all).

R=apolito@google.com

Bug: 617218
Change-Id: I37a8f7953779f15b320e4ed7bb85119cb4bb665a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2868766
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
4 years ago
Josip Sokcevic 0642373b27 Update origin/HEAD automatically
If origin/HEAD resolves to `master`, depot_tools can check if
origin/main exists. If so, it's very likely that origin/HEAD should be
updated to point to origin/main.
In the worst case, this will result in extra git remote call while not
changing local state (i.e origin/HEAD remained unchanged).

R=gavinmak@google.com

Bug: 1190702
Change-Id: I51e69d7a95d3534e1820099b4b6983d38b5e2763
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2795075
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Antonio Sartori e0dff20891 Make git map-branches faster
This change makes git map-branches a little bit faster by avoiding
fetching the revision list of each branch if git map-branches will not
show the tracking info anyway.

Change-Id: I47458871f904004f910aadd7d774bea5193c979e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2695393
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
4 years ago
Edward Lesmes cf06cad1be [subprocess2] Replace VOID with DEVNULL
subprocess.DEVNULL was introduced in Python3 to serve same purpose
as subprocess2.VOID, so rename VOID to DEVNULL in subprocess2.

Change-Id: I6dade3306ffc3bc2441ac6083f362b099c2427e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2587758
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Josip Sokcevic 9c0dc3026e Replace non-inclusive terms
Bug: 1118410, 1118413, 1118422, 1118424, 1118426
Bug: 1118428, 1118430, 1118434, 1118438, 1118442
Bug: 1118453, 1118454
Recipe-Nontrivial-Roll: chromiumos
Recipe-Nontrivial-Roll: build
Change-Id: I43e6305f8c3136774f01b57f12bb442bcb863371
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2551388
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Gavin Mak 934ac6ebdf [depot_tools] Add --fork-point when computing merge-base
Using --fork-point when possible reduces the number of merge conflicts when running merge-base.

Bug: 1111269
Change-Id: I7240fdc9a613d2eb4e856b5677fc713551d7afe9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2519729
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
4 years ago
Sylvain Defresne 39d870e1f0 Fix `git map-branches` when branch is named after a file/directory
If there is a branch named after a file in the repository root, the
command `git rev-list --count $branch ^$base` is ambiguous. This is
because `git` does not know whether $branch needs to be parsed as a
revision or a filename.

Adding a trailing `--` parameter to the command-line resolves this
ambiguity since when present, everything before the `--` cannot be
a filename and everything after `--` has to one.

From git documentation:

  Paths may need to be prefixed with -- to separate them from
  options or the revision range, when confusion arises.

Bug: none
Change-Id: Ieb10aa8701e12fc3c88d5f75ff624f61ee8d8aaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2475773
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
4 years ago
Gavin Mak 8d7201bc3c Modify git map-branches to show the number of commits on a branch
Currently, for a given branch, map-branches displays the number of
commits ahead and behind it is. This change replaces ahead with
commits, representing the number of commits a branch has, starting from
its base commit, and more accurately reflects the state of a repo.

Bug:1128716
Change-Id: I7c070b4efd452d82d878e1cfb7c20d1c80f38ec7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2412991
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
5 years ago
Richard He 42033b2c6a Fix gclient-new-workdir when source repo is shallow clone
When source repo is a 'shallow clone', `.git/shallow` is not linked to
the new workdir. Which makes running git command fails in new workdir.

Change-Id: I81d38b7b2cccc482711dcc1dd02ea06fbd01a56d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2211635
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Richard He <linyhe@microsoft.com>
5 years ago
Josip Sokcevic 72f991f760 Fix printing error on git-rebase failure
Reverted commit 4511b131e6 had a bug where
squash_ret.success = True and empty_rebase = False. In that case, stdout
and stderr would already be string and trying to decode would fail.

Bug: 1071280
Change-Id: Iadcc526147ebb98aa7a91a7daa64ef44066e83b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2163387
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago