| OLD | NEW |
| 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 """Wrapper script around Rietveld's upload.py that groups files into | 6 """Wrapper script around Rietveld's upload.py that groups files into |
| 7 changelists.""" | 7 changelists.""" |
| 8 | 8 |
| 9 import getpass | 9 import getpass |
| 10 import os | 10 import os |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 if not editor: | 673 if not editor: |
| 674 if sys.platform.startswith("win"): | 674 if sys.platform.startswith("win"): |
| 675 editor = "notepad" | 675 editor = "notepad" |
| 676 else: | 676 else: |
| 677 editor = "vi" | 677 editor = "vi" |
| 678 | 678 |
| 679 return editor | 679 return editor |
| 680 | 680 |
| 681 | 681 |
| 682 def GenerateDiff(files, root=None): | 682 def GenerateDiff(files, root=None): |
| 683 """Returns a string containing the diff for the given file list. | 683 return SVN.GenerateDiff(files, root=root) |
| 684 | |
| 685 The files in the list should either be absolute paths or relative to the | |
| 686 given root. If no root directory is provided, the repository root will be | |
| 687 used. | |
| 688 """ | |
| 689 previous_cwd = os.getcwd() | |
| 690 if root is None: | |
| 691 os.chdir(GetRepositoryRoot()) | |
| 692 else: | |
| 693 os.chdir(root) | |
| 694 | |
| 695 # If the user specified a custom diff command in their svn config file, | |
| 696 # then it'll be used when we do svn diff, which we don't want to happen | |
| 697 # since we want the unified diff. Using --diff-cmd=diff doesn't always | |
| 698 # work, since they can have another diff executable in their path that | |
| 699 # gives different line endings. So we use a bogus temp directory as the | |
| 700 # config directory, which gets around these problems. | |
| 701 bogus_dir = tempfile.mkdtemp() | |
| 702 diff = [] | |
| 703 for filename in files: | |
| 704 # TODO(maruel): Use SVN.DiffItem(). | |
| 705 # Use svn info output instead of os.path.isdir because the latter fails | |
| 706 # when the file is deleted. | |
| 707 if SVN.CaptureInfo(filename).get('Node Kind') == 'directory': | |
| 708 continue | |
| 709 output = RunShell(["svn", "diff", "--config-dir", bogus_dir, filename]) | |
| 710 if output: | |
| 711 diff.append(output) | |
| 712 elif SVN.IsMoved(filename): | |
| 713 # svn diff on a mv/cp'd file outputs nothing. | |
| 714 # We put in an empty Index entry so upload.py knows about them. | |
| 715 diff.append("\nIndex: %s\n" % filename) | |
| 716 else: | |
| 717 # The file is not modified anymore. It should be removed from the set. | |
| 718 pass | |
| 719 shutil.rmtree(bogus_dir) | |
| 720 os.chdir(previous_cwd) | |
| 721 return "".join(diff) | |
| 722 | |
| 723 | 684 |
| 724 | 685 |
| 725 def OptionallyDoPresubmitChecks(change_info, committing, args): | 686 def OptionallyDoPresubmitChecks(change_info, committing, args): |
| 726 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): | 687 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): |
| 727 return True | 688 return True |
| 728 return DoPresubmitChecks(change_info, committing, True) | 689 return DoPresubmitChecks(change_info, committing, True) |
| 729 | 690 |
| 730 | 691 |
| 731 def UploadCL(change_info, args): | 692 def UploadCL(change_info, args): |
| 732 if not change_info.GetFiles(): | 693 if not change_info.GetFiles(): |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 return 0 | 1241 return 0 |
| 1281 args =["svn", command] | 1242 args =["svn", command] |
| 1282 root = GetRepositoryRoot() | 1243 root = GetRepositoryRoot() |
| 1283 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) | 1244 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) |
| 1284 RunShell(args, True) | 1245 RunShell(args, True) |
| 1285 return 0 | 1246 return 0 |
| 1286 | 1247 |
| 1287 | 1248 |
| 1288 if __name__ == "__main__": | 1249 if __name__ == "__main__": |
| 1289 sys.exit(main()) | 1250 sys.exit(main()) |
| OLD | NEW |