Commit ead4c7e5 authored by nodir@chromium.org's avatar nodir@chromium.org

Revert of revert and fix "Now trychange can...

Bug=359292
Original commit: b1391c6a
Revert: 8e5f7d308fde74c52e321587649c16568e4a9644

Original commit comment:

> Now trychange can store patches in a Git repo

> A git patch repo is cloned to .git/git-try/patches-git, if was not
> cloned before. Otherwise, changes are pulled. Then a patch is committed a
> pushed.

> --revision=auto (Git only) is resolved to the revision the diff is genera
> against.

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@261247 0039d316-1c4b-4281-b951-d872f2087c98
parent 27e6f9b9
......@@ -140,6 +140,10 @@ class GIT(object):
results.append(('%s ' % m.group(1)[0], m.group(2)))
return results
@staticmethod
def IsWorkTreeDirty(cwd):
return GIT.Capture(['status', '-s'], cwd=cwd) != ''
@staticmethod
def GetEmail(cwd):
"""Retrieves the user email address if known."""
......@@ -389,6 +393,17 @@ class GIT(object):
root = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd)
return os.path.abspath(os.path.join(cwd, root))
@staticmethod
def GetGitDir(cwd):
return os.path.abspath(GIT.Capture(['rev-parse', '--git-dir'], cwd=cwd))
@staticmethod
def IsInsideWorkTree(cwd):
try:
return GIT.Capture(['rev-parse', '--is-inside-work-tree'], cwd=cwd)
except (OSError, subprocess2.CalledProcessError):
return False
@staticmethod
def GetGitSvnHeadRev(cwd):
"""Gets the most recently pulled git-svn revision."""
......
......@@ -85,13 +85,16 @@ class GitWrapperTestCase(BaseSCMTestCase):
'GetCheckoutRoot',
'GetDifferentFiles',
'GetEmail',
'GetGitDir',
'GetGitSvnHeadRev',
'GetPatchName',
'GetSha1ForSvnRev',
'GetSVNBranch',
'GetUpstreamBranch',
'IsGitSvn',
'IsInsideWorkTree',
'IsValidRevision',
'IsWorkTreeDirty',
'MatchSvnGlob',
'ParseGitSvnSha1',
'ShortBranchName',
......
......@@ -46,10 +46,12 @@ class TryChangeUnittest(TryChangeTestsBase):
"""General trychange.py tests."""
def testMembersChanged(self):
members = [
'DieWithError', 'EPILOG', 'Escape', 'GIT', 'GetMungedDiff', 'GuessVCS',
'DieWithError', 'EPILOG', 'Escape', 'GIT', 'GIT_PATCH_DIR_BASENAME',
'GetMungedDiff', 'GuessVCS', 'GIT_BRANCH_FILE',
'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'OptionParser',
'PrintSuccess',
'RunCommand', 'RunGit', 'SCM', 'SVN', 'TryChange', 'USAGE', 'breakpad',
'RunCommand', 'RunGit', 'SCM', 'SVN', 'TryChange', 'USAGE', 'contextlib',
'breakpad',
'datetime', 'errno', 'fix_encoding', 'gcl', 'gclient_utils', 'gen_parser',
'getpass', 'itertools', 'json', 'logging', 'optparse', 'os', 'posixpath',
're', 'scm', 'shutil', 'subprocess2', 'sys', 'tempfile', 'urllib',
......
This diff is collapsed.
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