Commit 1ef44afb authored by qsr@chromium.org's avatar qsr@chromium.org

Adding --directory option to git cl patch

Review URL: https://codereview.chromium.org/27316002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@228926 0039d316-1c4b-4281-b951-d872f2087c98
parent cef7236c
......@@ -1862,9 +1862,12 @@ def CMDpatch(parser, args):
"""Patches in a code review."""
parser.add_option('-b', dest='newbranch',
help='create a new branch off trunk for the patch')
parser.add_option('-f', action='store_true', dest='force',
parser.add_option('-f', '--force', action='store_true',
help='with -b, clobber any existing branch')
parser.add_option('--reject', action='store_true', dest='reject',
parser.add_option('-d', '--directory', action='store', metavar='DIR',
help='Change to the directory DIR immediately, '
'before doing anything else.')
parser.add_option('--reject', action='store_true',
help='failed patches spew .rej files rather than '
'attempting a 3-way merge')
parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit',
......@@ -1885,10 +1888,11 @@ def CMDpatch(parser, args):
RunGit(['checkout', '-b', options.newbranch,
Changelist().GetUpstreamBranch()])
return PatchIssue(issue_arg, options.reject, options.nocommit)
return PatchIssue(issue_arg, options.reject, options.nocommit,
options.directory)
def PatchIssue(issue_arg, reject, nocommit):
def PatchIssue(issue_arg, reject, nocommit, directory):
if type(issue_arg) is int or issue_arg.isdigit():
# Input is an issue id. Figure out the URL.
issue = int(issue_arg)
......@@ -1930,6 +1934,8 @@ def PatchIssue(issue_arg, reject, nocommit):
# pick up file adds.
# The --index flag means: also insert into the index (so we catch adds).
cmd = ['git', 'apply', '--index', '-p0']
if directory:
cmd.extend(('--directory', directory))
if reject:
cmd.append('--reject')
elif IsGitVersionAtLeast('1.7.12'):
......@@ -2160,7 +2166,7 @@ def CMDdiff(parser, args):
RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch])
try:
# Patch in the latest changes from rietveld.
rtn = PatchIssue(cl.GetIssue(), False, False)
rtn = PatchIssue(cl.GetIssue(), False, False, None)
if rtn != 0:
return rtn
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment