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

Unified Diff: git_cl.py

Issue 27316002: Adding --directory option to git cl patch (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Follow review Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 7a9bff92d10e9ff14eb0b16983b0550aa00c939c..6de71b007928669af44871554d2a311eb75edf71 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -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
« 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