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

Side by Side Diff: presubmit_support.py

Issue 191002: Change directory to repository root before running CheckSvnModifiedDirectorie... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2009 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 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.3.2' 9 __version__ = '1.3.2'
10 10
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 filter(lambda x: x.IsTextFile(), 676 filter(lambda x: x.IsTextFile(),
677 self.AffectedFiles(include_deletes=False))) 677 self.AffectedFiles(include_deletes=False)))
678 678
679 679
680 class SvnChange(Change): 680 class SvnChange(Change):
681 _AFFECTED_FILES = SvnAffectedFile 681 _AFFECTED_FILES = SvnAffectedFile
682 682
683 def __init__(self, *args, **kwargs): 683 def __init__(self, *args, **kwargs):
684 Change.__init__(self, *args, **kwargs) 684 Change.__init__(self, *args, **kwargs)
685 self.scm = 'svn' 685 self.scm = 'svn'
686 self._changelists = None
687
688 def _GetChangeLists(self):
689 """Get all change lists."""
690 if self._changelists == None:
691 previous_cwd = os.getcwd()
692 os.chdir(self.RepositoryRoot())
693 self._changelists = gcl.GetModifiedFiles()
694 os.chdir(previous_cwd)
695 return self._changelists
686 696
687 def GetAllModifiedFiles(self): 697 def GetAllModifiedFiles(self):
688 """Get all modified files.""" 698 """Get all modified files."""
689 changelists = gcl.GetModifiedFiles() 699 changelists = self._GetChangeLists()
690 all_modified_files = [] 700 all_modified_files = []
691 for cl in changelists.values(): 701 for cl in changelists.values():
692 all_modified_files.extend([f[1] for f in cl]) 702 all_modified_files.extend(
703 [os.path.join(self.RepositoryRoot(), f[1]) for f in cl])
693 return all_modified_files 704 return all_modified_files
694 705
695 def GetModifiedFiles(self): 706 def GetModifiedFiles(self):
696 """Get modified files in the current CL.""" 707 """Get modified files in the current CL."""
697 changelists = gcl.GetModifiedFiles() 708 changelists = self._GetChangeLists()
698 return [f[1] for f in changelists[self.Name()]] 709 return [os.path.join(self.RepositoryRoot(), f[1])
710 for f in changelists[self.Name()]]
699 711
700 712
701 class GitChange(Change): 713 class GitChange(Change):
702 _AFFECTED_FILES = GitAffectedFile 714 _AFFECTED_FILES = GitAffectedFile
703 715
704 def __init__(self, *args, **kwargs): 716 def __init__(self, *args, **kwargs):
705 Change.__init__(self, *args, **kwargs) 717 Change.__init__(self, *args, **kwargs)
706 self.scm = 'git' 718 self.scm = 'git'
707 719
708 720
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 options.commit, 960 options.commit,
949 options.verbose, 961 options.verbose,
950 sys.stdout, 962 sys.stdout,
951 sys.stdin, 963 sys.stdin,
952 options.default_presubmit, 964 options.default_presubmit,
953 options.may_prompt) 965 options.may_prompt)
954 966
955 967
956 if __name__ == '__main__': 968 if __name__ == '__main__':
957 sys.exit(Main(sys.argv)) 969 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698