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 import logging | 10 import logging |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 remote = self.FetchUpstreamTuple()[0] | 390 remote = self.FetchUpstreamTuple()[0] |
391 if remote == '.': | 391 if remote == '.': |
392 return None | 392 return None |
393 return RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip() | 393 return RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip() |
394 | 394 |
395 def GetIssue(self): | 395 def GetIssue(self): |
396 if not self.has_issue: | 396 if not self.has_issue: |
397 issue = RunGit(['config', self._IssueSetting()], error_ok=True).strip() | 397 issue = RunGit(['config', self._IssueSetting()], error_ok=True).strip() |
398 if issue: | 398 if issue: |
399 self.issue = issue | 399 self.issue = issue |
400 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit( | |
401 ['config', self._RietveldServer()], error_ok=True).strip()) | |
402 else: | 400 else: |
403 self.issue = None | 401 self.issue = None |
404 if not self.rietveld_server: | |
405 self.rietveld_server = settings.GetDefaultServerUrl() | |
406 self.has_issue = True | 402 self.has_issue = True |
407 return self.issue | 403 return self.issue |
408 | 404 |
409 def GetRietveldServer(self): | 405 def GetRietveldServer(self): |
410 self.GetIssue() | 406 if not self.rietveld_server: |
| 407 # If we're on a branch then get the server potentially associated |
| 408 # with that branch. |
| 409 if self.GetIssue(): |
| 410 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit( |
| 411 ['config', self._RietveldServer()], error_ok=True).strip()) |
| 412 if not self.rietveld_server: |
| 413 self.rietveld_server = settings.GetDefaultServerUrl() |
411 return self.rietveld_server | 414 return self.rietveld_server |
412 | 415 |
413 def GetIssueURL(self): | 416 def GetIssueURL(self): |
414 """Get the URL for a particular issue.""" | 417 """Get the URL for a particular issue.""" |
415 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) | 418 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) |
416 | 419 |
417 def GetDescription(self, pretty=False): | 420 def GetDescription(self, pretty=False): |
418 if not self.has_description: | 421 if not self.has_description: |
419 if self.GetIssue(): | 422 if self.GetIssue(): |
420 issue = int(self.GetIssue()) | 423 issue = int(self.GetIssue()) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if e.code == 403: | 560 if e.code == 403: |
558 DieWithError( | 561 DieWithError( |
559 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' | 562 ('Access denied to issue %s. Maybe the patchset %s doesn\'t ' |
560 'match?') % (self.GetIssue(), self.GetPatchset())) | 563 'match?') % (self.GetIssue(), self.GetPatchset())) |
561 raise | 564 raise |
562 | 565 |
563 def RpcServer(self): | 566 def RpcServer(self): |
564 """Returns an upload.RpcServer() to access this review's rietveld instance. | 567 """Returns an upload.RpcServer() to access this review's rietveld instance. |
565 """ | 568 """ |
566 if not self._rpc_server: | 569 if not self._rpc_server: |
567 self.GetIssue() | 570 self._rpc_server = rietveld.Rietveld(self.GetRietveldServer(), |
568 self._rpc_server = rietveld.Rietveld(self.rietveld_server, None, None) | 571 None, None) |
569 return self._rpc_server | 572 return self._rpc_server |
570 | 573 |
571 def _IssueSetting(self): | 574 def _IssueSetting(self): |
572 """Return the git setting that stores this change's issue.""" | 575 """Return the git setting that stores this change's issue.""" |
573 return 'branch.%s.rietveldissue' % self.GetBranch() | 576 return 'branch.%s.rietveldissue' % self.GetBranch() |
574 | 577 |
575 def _PatchsetSetting(self): | 578 def _PatchsetSetting(self): |
576 """Return the git setting that stores this change's most recent patchset.""" | 579 """Return the git setting that stores this change's most recent patchset.""" |
577 return 'branch.%s.rietveldpatchset' % self.GetBranch() | 580 return 'branch.%s.rietveldpatchset' % self.GetBranch() |
578 | 581 |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1473 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1471 | 1474 |
1472 # Not a known command. Default to help. | 1475 # Not a known command. Default to help. |
1473 GenUsage(parser, 'help') | 1476 GenUsage(parser, 'help') |
1474 return CMDhelp(parser, argv) | 1477 return CMDhelp(parser, argv) |
1475 | 1478 |
1476 | 1479 |
1477 if __name__ == '__main__': | 1480 if __name__ == '__main__': |
1478 fix_encoding.fix_encoding() | 1481 fix_encoding.fix_encoding() |
1479 sys.exit(main(sys.argv[1:])) | 1482 sys.exit(main(sys.argv[1:])) |
OLD | NEW |