Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: git_cl.py

Issue 287063002: Revert of use canonical base URL for projects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 datetime 10 import datetime
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 'ERROR: Your diff contains %d commits already in %s.\n' 628 'ERROR: Your diff contains %d commits already in %s.\n'
629 'Run "git log --oneline %s..HEAD" to get a list of commits in ' 629 'Run "git log --oneline %s..HEAD" to get a list of commits in '
630 'the diff. If you are using a custom git flow, you can override' 630 'the diff. If you are using a custom git flow, you can override'
631 ' the reference used for this check with "git config ' 631 ' the reference used for this check with "git config '
632 'gitcl.remotebranch <git-ref>".' % ( 632 'gitcl.remotebranch <git-ref>".' % (
633 len(common_commits), remote_branch, upstream_git_obj)) 633 len(common_commits), remote_branch, upstream_git_obj))
634 return False 634 return False
635 return True 635 return True
636 636
637 def GetGitBaseUrlFromConfig(self): 637 def GetGitBaseUrlFromConfig(self):
638 """Return the configured base URL from branch.<branchname>.canonical-url. 638 """Return the configured base URL from branch.<branchname>.baseurl.
639 639
640 Returns None if it is not set. 640 Returns None if it is not set.
641 """ 641 """
642 branch = self.GetBranch() 642 return RunGit(['config', 'branch.%s.base-url' % self.GetBranch()],
643 url = RunGit(['config', 'branch.%s.canonical-url' % branch], 643 error_ok=True).strip()
644 error_ok=True).strip()
645 if not url:
646 url = RunGit(['config', 'branch.%s.base-url' % branch],
647 error_ok=True).strip()
648 return url
649 644
650 def GetRemoteUrl(self): 645 def GetRemoteUrl(self):
651 """Return the configured remote URL, e.g. 'git://example.org/foo.git/'. 646 """Return the configured remote URL, e.g. 'git://example.org/foo.git/'.
652 647
653 Returns None if there is no remote. 648 Returns None if there is no remote.
654 """ 649 """
655 remote, _ = self.GetRemoteBranch() 650 remote, _ = self.GetRemoteBranch()
656 return RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip() 651 return RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip()
657 652
658 def GetIssue(self): 653 def GetIssue(self):
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 if 'GERRIT_HOST' in keyvals: 1067 if 'GERRIT_HOST' in keyvals:
1073 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) 1068 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
1074 1069
1075 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: 1070 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals:
1076 #should be of the form 1071 #should be of the form
1077 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof 1072 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof
1078 #ORIGIN_URL_CONFIG: http://src.chromium.org/git 1073 #ORIGIN_URL_CONFIG: http://src.chromium.org/git
1079 RunGit(['config', keyvals['PUSH_URL_CONFIG'], 1074 RunGit(['config', keyvals['PUSH_URL_CONFIG'],
1080 keyvals['ORIGIN_URL_CONFIG']]) 1075 keyvals['ORIGIN_URL_CONFIG']])
1081 1076
1082 if 'CANONICAL_URL' in keyvals:
1083 branchref = RunGit(['symbolic-ref', 'HEAD']).strip()
1084 branch = ShortBranchName(branchref)
1085 RunGit(['config', 'branch.%s.canonical-url' % branch,
1086 keyvals['CANONICAL_URL']],
1087 error_ok=False)
1088
1089 1077
1090 def urlretrieve(source, destination): 1078 def urlretrieve(source, destination):
1091 """urllib is broken for SSL connections via a proxy therefore we 1079 """urllib is broken for SSL connections via a proxy therefore we
1092 can't use urllib.urlretrieve().""" 1080 can't use urllib.urlretrieve()."""
1093 with open(destination, 'w') as f: 1081 with open(destination, 'w') as f:
1094 f.write(urllib2.urlopen(source).read()) 1082 f.write(urllib2.urlopen(source).read())
1095 1083
1096 1084
1097 def hasSheBang(fname): 1085 def hasSheBang(fname):
1098 """Checks fname is a #! script.""" 1086 """Checks fname is a #! script."""
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2600 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2613 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2601 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2614 2602
2615 2603
2616 if __name__ == '__main__': 2604 if __name__ == '__main__':
2617 # These affect sys.stdout so do it outside of main() to simplify mocks in 2605 # These affect sys.stdout so do it outside of main() to simplify mocks in
2618 # unit testing. 2606 # unit testing.
2619 fix_encoding.fix_encoding() 2607 fix_encoding.fix_encoding()
2620 colorama.init() 2608 colorama.init()
2621 sys.exit(main(sys.argv[1:])) 2609 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698