Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 09938db2ce332b2c621bc7db303a22b6b8b913fb..f9107065157619af0c630aa6fd16a2ee917a6f31 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -3758,8 +3758,8 @@ def IsSubmoduleMergeCommit(ref): |
| return RunGit(cmd) != '' |
| -def SendUpstream(parser, args, cmd): |
| - """Common code for CMDland and CmdDCommit |
| +def SendUpstream(parser, args): |
| + """Common code for CMDland |
| In case of Gerrit, uses Gerrit REST api to "submit" the issue, which pushes |
| upstream and closes the issue automatically and atomically. |
| @@ -3767,7 +3767,7 @@ def SendUpstream(parser, args, cmd): |
| Otherwise (in case of Rietveld): |
| Squashes branch into a single commit. |
| Updates changelog with metadata (e.g. pointer to review). |
| - Pushes/dcommits the code upstream. |
| + Pushes the code upstream. |
| Updates review and closes. |
| """ |
| parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', |
| @@ -3820,7 +3820,7 @@ def SendUpstream(parser, args, cmd): |
| print(' Current parent: %r' % upstream_branch) |
| return 1 |
| - if not args or cmd == 'land': |
| + if not args: |
| # Default to merging against our best guess of the upstream branch. |
| args = [cl.GetUpstreamBranch()] |
| @@ -3832,7 +3832,7 @@ def SendUpstream(parser, args, cmd): |
| base_branch = args[0] |
| base_has_submodules = IsSubmoduleMergeCommit(base_branch) |
| - if git_common.is_dirty_git_tree(cmd): |
| + if git_common.is_dirty_git_tree(cmd='land'): |
| return 1 |
| # This rev-list syntax means "show all commits not in my branch that |
| @@ -3842,30 +3842,15 @@ def SendUpstream(parser, args, cmd): |
| if upstream_commits: |
| print('Base branch "%s" has %d commits ' |
| 'not in this branch.' % (base_branch, len(upstream_commits))) |
| - print('Run "git merge %s" before attempting to %s.' % (base_branch, cmd)) |
| + print('Run "git merge %s" before attempting to land.' % (base_branch,)) |
| return 1 |
| # This is the revision `svn dcommit` will commit on top of. |
| svn_head = None |
| - if cmd == 'dcommit' or base_has_submodules: |
| + if base_has_submodules: |
| svn_head = RunGit(['log', '--grep=^git-svn-id:', '-1', |
| '--pretty=format:%H']) |
| - if cmd == 'dcommit': |
| - # If the base_head is a submodule merge commit, the first parent of the |
| - # base_head should be a git-svn commit, which is what we're interested in. |
| - base_svn_head = base_branch |
| - if base_has_submodules: |
| - base_svn_head += '^1' |
| - |
| - extra_commits = RunGit(['rev-list', '^' + svn_head, base_svn_head]) |
| - if extra_commits: |
| - print('This branch has %d additional commits not upstreamed yet.' |
| - % len(extra_commits.splitlines())) |
| - print('Upstream "%s" or rebase this branch on top of the upstream trunk ' |
| - 'before attempting to %s.' % (base_branch, cmd)) |
| - return 1 |
| - |
| merge_base = RunGit(['merge-base', base_branch, 'HEAD']).strip() |
| if not options.bypass_hooks: |
| author = None |
| @@ -3883,11 +3868,11 @@ def SendUpstream(parser, args, cmd): |
| status = GetTreeStatus() |
| if 'closed' == status: |
| print('The tree is closed. Please wait for it to reopen. Use ' |
| - '"git cl %s --bypass-hooks" to commit on a closed tree.' % cmd) |
| + '"git cl land --bypass-hooks" to commit on a closed tree.') |
| return 1 |
| elif 'unknown' == status: |
| print('Unable to determine tree status. Please verify manually and ' |
| - 'use "git cl %s --bypass-hooks" to commit on a closed tree.' % cmd) |
| + 'use "git cl land --bypass-hooks" to commit on a closed tree.') |
| return 1 |
| change_desc = ChangeDescription(options.message) |
| @@ -3970,44 +3955,25 @@ def SendUpstream(parser, args, cmd): |
| RunGit(['branch', CHERRY_PICK_BRANCH, svn_head]) |
| RunGit(['checkout', CHERRY_PICK_BRANCH]) |
| RunGit(['cherry-pick', cherry_pick_commit]) |
| - if cmd == 'land': |
| - remote, branch = cl.FetchUpstreamTuple(cl.GetBranch()) |
| - mirror = settings.GetGitMirror(remote) |
| - pushurl = mirror.url if mirror else remote |
| - pending_prefix = settings.GetPendingRefPrefix() |
| - if not pending_prefix or branch.startswith(pending_prefix): |
| - # If not using refs/pending/heads/* at all, or target ref is already set |
| - # to pending, then push to the target ref directly. |
| - retcode, output = RunGitWithCode( |
| - ['push', '--porcelain', pushurl, 'HEAD:%s' % branch]) |
| - pushed_to_pending = pending_prefix and branch.startswith(pending_prefix) |
| - else: |
| - # Cherry-pick the change on top of pending ref and then push it. |
| - assert branch.startswith('refs/'), branch |
| - assert pending_prefix[-1] == '/', pending_prefix |
| - pending_ref = pending_prefix + branch[len('refs/'):] |
| - retcode, output = PushToGitPending(pushurl, pending_ref, branch) |
| - pushed_to_pending = (retcode == 0) |
| - if retcode == 0: |
| - revision = RunGit(['rev-parse', 'HEAD']).strip() |
| + remote, branch = cl.FetchUpstreamTuple(cl.GetBranch()) |
| + mirror = settings.GetGitMirror(remote) |
| + pushurl = mirror.url if mirror else remote |
| + pending_prefix = settings.GetPendingRefPrefix() |
| + if not pending_prefix or branch.startswith(pending_prefix): |
| + # If not using refs/pending/heads/* at all, or target ref is already set |
| + # to pending, then push to the target ref directly. |
| + retcode, output = RunGitWithCode( |
| + ['push', '--porcelain', pushurl, 'HEAD:%s' % branch]) |
| + pushed_to_pending = pending_prefix and branch.startswith(pending_prefix) |
| else: |
| - # dcommit the merge branch. |
| - cmd_args = [ |
| - 'svn', 'dcommit', |
| - '-C%s' % options.similarity, |
| - '--no-rebase', '--rmdir', |
| - ] |
| - if settings.GetForceHttpsCommitUrl(): |
| - # Allow forcing https commit URLs for some projects that don't allow |
| - # committing to http URLs (like Google Code). |
| - remote_url = cl.GetGitSvnRemoteUrl() |
| - if urlparse.urlparse(remote_url).scheme == 'http': |
| - remote_url = remote_url.replace('http://', 'https://') |
| - cmd_args.append('--commit-url=%s' % remote_url) |
| - _, output = RunGitWithCode(cmd_args) |
| - if 'Committed r' in output: |
| - revision = re.match( |
| - '.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) |
| + # Cherry-pick the change on top of pending ref and then push it. |
| + assert branch.startswith('refs/'), branch |
| + assert pending_prefix[-1] == '/', pending_prefix |
| + pending_ref = pending_prefix + branch[len('refs/'):] |
| + retcode, output = PushToGitPending(pushurl, pending_ref, branch) |
| + pushed_to_pending = (retcode == 0) |
| + if retcode == 0: |
| + revision = RunGit(['rev-parse', 'HEAD']).strip() |
| logging.debug(output) |
| finally: |
| # And then swap back to the original branch and clean up. |
| @@ -4060,7 +4026,7 @@ def SendUpstream(parser, args, cmd): |
| print('It will show up on %s in ~1 min, once it gets a Cr-Commit-Position ' |
| 'footer.' % branch) |
| - hook = POSTUPSTREAM_HOOK_PATTERN % cmd |
| + hook = POSTUPSTREAM_HOOK_PATTERN % 'land' |
| if os.path.isfile(hook): |
| RunCommand([hook, merge_base], error_ok=True) |
| @@ -4161,34 +4127,6 @@ def IsFatalPushFailure(push_stdout): |
| @subcommand.usage('[upstream branch to apply against]') |
| -def CMDdcommit(parser, args): |
| - """Commits the current changelist via git-svn.""" |
| - if not settings.GetIsGitSvn(): |
| - if git_footers.get_footer_svn_id(): |
| - # If it looks like previous commits were mirrored with git-svn. |
| - message = """This repository appears to be a git-svn mirror, but no |
| -upstream SVN master is set. You probably need to run 'git auto-svn' once.""" |
| - else: |
| - message = """This doesn't appear to be an SVN repository. |
| -If your project has a true, writeable git repository, you probably want to run |
| -'git cl land' instead. |
| -If your project has a git mirror of an upstream SVN master, you probably need |
| -to run 'git svn init'. |
| - |
| -Using the wrong command might cause your commit to appear to succeed, and the |
| -review to be closed, without actually landing upstream. If you choose to |
| -proceed, please verify that the commit lands upstream as expected.""" |
| - print(message) |
| - ask_for_data('[Press enter to dcommit or ctrl-C to quit]') |
| - # TODO(tandrii): kill this post SVN migration with |
| - # https://codereview.chromium.org/2076683002 |
| - print('WARNING: chrome infrastructure is migrating SVN repos to Git.\n' |
| - 'Please let us know of this project you are committing to:' |
| - ' http://crbug.com/600451') |
| - return SendUpstream(parser, args, 'dcommit') |
| - |
| - |
| -@subcommand.usage('[upstream branch to apply against]') |
| def CMDland(parser, args): |
| """Commits the current changelist via git.""" |
| if settings.GetIsGitSvn() or git_footers.get_footer_svn_id(): |
| @@ -4196,7 +4134,7 @@ def CMDland(parser, args): |
| print('Are you sure you didn\'t mean \'git cl dcommit\'?') |
|
Michael Moss
2016/08/15 15:26:32
Change this too, maybe remove the get_footer_svn_i
|
| print('(Ignore if this is the first commit after migrating from svn->git)') |
| ask_for_data('[Press enter to push or ctrl-C to quit]') |
| - return SendUpstream(parser, args, 'land') |
| + return SendUpstream(parser, args) |
| @subcommand.usage('<patch url or issue id or issue url>') |