Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: patch.py

Issue 15898005: presubmit: Call 'git diff' once per change instead of once per file (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix language in git_cl.py Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Utility functions to handle patches.""" 5 """Utility functions to handle patches."""
6 6
7 import posixpath 7 import posixpath
8 import os 8 import os
9 import re 9 import re
10 10
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 def mangle(self, string): 312 def mangle(self, string):
313 """Mangle a file path.""" 313 """Mangle a file path."""
314 return '/'.join(string.replace('\\', '/').split('/')[self.patchlevel:]) 314 return '/'.join(string.replace('\\', '/').split('/')[self.patchlevel:])
315 315
316 def _verify_git_header(self): 316 def _verify_git_header(self):
317 """Sanity checks the header. 317 """Sanity checks the header.
318 318
319 Expects the following format: 319 Expects the following format:
320 320
321 <garbagge> 321 <garbage>
322 diff --git (|a/)<filename> (|b/)<filename> 322 diff --git (|a/)<filename> (|b/)<filename>
323 <similarity> 323 <similarity>
324 <filemode changes> 324 <filemode changes>
325 <index> 325 <index>
326 <copy|rename from> 326 <copy|rename from>
327 <copy|rename to> 327 <copy|rename to>
328 --- <filename> 328 --- <filename>
329 +++ <filename> 329 +++ <filename>
330 330
331 Everything is optional except the diff --git line. 331 Everything is optional except the diff --git line.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 def __iter__(self): 534 def __iter__(self):
535 for patch in self.patches: 535 for patch in self.patches:
536 yield patch 536 yield patch
537 537
538 def __getitem__(self, key): 538 def __getitem__(self, key):
539 return self.patches[key] 539 return self.patches[key]
540 540
541 @property 541 @property
542 def filenames(self): 542 def filenames(self):
543 return [p.filename for p in self.patches] 543 return [p.filename for p in self.patches]
OLDNEW
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698