Commit 3671a6a2 authored by Jamie Madill's avatar Jamie Madill Committed by Commit Bot

Revert "git-cl: Add diff lines of context setting."

This reverts commit 812ac228.

Reason for revert: The fix was not sufficient to solve the git cl
format difference between 'git cl format' and 'git cl format --full'.
Looks like we'll need a different solution.

Original change's description:
> git-cl: Add diff lines of context setting.
> 
> Clients using some Clang-Format options can run into bugs when using
> 0 lines of context. AlignConsecutiveAssignments in particular is picky
> and behaves differently with 0 lines of context.
> 
> This behaviour lead to 'git cl format' behaving differently from
> 'git cl format --full'. That could also break presubmit format checks.
> Using >0 lines of context for 'git diff' fixes the inconsistency.
> 
> Add a setting 'DIFF_LINES_OF_CONTEXT' that can be controlled via
> codereview.settings. Defaults to zero to preserve the old behaviour.
> The setting allows the client to control the number of lines of context
> to use when running 'git cl format'.
> 
> Bug: angleproject:4003
> Change-Id: Ied2ebf23df4c41ba19bfbd5b8ddf526b56a20b31
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1864309
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Jamie Madill <jmadill@chromium.org>

TBR=agable@chromium.org,ehmaldonado@chromium.org,jmadill@chromium.org

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

Bug: angleproject:4003
Change-Id: Ib6b70969509a1e5446922d488f11d13a0c59c536
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1877003Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent ad557c41
...@@ -689,8 +689,7 @@ def _ComputeDiffLineRanges(files, upstream_commit): ...@@ -689,8 +689,7 @@ def _ComputeDiffLineRanges(files, upstream_commit):
return {} return {}
# Take the git diff and find the line ranges where there are changes. # Take the git diff and find the line ranges where there are changes.
lines = '-U%s' % settings.GetDiffLinesOfContext() diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, files, allow_prefix=True)
diff_cmd = BuildGitDiffCmd(lines, upstream_commit, files, allow_prefix=True)
diff_output = RunGit(diff_cmd) diff_output = RunGit(diff_cmd)
pattern = r'(?:^diff --git a/(?:.*) b/(.*))|(?:^@@.*\+(.*) @@)' pattern = r'(?:^diff --git a/(?:.*) b/(.*))|(?:^@@.*\+(.*) @@)'
...@@ -939,10 +938,6 @@ class Settings(object): ...@@ -939,10 +938,6 @@ class Settings(object):
return (self._GetConfig('rietveld.cpplint-ignore-regex', error_ok=True) or return (self._GetConfig('rietveld.cpplint-ignore-regex', error_ok=True) or
DEFAULT_LINT_IGNORE_REGEX) DEFAULT_LINT_IGNORE_REGEX)
def GetDiffLinesOfContext(self):
return (self._GetConfig('rietveld.diff-lines-of-context', error_ok=True) or
"0")
def _GetConfig(self, param, **kwargs): def _GetConfig(self, param, **kwargs):
self.LazyUpdateIfNeeded() self.LazyUpdateIfNeeded()
return RunGit(['config', param], **kwargs).strip() return RunGit(['config', param], **kwargs).strip()
...@@ -3154,8 +3149,6 @@ def LoadCodereviewSettingsFromFile(fileobj): ...@@ -3154,8 +3149,6 @@ def LoadCodereviewSettingsFromFile(fileobj):
SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True) SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True)
SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK', SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK',
unset_error_ok=True) unset_error_ok=True)
SetProperty(
'diff-lines-of-context', 'DIFF_LINES_OF_CONTEXT', unset_error_ok=True)
if 'GERRIT_HOST' in keyvals: if 'GERRIT_HOST' in keyvals:
RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
...@@ -5189,8 +5182,7 @@ def CMDformat(parser, args): ...@@ -5189,8 +5182,7 @@ def CMDformat(parser, args):
if not opts.dry_run and not opts.diff: if not opts.dry_run and not opts.diff:
cmd.append('-i') cmd.append('-i')
lines = '-U%s' % settings.GetDiffLinesOfContext() diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, clang_diff_files)
diff_cmd = BuildGitDiffCmd(lines, upstream_commit, clang_diff_files)
diff_output = RunGit(diff_cmd) diff_output = RunGit(diff_cmd)
stdout = RunCommand(cmd, stdin=diff_output, cwd=top_dir, env=env) stdout = RunCommand(cmd, stdin=diff_output, cwd=top_dir, env=env)
......
...@@ -724,8 +724,6 @@ class TestGitCl(TestCase): ...@@ -724,8 +724,6 @@ class TestGitCl(TestCase):
CERR1), CERR1),
((['git', 'config', '--unset-all', 'rietveld.run-post-upload-hook'],), ((['git', 'config', '--unset-all', 'rietveld.run-post-upload-hook'],),
CERR1), CERR1),
((['git', 'config', '--unset-all', 'rietveld.diff-lines-of-context'],),
CERR1),
((['git', 'config', 'gerrit.host', 'true'],), ''), ((['git', 'config', 'gerrit.host', 'true'],), ''),
] ]
self.assertIsNone(git_cl.LoadCodereviewSettingsFromFile(codereview_file)) self.assertIsNone(git_cl.LoadCodereviewSettingsFromFile(codereview_file))
......
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