Commit bbb46658 authored by cmp@chromium.org's avatar cmp@chromium.org

Make git try work on Windows.

This mirrors the git-cl changes by first moving git-try
to git_try.py (which git cl already had), then copying
git-cl to git-try and updating all references to git-cl
and git_cl.py to the corresponding git try references.

The main issue is that in the MINGW/Msysgit case we want
to use the Python in depot_tools since that is 100%
compatible with the Command Prompt.  Hence we need
to call it directly and then pass it the name of the
git_try.py script.

Note that 'git-try' will not (ever) work on Windows,
and users should only ever run 'git try'.  Hence the
need to modify the output of the command to avoid
further confusion.
Review URL: http://codereview.chromium.org/7114002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@89031 0039d316-1c4b-4281-b951-d872f2087c98
parent 63f78b0f
#!/usr/bin/python
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
#!/bin/sh
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Wrapper for trychange.py for git checkout."""
import logging
import sys
base_dir=$(dirname "$0")
import breakpad # pylint: disable=W0611
# Test if this script is running under a MSys install. If it is, we will
# hardcode the path to Python where possible.
OUTPUT="$(uname | grep 'MINGW')"
MINGW=$?
import gclient_utils
from scm import GIT
import third_party.upload
import trychange
def GetRietveldIssueNumber():
try:
return GIT.Capture(
['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)])
except gclient_utils.Error:
return None
def GetRietveldPatchsetNumber():
try:
return GIT.Capture(
['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)])
except gclient_utils.Error:
return None
def GetRietveldServerUrl():
try:
return GIT.Capture(['config', 'rietveld.server']).strip()
except gclient_utils.Error:
return None
if __name__ == '__main__':
args = sys.argv[1:]
patchset = GetRietveldPatchsetNumber()
if patchset:
args.extend([
'--issue', GetRietveldIssueNumber(),
'--patchset', patchset,
])
else:
rietveld_url = GetRietveldServerUrl()
if rietveld_url:
args.extend(['--rietveld_url', GetRietveldServerUrl()])
# Hack around a limitation in logging.
logging.getLogger().handlers = []
try:
sys.exit(trychange.TryChange(
args, file_list=[], swallow_exception=False,
prog='git-try',
extra_epilog='\n'
'git-try will diff against your tracked branch and will '
'detect your rietveld\n'
'code review if you are using git-cl\n'))
except third_party.upload.ClientLoginError, e:
print('Got an exception while trying to log in to Rietveld.')
print(str(e))
if [ -d "$base_dir/python_bin" -a $MINGW = 0 ]; then
exec "$base_dir/python_bin/python.exe" "$base_dir"/git_try.py "$@"
else
exec "$base_dir/git_try.py" "$@"
fi
#!/usr/bin/python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Wrapper for trychange.py for git checkout."""
import logging
import sys
import breakpad # pylint: disable=W0611
import gclient_utils
from scm import GIT
import third_party.upload
import trychange
def GetRietveldIssueNumber():
try:
return GIT.Capture(
['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)])
except gclient_utils.Error:
return None
def GetRietveldPatchsetNumber():
try:
return GIT.Capture(
['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)])
except gclient_utils.Error:
return None
def GetRietveldServerUrl():
try:
return GIT.Capture(['config', 'rietveld.server']).strip()
except gclient_utils.Error:
return None
if __name__ == '__main__':
args = sys.argv[1:]
patchset = GetRietveldPatchsetNumber()
if patchset:
args.extend([
'--issue', GetRietveldIssueNumber(),
'--patchset', patchset,
])
else:
rietveld_url = GetRietveldServerUrl()
if rietveld_url:
args.extend(['--rietveld_url', GetRietveldServerUrl()])
# Hack around a limitation in logging.
logging.getLogger().handlers = []
try:
sys.exit(trychange.TryChange(
args, file_list=[], swallow_exception=False,
prog='git-try',
extra_epilog='\n'
'git try will diff against your tracked branch and will '
'detect your rietveld\n'
'code review if you are using git-cl\n'))
except third_party.upload.ClientLoginError, e:
print('Got an exception while trying to log in to Rietveld.')
print(str(e))
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