|
|
@ -43,6 +43,7 @@ DEFAULT_SERVER = 'http://codereview.appspot.com'
|
|
|
|
POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
|
|
|
|
POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
|
|
|
|
DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
|
|
|
|
DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def DieWithError(message):
|
|
|
|
def DieWithError(message):
|
|
|
|
print >> sys.stderr, message
|
|
|
|
print >> sys.stderr, message
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
@ -98,6 +99,14 @@ def usage(more):
|
|
|
|
return hook
|
|
|
|
return hook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ask_for_data(prompt):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
return raw_input(prompt)
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
# Hide the exception.
|
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def FixUrl(server):
|
|
|
|
def FixUrl(server):
|
|
|
|
"""Fix a server url to defaults protocol to http:// if none is specified."""
|
|
|
|
"""Fix a server url to defaults protocol to http:// if none is specified."""
|
|
|
|
if not server:
|
|
|
|
if not server:
|
|
|
@ -526,7 +535,7 @@ def GetCodereviewSettingsInteractively():
|
|
|
|
server = settings.GetDefaultServerUrl(error_ok=True)
|
|
|
|
server = settings.GetDefaultServerUrl(error_ok=True)
|
|
|
|
prompt = 'Rietveld server (host[:port])'
|
|
|
|
prompt = 'Rietveld server (host[:port])'
|
|
|
|
prompt += ' [%s]' % (server or DEFAULT_SERVER)
|
|
|
|
prompt += ' [%s]' % (server or DEFAULT_SERVER)
|
|
|
|
newserver = raw_input(prompt + ': ')
|
|
|
|
newserver = ask_for_data(prompt + ':')
|
|
|
|
if not server and not newserver:
|
|
|
|
if not server and not newserver:
|
|
|
|
newserver = DEFAULT_SERVER
|
|
|
|
newserver = DEFAULT_SERVER
|
|
|
|
if newserver and newserver != server:
|
|
|
|
if newserver and newserver != server:
|
|
|
@ -536,7 +545,7 @@ def GetCodereviewSettingsInteractively():
|
|
|
|
prompt = caption
|
|
|
|
prompt = caption
|
|
|
|
if initial:
|
|
|
|
if initial:
|
|
|
|
prompt += ' ("x" to clear) [%s]' % initial
|
|
|
|
prompt += ' ("x" to clear) [%s]' % initial
|
|
|
|
new_val = raw_input(prompt + ': ')
|
|
|
|
new_val = ask_for_data(prompt + ':')
|
|
|
|
if new_val == 'x':
|
|
|
|
if new_val == 'x':
|
|
|
|
RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True)
|
|
|
|
RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True)
|
|
|
|
elif new_val and new_val != initial:
|
|
|
|
elif new_val and new_val != initial:
|
|
|
@ -1113,7 +1122,7 @@ def SendUpstream(parser, args, cmd):
|
|
|
|
branches = [base_branch, cl.GetBranchRef()]
|
|
|
|
branches = [base_branch, cl.GetBranchRef()]
|
|
|
|
if not options.force:
|
|
|
|
if not options.force:
|
|
|
|
subprocess.call(['git', 'diff', '--stat'] + branches)
|
|
|
|
subprocess.call(['git', 'diff', '--stat'] + branches)
|
|
|
|
raw_input("About to commit; enter to confirm.")
|
|
|
|
ask_for_data('About to commit; enter to confirm.')
|
|
|
|
|
|
|
|
|
|
|
|
# We want to squash all this branch's commits into one commit with the
|
|
|
|
# We want to squash all this branch's commits into one commit with the
|
|
|
|
# proper description.
|
|
|
|
# proper description.
|
|
|
@ -1198,7 +1207,7 @@ to run 'git cl push' instead.
|
|
|
|
Choose wisely, if you get this wrong, your commit might appear to succeed but
|
|
|
|
Choose wisely, if you get this wrong, your commit might appear to succeed but
|
|
|
|
will instead be silently ignored."""
|
|
|
|
will instead be silently ignored."""
|
|
|
|
print(message)
|
|
|
|
print(message)
|
|
|
|
raw_input('[Press enter to dcommit or ctrl-C to quit]')
|
|
|
|
ask_for_data('[Press enter to dcommit or ctrl-C to quit]')
|
|
|
|
return SendUpstream(parser, args, 'dcommit')
|
|
|
|
return SendUpstream(parser, args, 'dcommit')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1208,7 +1217,7 @@ def CMDpush(parser, args):
|
|
|
|
if settings.GetIsGitSvn():
|
|
|
|
if settings.GetIsGitSvn():
|
|
|
|
print('This appears to be an SVN repository.')
|
|
|
|
print('This appears to be an SVN repository.')
|
|
|
|
print('Are you sure you didn\'t mean \'git cl dcommit\'?')
|
|
|
|
print('Are you sure you didn\'t mean \'git cl dcommit\'?')
|
|
|
|
raw_input('[Press enter to push or ctrl-C to quit]')
|
|
|
|
ask_for_data('[Press enter to push or ctrl-C to quit]')
|
|
|
|
return SendUpstream(parser, args, 'push')
|
|
|
|
return SendUpstream(parser, args, 'push')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|