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

Side by Side Diff: git_cl.py

Issue 967453004: Stop defaulting unrecognized branches to master except for handful of special refs (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Create an alias map Created 5 years, 9 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
« 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 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 import subprocess2 49 import subprocess2
50 import watchlists 50 import watchlists
51 51
52 __version__ = '1.0' 52 __version__ = '1.0'
53 53
54 DEFAULT_SERVER = 'https://codereview.appspot.com' 54 DEFAULT_SERVER = 'https://codereview.appspot.com'
55 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' 55 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
56 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' 56 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
57 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' 57 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit'
58 CHANGE_ID = 'Change-Id:' 58 CHANGE_ID = 'Change-Id:'
59 REFS_THAT_ALIAS_TO_OTHER_REFS = {
60 'refs/remotes/origin/lkgr': 'refs/remotes/origin/master',
61 'refs/remotes/origin/lkcr': 'refs/remotes/origin/master',
62 }
59 63
60 # Valid extensions for files we want to lint. 64 # Valid extensions for files we want to lint.
61 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" 65 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
62 DEFAULT_LINT_IGNORE_REGEX = r"$^" 66 DEFAULT_LINT_IGNORE_REGEX = r"$^"
63 67
64 # Shortcut since it quickly becomes redundant. 68 # Shortcut since it quickly becomes redundant.
65 Fore = colorama.Fore 69 Fore = colorama.Fore
66 70
67 # Initialized in main() 71 # Initialized in main()
68 settings = None 72 settings = None
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 ) 1787 )
1784 match = None 1788 match = None
1785 for regex, replacement in prefix_replacements: 1789 for regex, replacement in prefix_replacements:
1786 match = re.search(regex, target_branch) 1790 match = re.search(regex, target_branch)
1787 if match: 1791 if match:
1788 remote_branch = target_branch.replace(match.group(0), replacement) 1792 remote_branch = target_branch.replace(match.group(0), replacement)
1789 break 1793 break
1790 if not match: 1794 if not match:
1791 # This is a branch path but not one we recognize; use as-is. 1795 # This is a branch path but not one we recognize; use as-is.
1792 remote_branch = target_branch 1796 remote_branch = target_branch
1793 elif (not remote_branch.startswith('refs/remotes/branch-heads') and 1797 elif remote_branch in REFS_THAT_ALIAS_TO_OTHER_REFS:
1794 not remote_branch.startswith('refs/remotes/%s/refs' % remote)): 1798 # Handle the refs that need to land in different refs.
1795 # Default to master for refs that are not branches. 1799 remote_branch = REFS_THAT_ALIAS_TO_OTHER_REFS[remote_branch]
1796 remote_branch = 'refs/remotes/%s/master' % remote
1797 1800
1798 # Create the true path to the remote branch. 1801 # Create the true path to the remote branch.
1799 # Does the following translation: 1802 # Does the following translation:
1800 # * refs/remotes/origin/refs/diff/test -> refs/diff/test 1803 # * refs/remotes/origin/refs/diff/test -> refs/diff/test
1801 # * refs/remotes/origin/master -> refs/heads/master 1804 # * refs/remotes/origin/master -> refs/heads/master
1802 # * refs/remotes/branch-heads/test -> refs/branch-heads/test 1805 # * refs/remotes/branch-heads/test -> refs/branch-heads/test
1803 if remote_branch.startswith('refs/remotes/%s/refs/' % remote): 1806 if remote_branch.startswith('refs/remotes/%s/refs/' % remote):
1804 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '') 1807 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, '')
1805 elif remote_branch.startswith('refs/remotes/%s/' % remote): 1808 elif remote_branch.startswith('refs/remotes/%s/' % remote):
1806 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote, 1809 remote_branch = remote_branch.replace('refs/remotes/%s/' % remote,
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 if __name__ == '__main__': 3097 if __name__ == '__main__':
3095 # These affect sys.stdout so do it outside of main() to simplify mocks in 3098 # These affect sys.stdout so do it outside of main() to simplify mocks in
3096 # unit testing. 3099 # unit testing.
3097 fix_encoding.fix_encoding() 3100 fix_encoding.fix_encoding()
3098 colorama.init() 3101 colorama.init()
3099 try: 3102 try:
3100 sys.exit(main(sys.argv[1:])) 3103 sys.exit(main(sys.argv[1:]))
3101 except KeyboardInterrupt: 3104 except KeyboardInterrupt:
3102 sys.stderr.write('interrupted\n') 3105 sys.stderr.write('interrupted\n')
3103 sys.exit(1) 3106 sys.exit(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