Commit ac5c55f6 authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

Revert "Improve git cl split"

This reverts commit 68409634.

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/+/2080205Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 55ab41d1
......@@ -4433,10 +4433,8 @@ def CMDsplit(parser, args):
Creates a branch and uploads a CL for each group of files modified in the
current branch that share a common OWNERS file. In the CL description and
comment, '$directory' is replaced with the directory containing the changes
in this CL, '$cl_index' is replaced with the index of the CL we're currently
sending out, and '$num_cls' is replaced with the total number of CLs that
we're sending out in this split.
comment, the string '$directory', is replaced with the directory containing
the shared OWNERS file.
"""
parser.add_option('-d', '--description', dest='description_file',
help='A text file containing a CL description in which '
......
......@@ -854,22 +854,6 @@ class _GitDiffCache(_DiffCache):
return scm.GIT.GetOldContents(local_root, path, branch=self._upstream)
def _ParseDiffHeader(line):
"""Searches |line| for diff headers and returns a tuple
(header, old_line, old_size, new_line, new_size), or None if line doesn't
contain a diff header.
This relies on the scm diff output describing each changed code section
with a line of the form
^@@ <old line num>,<old size> <new line num>,<new size> @@$
"""
m = re.match(r'^@@ \-([0-9]+)\,([0-9]+) \+([0-9]+)\,([0-9]+) @@', line)
if m:
return (m.group(0), int(m.group(1)), int(m.group(2)), int(m.group(3)),
int(m.group(4)))
class AffectedFile(object):
"""Representation of a file in a change."""
......@@ -883,7 +867,6 @@ class AffectedFile(object):
self._local_root = repository_root
self._is_directory = None
self._cached_changed_contents = None
self._cached_change_size_in_bytes = None
self._cached_new_contents = None
self._diff_cache = diff_cache
logging.debug('%s(%s)', self.__class__.__name__, self._path)
......@@ -960,9 +943,9 @@ class AffectedFile(object):
line_num = 0
for line in self.GenerateScmDiff().splitlines():
h = _ParseDiffHeader(line)
if h:
line_num = h[3]
m = re.match(r'^@@ [0-9\,\+\-]+ \+([0-9]+)\,[0-9]+ @@', line)
if m:
line_num = int(m.groups(1)[0])
continue
if line.startswith('+') and not line.startswith('++'):
self._cached_changed_contents.append((line_num, line[1:]))
......@@ -970,25 +953,6 @@ class AffectedFile(object):
line_num += 1
return self._cached_changed_contents[:]
def ChangeSizeInBytes(self):
"""Returns a list of tuples (deleted bytes, added bytes) of all changes
in this file.
This relies on the scm diff output describing each changed code section
with a line of the form
^@@ <old line num>,<old size> <new line num>,<new size> @@$
"""
if self._cached_change_size_in_bytes is not None:
return self._cached_change_size_in_bytes[:]
self._cached_change_size_in_bytes = []
for line in self.GenerateScmDiff().splitlines():
h = _ParseDiffHeader(line)
if h:
self._cached_change_size_in_bytes.append((h[2], h[4]))
return self._cached_change_size_in_bytes[:]
def __str__(self):
return self.LocalPath()
......
This diff is collapsed.
This diff is collapsed.
URL: https://github.com/google/pygtrie
Version: 64ee0836f41a59919ecf8a59b0c7e2f7f1b8c5ba
License: Apache 2.0
License File: LICENSE
Description:
This directory contains the Python pygtrie module.
Local Modifications:
None
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment