| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 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 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 import subcommand | 39 import subcommand |
| 40 import subprocess2 | 40 import subprocess2 |
| 41 import watchlists | 41 import watchlists |
| 42 import owners_finder | 42 import owners_finder |
| 43 | 43 |
| 44 __version__ = '1.0' | 44 __version__ = '1.0' |
| 45 | 45 |
| 46 DEFAULT_SERVER = 'https://codereview.appspot.com' | 46 DEFAULT_SERVER = 'https://codereview.appspot.com' |
| 47 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' | 47 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' |
| 48 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' | 48 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' |
| 49 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 49 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' |
| 50 CHANGE_ID = 'Change-Id:' | 50 CHANGE_ID = 'Change-Id:' |
| 51 | 51 |
| 52 # Shortcut since it quickly becomes redundant. | 52 # Shortcut since it quickly becomes redundant. |
| 53 Fore = colorama.Fore | 53 Fore = colorama.Fore |
| 54 | 54 |
| 55 # Initialized in main() | 55 # Initialized in main() |
| 56 settings = None | 56 settings = None |
| 57 | 57 |
| 58 | 58 |
| 59 def DieWithError(message): | 59 def DieWithError(message): |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 self.branch = ShortBranchName(self.branchref) | 466 self.branch = ShortBranchName(self.branchref) |
| 467 return self.branch | 467 return self.branch |
| 468 | 468 |
| 469 def GetBranchRef(self): | 469 def GetBranchRef(self): |
| 470 """Returns the full branch name, e.g. 'refs/heads/master'.""" | 470 """Returns the full branch name, e.g. 'refs/heads/master'.""" |
| 471 self.GetBranch() # Poke the lazy loader. | 471 self.GetBranch() # Poke the lazy loader. |
| 472 return self.branchref | 472 return self.branchref |
| 473 | 473 |
| 474 @staticmethod | 474 @staticmethod |
| 475 def FetchUpstreamTuple(branch): | 475 def FetchUpstreamTuple(branch): |
| 476 """Returns a tuple containg remote and remote ref, | 476 """Returns a tuple containing remote and remote ref, |
| 477 e.g. 'origin', 'refs/heads/master' | 477 e.g. 'origin', 'refs/heads/master' |
| 478 """ | 478 """ |
| 479 remote = '.' | 479 remote = '.' |
| 480 upstream_branch = RunGit(['config', 'branch.%s.merge' % branch], | 480 upstream_branch = RunGit(['config', 'branch.%s.merge' % branch], |
| 481 error_ok=True).strip() | 481 error_ok=True).strip() |
| 482 if upstream_branch: | 482 if upstream_branch: |
| 483 remote = RunGit(['config', 'branch.%s.remote' % branch]).strip() | 483 remote = RunGit(['config', 'branch.%s.remote' % branch]).strip() |
| 484 else: | 484 else: |
| 485 upstream_branch = RunGit(['config', 'rietveld.upstream-branch'], | 485 upstream_branch = RunGit(['config', 'rietveld.upstream-branch'], |
| 486 error_ok=True).strip() | 486 error_ok=True).strip() |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 root = '.' | 721 root = '.' |
| 722 absroot = os.path.abspath(root) | 722 absroot = os.path.abspath(root) |
| 723 | 723 |
| 724 # We use the sha1 of HEAD as a name of this change. | 724 # We use the sha1 of HEAD as a name of this change. |
| 725 name = RunCommand(['git', 'rev-parse', 'HEAD'], env=env).strip() | 725 name = RunCommand(['git', 'rev-parse', 'HEAD'], env=env).strip() |
| 726 # Need to pass a relative path for msysgit. | 726 # Need to pass a relative path for msysgit. |
| 727 try: | 727 try: |
| 728 files = scm.GIT.CaptureStatus([root], '.', upstream_branch) | 728 files = scm.GIT.CaptureStatus([root], '.', upstream_branch) |
| 729 except subprocess2.CalledProcessError: | 729 except subprocess2.CalledProcessError: |
| 730 DieWithError( | 730 DieWithError( |
| 731 ('\nFailed to diff against upstream branch %s!\n\n' | 731 ('\nFailed to diff against upstream branch %s\n\n' |
| 732 'This branch probably doesn\'t exist anymore. To reset the\n' | 732 'This branch probably doesn\'t exist anymore. To reset the\n' |
| 733 'tracking branch, please run\n' | 733 'tracking branch, please run\n' |
| 734 ' git branch --set-upstream %s trunk\n' | 734 ' git branch --set-upstream %s trunk\n' |
| 735 'replacing trunk with origin/master or the relevant branch') % | 735 'replacing trunk with origin/master or the relevant branch') % |
| 736 (upstream_branch, self.GetBranch())) | 736 (upstream_branch, self.GetBranch())) |
| 737 | 737 |
| 738 issue = self.GetIssue() | 738 issue = self.GetIssue() |
| 739 patchset = self.GetPatchset() | 739 patchset = self.GetPatchset() |
| 740 if issue: | 740 if issue: |
| 741 description = self.GetDescription() | 741 description = self.GetDescription() |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2318 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2318 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2319 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2319 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2320 | 2320 |
| 2321 | 2321 |
| 2322 if __name__ == '__main__': | 2322 if __name__ == '__main__': |
| 2323 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2323 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2324 # unit testing. | 2324 # unit testing. |
| 2325 fix_encoding.fix_encoding() | 2325 fix_encoding.fix_encoding() |
| 2326 colorama.init() | 2326 colorama.init() |
| 2327 sys.exit(main(sys.argv[1:])) | 2327 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |