Commit Graph

58 Commits (main)

Author SHA1 Message Date
Paul Irish 237b84e76c Colorize branch names for rebase-update
To ease the UX of finding the branch name when there's a conflict to
resolve.

Change-Id: I34d16f2f7bd897a60e96b0391772b5d8985f3cb6
Bug: none
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6278647
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Paul Irish <paulirish@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 week ago
Mason Freed 2451ee476d Reland: add a `--no-squash` argument to `git rebase-update`
See crbug.com/40264739 for many more details. But a prior attempt
to land this patch resulted in [1] which simply removed all
squashing behavior from `git rebase-update`. That broke several
people's workflows. So this patch attempts, again, to simply
add an opt-in to *not* squashing, for the folks (like me) who
do not want that behavior.

[1] https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6104282

Fixed: 40264739
Change-Id: I4a6aa8e53e854a7e601a0fb83f4f9fcb638d36ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6254099
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
2 weeks ago
Mason Freed a155deff42 Revert "Remove "attempt to squash" behavior from `git rebase-update`"
This reverts commit 58625e82c6.

Reason for revert: Several comments on crbug.com/40264739 that this broke their workflow. I plan to revert this and put patchset #2 back up for review, with an opt-in instead of a change to the default behavior.

Original change's description:
> Remove "attempt to squash" behavior from `git rebase-update`
>
> In common workflows, this step only succeeds ~5% of the time, and
> in the other 95% of cases, simply adds ~30 seconds of wasted time
> to the execution time of `rebase-update`. Therefore, this CL removes
> the automated functionality, and leaves squashing as a manual option
> to the user.
>
> Fixed: 40264739
> Bug: 40390274
> Change-Id: Ib2a3ffe4b0e5d0b74323a2a0d34ab0e1b7fafb08
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6104282
> Auto-Submit: Mason Freed <masonf@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>

Bug: 40390274
Change-Id: I91210a5a21b3751695553433389f346ba443bb1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6254237
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
2 weeks ago
Mason Freed 58625e82c6 Remove "attempt to squash" behavior from `git rebase-update`
In common workflows, this step only succeeds ~5% of the time, and
in the other 95% of cases, simply adds ~30 seconds of wasted time
to the execution time of `rebase-update`. Therefore, this CL removes
the automated functionality, and leaves squashing as a manual option
to the user.

Fixed: 40264739
Bug: 40390274
Change-Id: Ib2a3ffe4b0e5d0b74323a2a0d34ab0e1b7fafb08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6104282
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 months ago
Peter Birk Pakkenberg 6eeb55de17 Add --tree option to rebase-update.
I often find myself working on stacked changes, and this option will
make it easier to integrate changes into downstream CLs.

With `git rebase-update --current --tree --no-fetch`, it is possible
to only rebase the current chain of changes, without touching any other
local branches that may exist.
This is beneficial both for speed, and to avoid having to resolve merge
conflicts on branches unrelated to the changes you are currently working
on.

Change-Id: I2d3853ad5aad6c74db0ae26ff8d27d14dcaed3e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5546383
Auto-Submit: Peter Pakkenberg <pbirk@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
8 months ago
Yiwei Zhang 2ae9ede018 fail gracefully if git rebase-update is called in cog
Bug: 339231299
Change-Id: I2becec27c0b3f8d7b5e70c1eb7fe861c67f33e42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5539474
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
10 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
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
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
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
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
Robert Iannucci c5dab15050 [git-rebase-update] Ignore submodules when checking tree status.
Noticed while working on the infra repos.

Currently `git rebase-update` will do a `git freeze`, then run a
`git status` to make sure the tree is clean... however this status call
currently considers submodule state, which leads to a really confusing
experience. `git rebase-update` is trying to ensure that the FILES on
disk won't be goobered during the rebase process... a process which
essentially ignores submodule state entirely.

This CL just makes `git rebase-update` ignore submodule diffs.

R=aravindvasudev@google.com

Change-Id: I9d546ac9ef0c0ba6ac9918f08fb5163ab18aebb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4680280
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
2 years ago
Joanna Wang 677da3c869 Revert "Add --no-squash argument to git rebase-update"
This reverts commit 80cc67cc00.

Reason for revert: Not +1'd by anyone from owning team.

Original change's description:
> Add --no-squash argument to git rebase-update
>
> --no-squash makes it faster to run rebase-update when there are merge
> conflicts and you know that squashing will not help. For example, I
> store all of my branches in one commit each, so I know that squashing
> isn't even possible because they are already squashed.
>
> Change-Id: I2679a855ad79d602a6d1ee09c140f2fd27ae20c5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2904096
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
> Commit-Queue: Joey Arhar <jarhar@chromium.org>

Change-Id: I0b577b053a3e6c7514e28cde4cb7849f50ecd64f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4411905
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2 years ago
Joey Arhar 80cc67cc00 Add --no-squash argument to git rebase-update
--no-squash makes it faster to run rebase-update when there are merge
conflicts and you know that squashing will not help. For example, I
store all of my branches in one commit each, so I know that squashing
isn't even possible because they are already squashed.

Change-Id: I2679a855ad79d602a6d1ee09c140f2fd27ae20c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2904096
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Joey Arhar <jarhar@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
Victor Vianna 9a6aa08468 Suggest --no-fetch flag after git rebase-update conflict
This spares an unnecessary git fetch.

Change-Id: I552148bdfadc3482bda0d71d75aaf9d9ed61d75d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4062088
Auto-Submit: Victor Vianna <victorvianna@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Chloe Pelling e515e5d22e Make the "mark branch dormant" instructions simpler to copy+paste.
I regularly run into this error for local branches corresponding to
merged CLs. Before, I had to manually type `git rebase --abort`
before copy-pasting the `git config branch.[...].dormant true` line
into my terminal. With this change, I can just copy-paste once to
execute both steps, then press up+up+enter to retry.

As a side benefit, Git newcomers won't have to look up how to abort
a rebase.

Anyone preferring the previous workflow can still elect to copy
just the `git config` line.

Bug: none
Change-Id: I516d4ed12c5111936cc65460ce119a43e5f86a8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3570882
Auto-Submit: Chloe Pelling <cpelling@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Josip Sokcevic 4de5deacd4 Explicitly run everything with python3
R=aravindvasudev@google.com, gavinmak@google.com

Change-Id: Iaa5e960c6226dea3a0814c7cb778d952eafb1502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3525960
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Gavin Mak 9450767ac3 Revert "Error out of rebase-update if there are uncommitted changes"
This reverts commit eff810e93d.

Reason for revert: breaks workflows for users

Original change's description:
> Error out of rebase-update if there are uncommitted changes
>
> Currently, running rebase-update may lead to missing untracked files.
> This change prints an error instead freezing and thawing local changes.
>
> Bug: 1251047
> Change-Id: Ia5f718ed957dae936d2ead2778760ae0c8d9f9ea
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3171828
> Commit-Queue: Gavin Mak <gavinmak@google.com>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Bug: 1251047
Change-Id: I5b61dc1c7af13ccca6ea80baecff0522291083c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3191674
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
3 years ago
Gavin Mak eff810e93d Error out of rebase-update if there are uncommitted changes
Currently, running rebase-update may lead to missing untracked files.
This change prints an error instead freezing and thawing local changes.

Bug: 1251047
Change-Id: Ia5f718ed957dae936d2ead2778760ae0c8d9f9ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3171828
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
3 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
Allen Bauer 8e404a7e49 Added option to keep empty branches in rebase-update.
Change-Id: I87b1edf242aa5c8483d8d84d223fc9187a194708
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2292962
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
5 years ago
Wez fef5cf8e22 Revert "Fix printing error on git-rebase failure"
This reverts commit 4511b131e6.

Reason for revert: Broke git_rebase_update.py under Python3, which does
not support calling decode() on string objects.

Original change's description:
> Fix printing error on git-rebase failure
> 
> R=​ehmaldonado@chromium.org
> 
> Bug: 1071280
> Change-Id: I8b1f00bb7c454297b10d5e047ae35c2686f69fb1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2155154
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@google.com>

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

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1071280, 1073768
Change-Id: I58c1b24ba2aef255068c81be25475b2abbbf4fcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2161111
Reviewed-by: Wez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
5 years ago
Josip Sokcevic 4511b131e6 Fix printing error on git-rebase failure
R=ehmaldonado@chromium.org

Bug: 1071280
Change-Id: I8b1f00bb7c454297b10d5e047ae35c2686f69fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2155154
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
5 years ago
Dale Curtis 0610193326 Don't delete dormant branches, even if empty.
1) The current behavior feels contrary to the documentation; which says
"If true, will cause rebase-update to skip all processing on the branch."

2) The new behavior allows a workflow where 'master' is empty and
marked dormant, but kept up to date as the parent for all other
branches.

Change-Id: Ic7440706a69753f796846dd84ecbf8bcf172ba4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2128675
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Marc-Antoine Ruel 8e57b4bc55 python3 improvements
Ran:
  vi $(git grep --name-only iteritems | grep -v third_party)
  vi $(git grep --name-only itervalues | grep -v third_party)
  vi $(git grep --name-only 'print ' | grep -v third_party)

and edited the files quickly with adhoc macros. Then ran in recipes/:
  ./recipes.py test train

There was only a small subset of files that had been updated to use
six.iteritems() and six.itervalues(). Since the dataset size that is
being used in gclient is small (pretty much always below 200 items),
it's better to just switch to .items() right away and take the temporary
performance hit, so that we don't need to come back to rewrite the code.

Recipe-Nontrivial-Roll: build
Bug: 984182
Change-Id: I5faf11486b66b0d73c9098ab0f2ce1b15a45c53e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1854900
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Marc-Antoine Ruel <maruel@chromium.org>
5 years ago
Edward Lemur 12a537f932 depot_tools: Run git_common_test in Python 3
Bug: 1009809
Change-Id: Idfcbd26de3420798f092c7fa55a6126d7c389a8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1834317
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes 98eda3f3e4 Revert "depot_tools: Run Python scripts using vpython (Part 1)"
This reverts commit d6186f9936.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> depot_tools: Run Python scripts using vpython (Part 1)
> 
> Tbr: iannucci@chromium.org
> Bug: 984182
> Change-Id: If36722e190d305f89d63dce91d0a600ddc34ebe3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1748589
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=iannucci@chromium.org,ehmaldonado@chromium.org

Change-Id: I7686985852608d0703bcbbab137df1ce82b29723
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 984182
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1749853
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Edward Lemur d6186f9936 depot_tools: Run Python scripts using vpython (Part 1)
Tbr: iannucci@chromium.org
Bug: 984182
Change-Id: If36722e190d305f89d63dce91d0a600ddc34ebe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1748589
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Raul Tambre 80ee78e7fa Convert print statements to Python 3 style
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.

The scripts still work with Python 2.
There are no intended behaviour changes.

Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Henrique Ferreiro fe83cfa6b4 Add --current to rebase the current branch
Add a shortcut to extend the branches to be rebased with the current
branch without having to type its name.

Change-Id: If2fa117a6418590cdec5e65430f65dcdc825b611
Reviewed-on: https://chromium-review.googlesource.com/c/1483030
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Henrique Ferreiro 3acdefa9aa Omit "Skipping <branch>" message when unneeded
When calling `git rebase-update <branches>`, don't emit messages about
skipping branches which are not in the list of branches to be rebased.

R=iannucci@chromium.org

Change-Id: Ia5135d2e794646aaec68bca1aa64f4a73c98c186
Reviewed-on: https://chromium-review.googlesource.com/c/1476394
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Sergiy Belozorov b58d4bda63 Add a feature to specify branches to be re-based
Change-Id: I00f1d6716ca5ece647d7ac15471ded25c1f164b2
Reviewed-on: https://chromium-review.googlesource.com/c/1370125
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
6 years ago
Andrew Moylan bfc4082f43 Flush stdout before squash attempt
This change inserts a flush after "..." in lines like:

  Failed! Attempting to squash mybranch ... Failed!
and:
  Failed! Attempting to squash mybranch ... Success!

This way the user can follow the progress better and has an indication
of why the rebase is taking longer than they might expect.

Bug:
Change-Id: Ie04db2879fccd363d7b0f13b7a5217f1c13fd0e2
Reviewed-on: https://chromium-review.googlesource.com/737009
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Andrew Moylan <amoylan@chromium.org>
7 years ago
Robert Iannucci c87e36aaec [git rebase-update] Handle error when chdir'ing to original workdir.
BUG=

Change-Id: I1dc7f20eea3f4b1be9179aa6d77bdee08ab8a04f
Reviewed-on: https://chromium-review.googlesource.com/431576
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
8 years ago
agable 7aa2ddd81d Refactor git_common config and die
R=iannucci@chromium.org
BUG=376099

Review-Url: https://codereview.chromium.org/2075603002
9 years ago
iannucci@chromium.org 0d9e59c6ce Fix rebase-update on windows on git-svn repos.
Through a comedy of wrapper scripts, the ^ is being swallowed, which
causes the `git config` invocation to match all lines which HAVE
"remote" in them, instead of matching lines which BEGIN with remote.

R=maruel@chromium.org, pkasting@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1566343002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298185 0039d316-1c4b-4281-b951-d872f2087c98
9 years ago
iannucci@chromium.org aa1dfdab66 Fix multi-rename empty branch detection.
This changes the 'empty' branch detection to compare the commit trees instead
of the commit hashes. This avoids empty-branch detection when you have multiple
renames on the branch that end up canceling eachother out. Previously you'd
end up with the rename-commits, in order, in your rebased branch, even though
when you run `git upstream-diff` you get nothing.

R=agable@chromium.org, jochen@chromium.org, vadimsh@chromium.org
BUG=438208

Review URL: https://codereview.chromium.org/1497313002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297849 0039d316-1c4b-4281-b951-d872f2087c98
9 years ago
sdefresne@chromium.org d421f6a477 Fix "git rebase-update" when multiple branch are stale.
Fix a bug that left branches tracking a dead branch if both their parent
and grand-parent were left with no changes after a "rebase-update" step.

Given the following initial state:
  $ git map-branches -v
  origin/master
    a
      b
        c *        [ ahead 1 ]

without this patch, a "git rebase-update" on this tree state would
leave the branch "c" as tracking a non-existing branch "a":

  $ git recursive-rebase
  a up-to-date
  b up-to-date
  c up-to-date
  Reparented c to track a (was tracking b)
  Deleted branch b (was 448d1da).
  Deleted branch a (was 448d1da).
  $ git map-branches -v
  {a:GONE}
    c *

with the patch, we record that the branch "c" is tracking must be
updated twice and we end up in a state were "c" is correctly tracking
"origin/master":

  $ git recursive-rebase
  a up-to-date
  b up-to-date
  c up-to-date
  Reparented c to track origin/master (was tracking b)
  Deleted branch b (was 448d1da).
  Deleted branch a (was 448d1da).
  $ git map-branches -v
  origin/master
    c *            [ ahead 1 ]

BUG=456806

Review URL: https://codereview.chromium.org/1482753002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297792 0039d316-1c4b-4281-b951-d872f2087c98
9 years ago
stip@chromium.org 74374f985f Add a --keep-going flag for people who run rebase-update infrequently.
Review URL: https://codereview.chromium.org/1331263002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@296639 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
iannucci@chromium.org 196809e75b Only chdir in rebase-update if there's a directory to go back to.
TBR=agable@chromium.org
BUG=499031

Review URL: https://codereview.chromium.org/1182713002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295642 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
iannucci@chromium.org dabb78bfd5 Make git-rebase-update a bit more robust
* When aborting a failed rebase, don't cascade errors if the abort itself
    fails.
  * When starting a rebase-update cycle, cd to the root of the repo. This avoids
    an issue when you run rebase-update from inside of a branch which adds a
    new folder.

R=agable@chromium.org
BUG=499031

Review URL: https://codereview.chromium.org/1180673003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295637 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
sbc@chromium.org 013731e832 Handle KeyboardInterrupt consistently in python scripts
Handle KeyboardInterrupt gracefully rather the printing a
backtrace. Most users of these tools don't expect a
backtrace when then hit Ctrl-C.

Also, fix a few other inconsistencies found in the python
startup code of these different scripts:
- always call main function 'main' (rather than 'Main')
- always return 0 from main function
- if main takes args never include argv[0]

Review URL: https://codereview.chromium.org/955993006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294250 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
sbc@chromium.org 8b4900e77f Handle unusual case in rebase-update where second rebase attempt works.
Previously we just added an assert here but better
to simply succeed in this case, while outputting
the intial failure message.

BUG=425696

Review URL: https://codereview.chromium.org/667793005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292687 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
sbc@chromium.org 384039b174 Improve error handling in git-rebase-update
Don't discard stderr from failed rebase operations
I had an issue where stdout of the failed rebase was
empty but stderr contained:
First, rewinding head to replay your work on top of it...
Dirty index: cannot apply patches (dirty: internal_gyp
third_party/html_office).

Also, in my case the second rebase was actually succeeding
for some reason, which is clearly no expected, so assert
in this case.

BUG=410339

Review URL: https://codereview.chromium.org/645763002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292444 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
asanka@chromium.org 4d2a66eeda Fix regexp used for enumerating remotes.
R=szager@chromium.org
BUG=413391

Review URL: https://codereview.chromium.org/598153003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292123 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago