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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 | 305 |
306 def ShortBranchName(branch): | 306 def ShortBranchName(branch): |
307 """Convert a name like 'refs/heads/foo' to just 'foo'.""" | 307 """Convert a name like 'refs/heads/foo' to just 'foo'.""" |
308 return branch.replace('refs/heads/', '') | 308 return branch.replace('refs/heads/', '') |
309 | 309 |
310 | 310 |
311 class Changelist(object): | 311 class Changelist(object): |
312 def __init__(self, branchref=None): | 312 def __init__(self, branchref=None): |
313 # Poke settings so we get the "configure your server" message if necessary. | 313 # Poke settings so we get the "configure your server" message if necessary. |
| 314 global settings |
| 315 if not settings: |
| 316 # Happens when git_cl.py is used as a utility library. |
| 317 settings = Settings() |
314 settings.GetDefaultServerUrl() | 318 settings.GetDefaultServerUrl() |
315 self.branchref = branchref | 319 self.branchref = branchref |
316 if self.branchref: | 320 if self.branchref: |
317 self.branch = ShortBranchName(self.branchref) | 321 self.branch = ShortBranchName(self.branchref) |
318 else: | 322 else: |
319 self.branch = None | 323 self.branch = None |
320 self.rietveld_server = None | 324 self.rietveld_server = None |
321 self.upstream_branch = None | 325 self.upstream_branch = None |
322 self.has_issue = False | 326 self.has_issue = False |
323 self.issue = None | 327 self.issue = None |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1416 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1413 | 1417 |
1414 # Not a known command. Default to help. | 1418 # Not a known command. Default to help. |
1415 GenUsage(parser, 'help') | 1419 GenUsage(parser, 'help') |
1416 return CMDhelp(parser, argv) | 1420 return CMDhelp(parser, argv) |
1417 | 1421 |
1418 | 1422 |
1419 if __name__ == '__main__': | 1423 if __name__ == '__main__': |
1420 fix_encoding.fix_encoding() | 1424 fix_encoding.fix_encoding() |
1421 sys.exit(main(sys.argv[1:])) | 1425 sys.exit(main(sys.argv[1:])) |
OLD | NEW |