Commit 7a54e818 authored by thestig@chromium.org's avatar thestig@chromium.org

git_cl: Do not cache the relative root in Settings.

Relative root no longer makes sense after an os.chdir().
This is effectively a partial revert of r250248.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@250478 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b0553c1
...@@ -262,7 +262,7 @@ class Settings(object): ...@@ -262,7 +262,7 @@ class Settings(object):
def __init__(self): def __init__(self):
self.default_server = None self.default_server = None
self.cc = None self.cc = None
self.relative_root = None self.root = None
self.is_git_svn = None self.is_git_svn = None
self.svn_branch = None self.svn_branch = None
self.tree_status_url = None self.tree_status_url = None
...@@ -303,13 +303,14 @@ class Settings(object): ...@@ -303,13 +303,14 @@ class Settings(object):
self._GetRietveldConfig('server', error_message=error_message)) self._GetRietveldConfig('server', error_message=error_message))
return self.default_server return self.default_server
def GetRelativeRoot(self): @staticmethod
if self.relative_root is None: def GetRelativeRoot():
self.relative_root = RunGit(['rev-parse', '--show-cdup']).strip() return RunGit(['rev-parse', '--show-cdup']).strip()
return self.relative_root
def GetRoot(self): def GetRoot(self):
return os.path.abspath(self.GetRelativeRoot()) if self.root is None:
self.root = os.path.abspath(self.GetRelativeRoot())
return self.root
def GetIsGitSvn(self): def GetIsGitSvn(self):
"""Return true if this repo looks like it's using git-svn.""" """Return true if this repo looks like it's using git-svn."""
......
...@@ -204,6 +204,7 @@ class TestGitCl(TestCase): ...@@ -204,6 +204,7 @@ class TestGitCl(TestCase):
((['git', ((['git',
'config', '--local', '--get-regexp', '^svn-remote\\.'],), 'config', '--local', '--get-regexp', '^svn-remote\\.'],),
(('', None), 0)), (('', None), 0)),
((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'svn', 'info'],), ''), ((['git', 'svn', 'info'],), ''),
((['git', ((['git',
'config', 'branch.master.rietveldissue', '1'],), ''), 'config', 'branch.master.rietveldissue', '1'],), ''),
...@@ -318,8 +319,8 @@ class TestGitCl(TestCase): ...@@ -318,8 +319,8 @@ class TestGitCl(TestCase):
] ]
@classmethod @classmethod
def _dcommit_calls_3(cls, is_first_call): def _dcommit_calls_3(cls):
calls = [ return [
((['git', ((['git',
'diff', '--no-ext-diff', '--stat', '--find-copies-harder', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder',
'-l100000', '-C50', 'fake_ancestor_sha', '-l100000', '-C50', 'fake_ancestor_sha',
...@@ -333,12 +334,7 @@ class TestGitCl(TestCase): ...@@ -333,12 +334,7 @@ class TestGitCl(TestCase):
((['git', 'branch', '-D', 'git-cl-commit'],), ''), ((['git', 'branch', '-D', 'git-cl-commit'],), ''),
((['git', 'show-ref', '--quiet', '--verify', ((['git', 'show-ref', '--quiet', '--verify',
'refs/heads/git-cl-cherry-pick'],), ''), 'refs/heads/git-cl-cherry-pick'],), ''),
] ((['git', 'rev-parse', '--show-cdup'],), '\n'),
if is_first_call:
calls += [
((['git', 'rev-parse', '--show-cdup'],), '\n'),
]
calls += [
((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''),
((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''), ((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''),
((['git', 'commit', '-m', ((['git', 'commit', '-m',
...@@ -350,8 +346,7 @@ class TestGitCl(TestCase): ...@@ -350,8 +346,7 @@ class TestGitCl(TestCase):
(('', None), 0)), (('', None), 0)),
((['git', 'checkout', '-q', 'working'],), ''), ((['git', 'checkout', '-q', 'working'],), ''),
((['git', 'branch', '-D', 'git-cl-commit'],), ''), ((['git', 'branch', '-D', 'git-cl-commit'],), ''),
] ]
return calls
@staticmethod @staticmethod
def _cmd_line(description, args, similarity, find_copies, private): def _cmd_line(description, args, similarity, find_copies, private):
...@@ -514,14 +509,14 @@ class TestGitCl(TestCase): ...@@ -514,14 +509,14 @@ class TestGitCl(TestCase):
self._dcommit_calls_1() + self._dcommit_calls_1() +
self._git_sanity_checks('fake_ancestor_sha', 'working') + self._git_sanity_checks('fake_ancestor_sha', 'working') +
self._dcommit_calls_normal() + self._dcommit_calls_normal() +
self._dcommit_calls_3(False)) self._dcommit_calls_3())
git_cl.main(['dcommit']) git_cl.main(['dcommit'])
def test_dcommit_bypass_hooks(self): def test_dcommit_bypass_hooks(self):
self.calls = ( self.calls = (
self._dcommit_calls_1() + self._dcommit_calls_1() +
self._dcommit_calls_bypassed() + self._dcommit_calls_bypassed() +
self._dcommit_calls_3(True)) self._dcommit_calls_3())
git_cl.main(['dcommit', '--bypass-hooks']) git_cl.main(['dcommit', '--bypass-hooks'])
......
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