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

Side by Side Diff: git_cl.py

Issue 224703002: Use get_or_create_merge_base in git-cl-upload to correctly deal with rebased (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix tests' Created 6 years, 8 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 17 matching lines...) Expand all
28 except ImportError: 28 except ImportError:
29 pass 29 pass
30 30
31 31
32 from third_party import colorama 32 from third_party import colorama
33 from third_party import upload 33 from third_party import upload
34 import breakpad # pylint: disable=W0611 34 import breakpad # pylint: disable=W0611
35 import clang_format 35 import clang_format
36 import fix_encoding 36 import fix_encoding
37 import gclient_utils 37 import gclient_utils
38 import git_common
39 import owners_finder
38 import presubmit_support 40 import presubmit_support
39 import rietveld 41 import rietveld
40 import scm 42 import scm
41 import subcommand 43 import subcommand
42 import subprocess2 44 import subprocess2
43 import watchlists 45 import watchlists
44 import owners_finder
45 46
46 __version__ = '1.0' 47 __version__ = '1.0'
47 48
48 DEFAULT_SERVER = 'https://codereview.appspot.com' 49 DEFAULT_SERVER = 'https://codereview.appspot.com'
49 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' 50 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
50 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' 51 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
51 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' 52 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit'
52 CHANGE_ID = 'Change-Id:' 53 CHANGE_ID = 'Change-Id:'
53 54
54 # Valid extensions for files we want to lint. 55 # Valid extensions for files we want to lint.
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 else: 545 else:
545 DieWithError("""Unable to determine default branch to diff against. 546 DieWithError("""Unable to determine default branch to diff against.
546 Either pass complete "git diff"-style arguments, like 547 Either pass complete "git diff"-style arguments, like
547 git cl upload origin/master 548 git cl upload origin/master
548 or verify this branch is set up to track another (via the --track argument to 549 or verify this branch is set up to track another (via the --track argument to
549 "git checkout -b ...").""") 550 "git checkout -b ...").""")
550 551
551 return remote, upstream_branch 552 return remote, upstream_branch
552 553
553 def GetCommonAncestorWithUpstream(self): 554 def GetCommonAncestorWithUpstream(self):
554 return RunGit(['merge-base', self.GetUpstreamBranch(), 'HEAD']).strip() 555 return git_common.get_or_create_merge_base(self.GetBranch(),
556 self.GetUpstreamBranch())
555 557
556 def GetUpstreamBranch(self): 558 def GetUpstreamBranch(self):
557 if self.upstream_branch is None: 559 if self.upstream_branch is None:
558 remote, upstream_branch = self.FetchUpstreamTuple(self.GetBranch()) 560 remote, upstream_branch = self.FetchUpstreamTuple(self.GetBranch())
559 if remote is not '.': 561 if remote is not '.':
560 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote) 562 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote)
561 self.upstream_branch = upstream_branch 563 self.upstream_branch = upstream_branch
562 return self.upstream_branch 564 return self.upstream_branch
563 565
564 def GetRemoteBranch(self): 566 def GetRemoteBranch(self):
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 group.add_option( 2150 group.add_option(
2149 "-b", "--bot", action="append", 2151 "-b", "--bot", action="append",
2150 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " 2152 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple "
2151 "times to specify multiple builders. ex: " 2153 "times to specify multiple builders. ex: "
2152 "'-bwin_rel:ui_tests,webkit_unit_tests -bwin_layout'. See " 2154 "'-bwin_rel:ui_tests,webkit_unit_tests -bwin_layout'. See "
2153 "the try server waterfall for the builders name and the tests " 2155 "the try server waterfall for the builders name and the tests "
2154 "available. Can also be used to specify gtest_filter, e.g. " 2156 "available. Can also be used to specify gtest_filter, e.g. "
2155 "-bwin_rel:base_unittests:ValuesTest.*Value")) 2157 "-bwin_rel:base_unittests:ValuesTest.*Value"))
2156 group.add_option( 2158 group.add_option(
2157 "-m", "--master", default='', 2159 "-m", "--master", default='',
2158 help=("Specify a try master where to run the tries.")) 2160 help=("Specify a try master where to run the tries."))
2159 group.add_option( 2161 group.add_option(
2160 "-r", "--revision", 2162 "-r", "--revision",
2161 help="Revision to use for the try job; default: the " 2163 help="Revision to use for the try job; default: the "
2162 "revision will be determined by the try server; see " 2164 "revision will be determined by the try server; see "
2163 "its waterfall for more info") 2165 "its waterfall for more info")
2164 group.add_option( 2166 group.add_option(
2165 "-c", "--clobber", action="store_true", default=False, 2167 "-c", "--clobber", action="store_true", default=False,
2166 help="Force a clobber before building; e.g. don't do an " 2168 help="Force a clobber before building; e.g. don't do an "
2167 "incremental build") 2169 "incremental build")
2168 group.add_option( 2170 group.add_option(
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2542 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2541 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2543 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2542 2544
2543 2545
2544 if __name__ == '__main__': 2546 if __name__ == '__main__':
2545 # These affect sys.stdout so do it outside of main() to simplify mocks in 2547 # These affect sys.stdout so do it outside of main() to simplify mocks in
2546 # unit testing. 2548 # unit testing.
2547 fix_encoding.fix_encoding() 2549 fix_encoding.fix_encoding()
2548 colorama.init() 2550 colorama.init()
2549 sys.exit(main(sys.argv[1:])) 2551 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