| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import logging | 10 import logging |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 self.SetPatchset(0) | 488 self.SetPatchset(0) |
| 489 self.has_issue = False | 489 self.has_issue = False |
| 490 | 490 |
| 491 def GetChange(self, upstream_branch, author): | 491 def GetChange(self, upstream_branch, author): |
| 492 root = RunCommand(['git', 'rev-parse', '--show-cdup']).strip() or '.' | 492 root = RunCommand(['git', 'rev-parse', '--show-cdup']).strip() or '.' |
| 493 absroot = os.path.abspath(root) | 493 absroot = os.path.abspath(root) |
| 494 | 494 |
| 495 # We use the sha1 of HEAD as a name of this change. | 495 # We use the sha1 of HEAD as a name of this change. |
| 496 name = RunCommand(['git', 'rev-parse', 'HEAD']).strip() | 496 name = RunCommand(['git', 'rev-parse', 'HEAD']).strip() |
| 497 # Need to pass a relative path for msysgit. | 497 # Need to pass a relative path for msysgit. |
| 498 files = scm.GIT.CaptureStatus([root], upstream_branch) | 498 try: |
| 499 files = scm.GIT.CaptureStatus([root], upstream_branch) |
| 500 except subprocess2.CalledProcessError: |
| 501 DieWithError( |
| 502 ('\nFailed to diff against upstream branch %s!\n\n' |
| 503 'This branch probably doesn\'t exist anymore. To reset the\n' |
| 504 'tracking branch, please run\n' |
| 505 ' git branch --set-upstream %s trunk\n' |
| 506 'replacing trunk with origin/master or the relevant branch') % |
| 507 (upstream_branch, self.GetBranch())) |
| 499 | 508 |
| 500 issue = ConvertToInteger(self.GetIssue()) | 509 issue = ConvertToInteger(self.GetIssue()) |
| 501 patchset = ConvertToInteger(self.GetPatchset()) | 510 patchset = ConvertToInteger(self.GetPatchset()) |
| 502 if issue: | 511 if issue: |
| 503 description = self.GetDescription() | 512 description = self.GetDescription() |
| 504 else: | 513 else: |
| 505 # If the change was never uploaded, use the log messages of all commits | 514 # If the change was never uploaded, use the log messages of all commits |
| 506 # up to the branch point, as git cl upload will prefill the description | 515 # up to the branch point, as git cl upload will prefill the description |
| 507 # with these log messages. | 516 # with these log messages. |
| 508 description = RunCommand(['git', 'log', '--pretty=format:%s%n%n%b', | 517 description = RunCommand(['git', 'log', '--pretty=format:%s%n%n%b', |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1440 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1432 | 1441 |
| 1433 # Not a known command. Default to help. | 1442 # Not a known command. Default to help. |
| 1434 GenUsage(parser, 'help') | 1443 GenUsage(parser, 'help') |
| 1435 return CMDhelp(parser, argv) | 1444 return CMDhelp(parser, argv) |
| 1436 | 1445 |
| 1437 | 1446 |
| 1438 if __name__ == '__main__': | 1447 if __name__ == '__main__': |
| 1439 fix_encoding.fix_encoding() | 1448 fix_encoding.fix_encoding() |
| 1440 sys.exit(main(sys.argv[1:])) | 1449 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |