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

Side by Side Diff: git_cl.py

Issue 16211005: Allow --3way to be passed to `git apply` via `git cl patch`. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: make 3way default Created 7 years, 6 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 | no next file » | 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 json 10 import json
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 1685
1686 1686
1687 @usage('<patch url or issue id>') 1687 @usage('<patch url or issue id>')
1688 def CMDpatch(parser, args): 1688 def CMDpatch(parser, args):
1689 """patch in a code review""" 1689 """patch in a code review"""
1690 parser.add_option('-b', dest='newbranch', 1690 parser.add_option('-b', dest='newbranch',
1691 help='create a new branch off trunk for the patch') 1691 help='create a new branch off trunk for the patch')
1692 parser.add_option('-f', action='store_true', dest='force', 1692 parser.add_option('-f', action='store_true', dest='force',
1693 help='with -b, clobber any existing branch') 1693 help='with -b, clobber any existing branch')
1694 parser.add_option('--reject', action='store_true', dest='reject', 1694 parser.add_option('--reject', action='store_true', dest='reject',
1695 help='allow failed patches and spew .rej files') 1695 help='failed patches spew .rej files rather than '
1696 'attempting a 3-way merge')
1696 parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit', 1697 parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit',
1697 help="don't commit after patch applies") 1698 help="don't commit after patch applies")
1698 (options, args) = parser.parse_args(args) 1699 (options, args) = parser.parse_args(args)
1699 if len(args) != 1: 1700 if len(args) != 1:
1700 parser.print_help() 1701 parser.print_help()
1701 return 1 1702 return 1
1702 issue_arg = args[0] 1703 issue_arg = args[0]
1703 1704
1704 # TODO(maruel): Use apply_issue.py 1705 # TODO(maruel): Use apply_issue.py
1705 # TODO(ukai): use gerrit-cherry-pick for gerrit repository? 1706 # TODO(ukai): use gerrit-cherry-pick for gerrit repository?
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 ['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'], stdin=patch_data) 1744 ['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'], stdin=patch_data)
1744 except subprocess2.CalledProcessError: 1745 except subprocess2.CalledProcessError:
1745 DieWithError('Git patch mungling failed.') 1746 DieWithError('Git patch mungling failed.')
1746 logging.info(patch_data) 1747 logging.info(patch_data)
1747 # We use "git apply" to apply the patch instead of "patch" so that we can 1748 # We use "git apply" to apply the patch instead of "patch" so that we can
1748 # pick up file adds. 1749 # pick up file adds.
1749 # The --index flag means: also insert into the index (so we catch adds). 1750 # The --index flag means: also insert into the index (so we catch adds).
1750 cmd = ['git', '--no-pager', 'apply', '--index', '-p0'] 1751 cmd = ['git', '--no-pager', 'apply', '--index', '-p0']
1751 if options.reject: 1752 if options.reject:
1752 cmd.append('--reject') 1753 cmd.append('--reject')
1754 else:
1755 cmd.append('--3way')
ncarter (slow) 2013/06/07 19:42:00 FYI: this option doesn't seem to exist in git vers
M-A Ruel 2013/06/07 19:44:45 Trent, can you revert or fix? We have to support s
1753 try: 1756 try:
1754 subprocess2.check_call(cmd, stdin=patch_data, stdout=subprocess2.VOID) 1757 subprocess2.check_call(cmd, stdin=patch_data, stdout=subprocess2.VOID)
1755 except subprocess2.CalledProcessError: 1758 except subprocess2.CalledProcessError:
1756 DieWithError('Failed to apply the patch') 1759 DieWithError('Failed to apply the patch')
1757 1760
1758 # If we had an issue, commit the current state and register the issue. 1761 # If we had an issue, commit the current state and register the issue.
1759 if not options.nocommit: 1762 if not options.nocommit:
1760 RunGit(['commit', '-m', 'patch from issue %s' % issue]) 1763 RunGit(['commit', '-m', 'patch from issue %s' % issue])
1761 cl = Changelist() 1764 cl = Changelist()
1762 cl.SetIssue(issue) 1765 cl.SetIssue(issue)
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 GenUsage(parser, 'help') 2096 GenUsage(parser, 'help')
2094 return CMDhelp(parser, argv) 2097 return CMDhelp(parser, argv)
2095 2098
2096 2099
2097 if __name__ == '__main__': 2100 if __name__ == '__main__':
2098 # These affect sys.stdout so do it outside of main() to simplify mocks in 2101 # These affect sys.stdout so do it outside of main() to simplify mocks in
2099 # unit testing. 2102 # unit testing.
2100 fix_encoding.fix_encoding() 2103 fix_encoding.fix_encoding()
2101 colorama.init() 2104 colorama.init()
2102 sys.exit(main(sys.argv[1:])) 2105 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698