Commit Graph

54 Commits (65aa0a04ff7fd6f1fa35e160f0d1bb8236570b92)

Author SHA1 Message Date
Devon Loehr 65aa0a04ff Use hashlib for truly deterministic hashes
It turns out python's built-in hash function uses a random seed
that changes per-process, so branch names based on that hash
aren't actually deterministic. This changes the hashing algorithm
to use a stable hash so we can get consistent results.

Bug: 389069356
Change-Id: I1d3241b922005a7bff4d8621dc79dc4551bf264e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6258544
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
2 weeks ago
Devon Loehr f7e85d3470 Remove redundant try/catch for better error reporting
During testing, I discovered that the try/catch block surrounding
most of SplitCl is broken: subprocess errors seem to return bytes
more often than strings. When I fixed that, however, I found that
the errors were much more comprehensible if we simply re-raised
the initial error and got all the information it contained; this
both gives us a stack trace and makes it very obvious an error
occurred.

Specifically, we also had the problem that stderr was sometimes
empty even if the process failed (because it wrote to stdout instead),
and if we just wrote the output then it wasn't clear that an error
happened until you actually read the output, as opposed to the
exception printing where the stack trace makes it obvious.

Since re-raising without additional work is pointless, I just removed
the block entirely.

Bug: 389069356
Change-Id: I1d1bec765469d0b70b463f7214f47a25316a37c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6258516
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
2 weeks ago
Devon Loehr 0822fcc141 `git cl split`: Save and load splittings from files
This CL implements the proposal (from the design doc in the cited bug)
to allow `git cl split` to save the generated splitting to a
human-readable and editable text file. This allows users to save the
splitting in case something goes wrong and they need to retry, and also
lets them tweak a generated splitting if they get something mostly, but
not quite, usable.

It also allows users to edit the generated splitting interactively, like
they do for e.g. CL descriptions during `git cl upload`.

Bug: 389069356
Change-Id: I8ae21f2eb7c022ba181ae5af273ce09605b5acec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6235727
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
3 weeks ago
Devon Loehr ff733a6496 `git cl split`: Include dirname as part of branch names
This CL changes the way `git cl split` generates branch names during
upload. Specifically, it attempts to derive a common directory for all
the files in each CL, and includes that dirname as part of the branch
name, in addition to a hash of the files in the CL. This makes it a bit
easier to guess what's in a branch, given its name.

Since the hash is still included, branch names should remain unique.
Finding a common directory should be deterministic, so we can still rely
on branches having the same name if the script is re-run with the same
splitting.

Bug: 389069356
Change-Id: I70490258755f13962f3db5c835619caa24176af9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6243377
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
3 weeks ago
Devon Loehr 5a3c9438e6 `git cl split`: Name sub-branches by hash
`git cl split` operates by creating a new git branch for each CL
it uploads. It names this branch based on the directory of the files
in the CL. It uses this convention when resuming an interrupted upload:
it skips branches that already exist.

However, this approach is brittle for several reasons:
- The splitting is nondeterministic, so there's no guarantee that CLs
with the same directories will be generated when re-run. Even if they
are, there's no guarantee they'll have exactly the same files.
- For CLs with multiple directories, it uses an arbitrary one, so it
may not choose the same name a second time
- It bakes in an assumption that every CL is defined by the directories
it draws files from.

This CL alleviates this issues by instead naming branches using the hash
of their contained files. This ensures that, with extremely high
probability, branches will have the same name if and only if they have
the same (sorted) list of files. Thus resumed uploads can safely skip
existing branches.

Bug: 389069356
Change-Id: I19bf7cd6ff8b0127f5906384f7f43b3e40ac8fee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6236622
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
3 weeks ago
Devon Loehr f99834cd29 cl split: Refactor splitting datastructure
This is a preparatory CL which refactors some internal logic to make
writing future CLs easier. In particular, it changes from treating a
CL as "a list of files with the same reviewer" to treating them as a
triple of (reviewers, files, directories). It does so using a dataclass
to make it easy to work with.

It also adds an EmitWarning convenience function, which will be more
heavily used in future CLs.

Bug: 389069356
Change-Id: I842d59ba69f5db5e3745fa39832794cdc1eb222e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6190430
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
3 weeks ago
Devon Loehr 36427aab02 split_cl: Always ask for confirmation before uploading
`git cl split` has the potential to do a lot of operations at once,
which is problematic if it didn't end up splitting things in a way
the user approves of. This changes it to print a summary of the
splitting, and asking the user to review it briefly before proceeding
with the upload.

Bug: 389069356, 40642562, 40269201
Change-Id: I90bead0147badbaa3afcce2264d805ae498f101c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6163905
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: Andy Perelson <ajp@google.com>
1 month ago
Devon Loehr f546ee068c Fix argument mismatch in split_cl.py
When adding tests, the LoadDescription function accidentally got called
with the wrong arguments in the main function. This fixes that; a future
CL (uploading shortly) adds more robust tests that would have caught this.

Bug: 389568463, 389069356
Change-Id: Icaf5e83cd8caa9f3975173f8c8ee7d92ef44ee56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6170638
Commit-Queue: Andy Perelson <ajp@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
Reviewed-by: Andy Perelson <ajp@google.com>
Auto-Submit: Devon Loehr <dloehr@google.com>
2 months ago
Devon Loehr 24d9ad69fa split_cl: Make description file optional during dry runs
I frequently find myself running `git cl split` just to see how the
files are going to be split up, without actually intending to submit the
resulting CLs immediately. Doing so requires creating a file, putting a
dummy description in it, and passing that to the command line, which is
unnecessary work. This CL simply allows dry runs to use a dummy
description if none is provided, to make checking the tool's output
easier.

Bug: None
Change-Id: I47e06c6e6da26701e07dcae81ab605edac2e2ca6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6163904
Reviewed-by: Andy Perelson <ajp@google.com>
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
2 months ago
Chris Fredrickson 8893866bf7 Edit warning in split_cl.py
Per https://groups.google.com/a/google.com/g/mchristoff-team/c/U_4MKQwnJcU/m/3V4zgTiABQAJ,
a given user's CQ+1 and CQ+2 runs have a global throttle limit, to
avoid straining the build infrastructure too much. We can therefore
adjust the warning in `git cl split`.

Change-Id: I9f07c93bd428e70b49d13b4cbf085da024c78210
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5748984
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Chris Fredrickson <cfredric@chromium.org>
Auto-Submit: Chris Fredrickson <cfredric@chromium.org>
7 months ago
Takuto Ikuta d44bc14aa6 split_cl: do not prepend '/' in $directory
I think it is readable if '/' is not prepended for the CL title like

```
$directory: apply some change
```

e.g. https://crrev.com/c/5541194/1..3//COMMIT_MSG#b7

Change-Id: If4cbb4966ebf62f99a7078028e4cb104de4b7197
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5540834
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
10 months ago
Kalvin Lee 726042b2c2 split_cl: Add spaces
In source, line-crossing string fragments are joined with no spaces in
between. This CL trivially adds spaces s.t. the warning doesn't get
printed like:

```
won'tbreak anything...to cancelyour jobs
```

Change-Id: I17b4a6c0d22fa63ee4ea66d5b32f7fc3221bc2be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5352388
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Kalvin Lee <kdlee@chromium.org>
12 months ago
Mike Dougherty 68c511349d Improve git cl split warning if more than 10 CLs will be created.
This CL updates the warning printed when more than 10 CLs will be
created to be shown whether or not the CLs are being sent to the CQ
and provides guidance on adjusting the number of CLs using the max-depth
flag. This makes the tool more user friendly by preventing a new user
from unknowingly creating many CLs without realizing there is a
supported option to customize the depth.

Additionally, it sets the default for the cq-dry-run option to False
instead of None and logs the value of cq_dry_run when running a git cl
split dry run.

Change-Id: I6feba24d06dd5e88d9005345d5b0a1e15c53e197
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5234543
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Mike Dougherty <michaeldo@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
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>
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 bb14391a50 Remove unused imports from depot_tools scripts
This change removes some unused imports across depot_tools scripts.

Change-Id: Ic1112065ad1020fc4a3573d3fb9f137915ef439c
Bug: 1475776
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4812185
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Peter Kotwicz caeef7ba32 Add tests for split_cl.py
This CL:
- Adds tests for split_cl.UploadCl()
- Splits out logic checking bug links so that it can be tested

Bug:None

Change-Id: I3c08b129e0cfda67a3d93a2e01acef86d33e92b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4743773
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
2 years ago
Peter Kotwicz 729de5761e Remove redundant message in case "git cl split" fails upload
This CL stops "git cl split" from printing which directories could
not be uploaded if upload fails. This information is redundant with
previous lines printed by "git cl split"

Bug:None

Change-Id: I39bc47e3b29d4ce777a65b6bdac28b19b672339f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4743774
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Peter Kotwicz 70d971a135 Prevent split_cl.py from uploading multiple CLs for same reviewers
This CL prevents split_cl.py from uploading multiple CLs for the same
reviewer set.

BUG=1468350

Change-Id: I9c328589f7facfe10ee5066cc3d1cda007dd1d2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4726781
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
2 years ago
Anne Redulla b550995346 Print top reviewers for git cl split
Change-Id: I958ebe18327c73be2d2273eb5c230a6e6fba2d73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4686590
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 072d06e918 Created disable-auto-submit flag for git cl split
This CL adds a disable-auto-submit flag for git cl split.

Change-Id: Ibce0e06706390ff9429d59094fed2449096c631c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4659527
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Rachael Newitt 03e4912518 Added topic flag to git cl split functionality.
Change-Id: Ie3314cfe45e008f1df8b21ff16abda0980a5225e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4653533
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Rachael Newitt <renewitt@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
Thiago Perrotta 223f48d7ad git cl split: recognize bug patterns of the form "Bug: chromium:123"
Currently, only the "Bug: 123" form is recognized.

Bug: none
Change-Id: I4348779bb14f4c02bb8781ce4fe2bd55892e8cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4289407
Commit-Queue: Thiago Perrotta <tperrotta@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
2 years ago
Daniel Cheng 403c44e293 Add a --max-depth option to git cl split
For some types of changes, git cl split generates too many small CLs.
--max-depth provides one way of generating larger CLs when the author
judges that the larger CLs do not adversely affect reviewability (e.g.
20x 1 line CLs packed into 1x 20 line CL is generally fine).

Fixed: 777781
Change-Id: I64426ff4723fbc412fbc47f3cc12767433aeb8ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3933974
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
2 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
Song Fangzhen 534f505b77 Update format of `git cl split`
This change updates the output format of `git cl split` when
`description_file` has no footers.

Bug: 1215852
Change-Id: I69764885337ec31134f2b5e2d861930e0bc8cd2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2936161
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: Fangzhen Song <songfangzhen@bytedance.com>
4 years ago
Olivier Li 0614591e11 Add more users warning to git cl split
Change-Id: I1306728d73701b2444d382f579aa8894d9857ed4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2892214
Commit-Queue: Olivier Li <olivierli@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
4 years ago
Edward Lesmes 15234017ec split-cl: Use code owners plugin if available.
Change-Id: I2263d8c1bc48ba0f64bcd5e665d8eb6ea451f1cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2693916
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Edward Lesmes a461284723 split-cl: Use owners client to suggest owners.
Change-Id: I7aab38306e0699de465d0d2ab83dd37c4a099eee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2669149
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Edward Lesmes b1174d733e split-cl: Walk the tree instead of using owners db.
Change-Id: I9dc9cda5a30833938fe13476deb76f4ed5770eab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2666668
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 years ago
Sigurdur Asgeirsson 1af7968d68 Reduce git cl split oversplitting.
Without this change, git cl split will create a separate CL for every
file that has per-file owners rules. This is almost always the wrong
thing to do. With this change, it will at least aggregate all such files
to their parent directory. This may under-split, but is perhaps nearer
the mark.

Change-Id: Iea7997b36d053713fa00f1261ea032e09d9c2818
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2555729
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Anthony Polito c08c71bedf don't let 'anyone' be a reviewer
Bug: 1120999
Change-Id: I8190a9d37f8dfcb59d9d51966fc67719592c2c8a
R=sokcevic@google.com
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2378453
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Anthony Polito <apolito@google.com>
5 years ago
Edward Lesmes 17ffd9875c git-cl: Fix git-cl split.
Change-Id: I6ca167e34829cd7694372923917446c3843c879f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2129146
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes ae3586b538 depot_tools: Use gclient_utils.AskForData instead of raw_input.
gclient_utils.AskForData will use raw_input on Python 2 and input on Python 3.

Bug: 1063976
Change-Id: I93c059c4e4454d01787716b5a0a2641ad5253f53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116370
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur 2c62b334ea git-cl: Stop using Change class from presubmit support.
Bug: 1042324
Change-Id: I72db082f086f69bf49256d0613c39dc92ae0a07f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101471
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
5 years ago
Edward Lemur a12175c2a7 git-cl: Use _create_description_from_log instead of GetLocalDescription
Also refactor code to eliminate multiple calls to _create_description_from_log.

Change-Id: I113134fbd90f396bdb6d561ed0369ea5ee9c78ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2090448
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur b7f759f6bc git-cl: Use open instead of file.
file does not exist on Python 3.

Change-Id: I9392fd797b730784cff4d1144c5a3ab1027c7dd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2086493
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur ac5c55f6d7 Revert "Improve git cl split"
This reverts commit 684096347b.

Reason for revert:
Breaks git-cl split.
https://bugs.chromium.org/p/chromium/issues/detail?id=1054888

Original change's description:
> Improve git cl split
>
> This CL changes the behavior of `git cl split` to split the change
> by the size of the resulting CLs. For now, this is based on the number
> of bytes changed, and not by the number of changed lines. Depending
> on the shape of change, this may still produce more CLs than expected
> (and possibly more than before).
>
> A future change will switch the split to be based on the number
> of affected lines, and also introduce a mode to base the split
> on the number of affected files.
>
> Bug: 998922
> Change-Id: I49f868972a61b89b426ef9e2ceedc733eacb4350
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1778744
> Commit-Queue: Yannic Bonenberger <yannic.bonenberger@gmail.com>
> Reviewed-by: Dirk Pranke <dpranke@chromium.org>

TBR=fdoray@chromium.org,dpranke@chromium.org,yannic.bonenberger@gmail.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com

Bug: 998922
Change-Id: I466e1245d5f1c934443d850c48c42d3e694e71c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2080205
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur 1773f37de6 gclient_utils: Add temporary_file method.
Useful when passing information to a subcommand via a temporary file.

Bug: 1051631
Change-Id: I0b8deda921effd24a37109544e1e7ca22e00ba4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2068942
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes 7c34a22537 git-cl: Fix Change object construction for git-cl split
Changelist.GetChange signature was changed in
https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2038050

Bug: 1042324, 1054880
Change-Id: I6ba63e7f2f6c13bd8e8bef4e76cd66ee0525bba2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2067623
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes 4dc5b7792f git-cl: Fix split branch name
Bug: 998922, 1054888
Change-Id: I4ae14700cbd6eb483f318f6ed9f4d1f30b58153e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2068492
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Yannic Bonenberger 684096347b Improve git cl split
This CL changes the behavior of `git cl split` to split the change
by the size of the resulting CLs. For now, this is based on the number
of bytes changed, and not by the number of changed lines. Depending
on the shape of change, this may still produce more CLs than expected
(and possibly more than before).

A future change will switch the split to be based on the number
of affected lines, and also introduce a mode to base the split
on the number of affected files.

Bug: 998922
Change-Id: I49f868972a61b89b426ef9e2ceedc733eacb4350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1778744
Commit-Queue: Yannic Bonenberger <yannic.bonenberger@gmail.com>
Reviewed-by: Dirk Pranke <dpranke@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
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
Takuto Ikuta 51eca59ff6 Support --enable-auto-submit in `git cl split`
With default True.

This CL was uploaded by git cl split.

R=jochen@chromium.org
Bug: 927178
Change-Id: Ie0a68ed7ca381e1bb33341badca153bf409bb376
Reviewed-on: https://chromium-review.googlesource.com/c/1470402
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
6 years ago
Stephen Martinis f53f82cbc8 `git cl split`: Fix typos in cq_dry_run code
Bug: 878117
Change-Id: Ifb8af6bfcc6467ad9b79cf6292ebb8afc8f7e949
Reviewed-on: https://chromium-review.googlesource.com/1213588
Reviewed-by: John Budorick <jbudorick@chromium.org>
Reviewed-by: Ryan Tseng <hinoka@chromium.org>
Commit-Queue: Stephen Martinis <martiniss@chromium.org>
7 years ago
Stephen Martinis cb32668137 git cl split: Don't cq dry run by default
`git cl split` currently runs a cq dry run for every uploaded CL. This
has overloaded our infrastructure a few times in the past. This CL changes
the command to not dry run by default, and adds a flag to enable this. The
flag has a warning about doing this, and tells the user to email
infra-dev@chromium.org if they're going to be generating >~10 CLs.

Bug: 878117
Change-Id: Ic865c09b188b8d4f202785f4763f7b7b8910c9cf
Reviewed-on: https://chromium-review.googlesource.com/1191927
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Stephen Martinis <martiniss@chromium.org>
7 years ago