Commit 882c91ed authored by John Budorick's avatar John Budorick Committed by Commit Bot

Revert "gclient: Add support for the branch:revision format."

This reverts commit d328b47e.

Reason for revert: suspect this caused https://bugs.chromium.org/p/chromium/issues/detail?id=863211

Original change's description:
> gclient: Add support for the branch:revision format.
> 
> Bug: 850812, 853032
> Change-Id: I597acbde2b3c229813b7eba8fcba52d5877130b2
> Reviewed-on: https://chromium-review.googlesource.com/1119235
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Aaron Gable <agable@chromium.org>

TBR=agable@chromium.org,tandrii@chromium.org,ehmaldonado@chromium.org

Change-Id: I1e4c00b83a2840cc5a87621469da866dad58a20c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 850812, 853032
Reviewed-on: https://chromium-review.googlesource.com/1135893Reviewed-by: 's avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
parent d328b47e
This diff is collapsed.
......@@ -382,8 +382,10 @@ deps_os = {
}""" % {
'git_base': self.git_base,
# See self.__init__() for the format. Grab's the hash of the first
# commit in repo_3.
'hash3': self.git_hashes['repo_3'][1][0]
# commit in repo_2. Only keep the first 7 character because of:
# TODO(maruel): http://crosbug.com/3591 We need to strip the hash..
# duh.
'hash3': self.git_hashes['repo_3'][1][0][:7]
},
'origin': 'git/repo_1@1\n',
})
......@@ -444,8 +446,9 @@ hooks = [
""" % {
'git_base': self.git_base,
# See self.__init__() for the format. Grab's the hash of the first
# commit in repo_2.
'hash': self.git_hashes['repo_2'][1][0]
# commit in repo_2. Only keep the first 7 character because of:
# TODO(maruel): http://crosbug.com/3591 We need to strip the hash.. duh.
'hash': self.git_hashes['repo_2'][1][0][:7]
},
'origin': 'git/repo_1@2\n',
})
......@@ -468,8 +471,8 @@ pre_deps_hooks = [
]
""" % {
'git_base': self.git_base,
'hash1': self.git_hashes['repo_1'][2][0],
'hash2': self.git_hashes['repo_2'][1][0],
'hash1': self.git_hashes['repo_1'][2][0][:7],
'hash2': self.git_hashes['repo_2'][1][0][:7],
},
'origin': 'git/repo_5@2\n',
})
......@@ -493,8 +496,8 @@ pre_deps_hooks = [
]
""" % {
'git_base': self.git_base,
'hash1': self.git_hashes['repo_1'][2][0],
'hash2': self.git_hashes['repo_2'][1][0],
'hash1': self.git_hashes['repo_1'][2][0][:7],
'hash2': self.git_hashes['repo_2'][1][0][:7],
},
'origin': 'git/repo_5@3\n',
})
......@@ -591,7 +594,7 @@ recursedeps = [
'src/repo8',
]""" % {
'git_base': self.git_base,
'hash': self.git_hashes['repo_2'][1][0]
'hash': self.git_hashes['repo_2'][1][0][:7]
},
'origin': 'git/repo_6@1\n',
})
......@@ -635,7 +638,7 @@ deps_os ={
vars = {
'str_var': 'xyz',
}
gclient_gn_args_file = 'src/repo9/gclient.args'
gclient_gn_args_file = 'src/repo2/gclient.args'
gclient_gn_args = [
'str_var',
]
......
......@@ -184,20 +184,6 @@ Add C
from :3
M 100644 :7 c
blob
mark :9
data 4
foo
commit refs/heads/feature
mark :10
author Alice <alice@example.com> 1490311986 -0700
committer Alice <alice@example.com> 1490311986 -0700
data 6
Add D
from :8
M 100644 :9 d
reset refs/heads/master
from :3
"""
......@@ -227,8 +213,7 @@ from :3
stderr=STDOUT, cwd=path).communicate()
Popen(['git', 'checkout', '-b', 'new', 'origin/master', '-q'], stdout=PIPE,
stderr=STDOUT, cwd=path).communicate()
Popen(['git', 'push', 'origin',
'refs/heads/origin:refs/heads/master', '-q'],
Popen(['git', 'push', 'origin', 'origin/origin:origin/master', '-q'],
stdout=PIPE, stderr=STDOUT, cwd=path).communicate()
Popen(['git', 'config', '--unset', 'remote.origin.fetch'], stdout=PIPE,
stderr=STDOUT, cwd=path).communicate()
......@@ -398,21 +383,6 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
'a7142dc9f0009350b96a11f372b6ea658592aa95')
sys.stdout.close()
def testUpdateRefRevision(self):
if not self.enabled:
return
options = self.Options()
options.force = True
options.revision = ('refs/heads/feature'
':9a51244740b25fa2ded5252ca00a3178d3f665a9')
scm = gclient_scm.GitWrapper(self.url, self.root_dir,
self.relpath)
file_list = []
scm.update(options, (), file_list)
self.assertEquals(scm.revinfo(options, (), None),
'9a51244740b25fa2ded5252ca00a3178d3f665a9')
sys.stdout.close()
def testUpdateMerge(self):
if not self.enabled:
return
......@@ -425,11 +395,11 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
file_list = []
scm.update(options, (), file_list)
self.assertEquals(file_list, [join(self.base_path, x)
for x in ['a', 'b', 'c', 'd']])
for x in ['a', 'b', 'c']])
# The actual commit that is created is unstable, so we verify its tree and
# parents instead.
self.assertEquals(scm._Capture(['rev-parse', 'HEAD:']),
'f7c1b0aaff248edf8981c776dcf6014c3eb09936')
'd2e35c10ac24d6c621e14a1fcadceb533155627d')
self.assertEquals(scm._Capture(['rev-parse', 'HEAD^1']), rev)
self.assertEquals(scm._Capture(['rev-parse', 'HEAD^2']),
scm._Capture(['rev-parse', 'origin/master']))
......@@ -449,12 +419,12 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
'(y)es / (q)uit / (s)kip : ', 'y')
scm.update(options, (), file_list)
self.assertEquals(file_list, [join(self.base_path, x)
for x in "abcd"])
for x in ['a', 'b', 'c']])
# The actual commit that is created is unstable, so we verify its tree and
# parent instead.
self.assertEquals(scm._Capture(['rev-parse', 'HEAD:']),
'f7c1b0aaff248edf8981c776dcf6014c3eb09936')
self.assertEquals(scm._Capture(['rev-parse', 'HEAD^^']),
'd2e35c10ac24d6c621e14a1fcadceb533155627d')
self.assertEquals(scm._Capture(['rev-parse', 'HEAD^']),
scm._Capture(['rev-parse', 'origin/master']))
sys.stdout.close()
......@@ -567,7 +537,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
'Fix the conflict and run gclient again.\n'
'See \'man git-rebase\' for details.\n')
self.assertRaisesError(exception, scm.update, options, (), [])
exception = ('\n____ . at refs/heads/master\n'
exception = ('\n____ . at refs/remotes/origin/master\n'
'\tYou have unstaged changes.\n'
'\tPlease commit, stash, or reset.\n')
self.assertRaisesError(exception, scm.update, options, (), [])
......@@ -665,9 +635,8 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
).AndReturn(False)
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True)
# pylint: disable=no-value-for-parameter
gclient_scm.GitWrapper._Clone(
'refs/heads/master', 'refs/remotes/origin/master', None, self.url,
options)
gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url,
options)
self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True)
gclient_scm.subprocess2.check_output(
['git', '-c', 'core.quotePath=false', 'ls-files'], cwd=self.base_path,
......@@ -698,15 +667,13 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True)
# pylint: disable=no-value-for-parameter
gclient_scm.GitWrapper._Clone(
'refs/heads/master', 'refs/remotes/origin/master', None, self.url,
options
'refs/remotes/origin/master', self.url, options
).AndRaise(gclient_scm.subprocess2.CalledProcessError(None, None, None,
None, None))
self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_DeleteOrMove', True)
gclient_scm.GitWrapper._DeleteOrMove(False)
gclient_scm.GitWrapper._Clone(
'refs/heads/master', 'refs/remotes/origin/master', None, self.url,
options)
gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url,
options)
self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True)
gclient_scm.subprocess2.check_output(
['git', '-c', 'core.quotePath=false', 'ls-files'], cwd=self.base_path,
......@@ -768,7 +735,7 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
self.assertEquals(file_list, expected_file_list)
self.assertEquals(scm.revinfo(options, (), None),
'a7142dc9f0009350b96a11f372b6ea658592aa95')
'069c602044c5388d2d15c3f875b057c852003458')
# indicates detached HEAD
self.assertEquals(self.getCurrentBranch(), None)
self.checkInStdout(
......@@ -776,33 +743,6 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
rmtree(origin_root_dir)
def testUpdateCloneRefRevision(self):
if not self.enabled:
return
options = self.Options()
options.revision = ('refs/heads/feature'
':9a51244740b25fa2ded5252ca00a3178d3f665a9')
origin_root_dir = self.root_dir
self.root_dir = tempfile.mkdtemp()
self.relpath = '.'
self.base_path = join(self.root_dir, self.relpath)
scm = gclient_scm.GitWrapper(origin_root_dir,
self.root_dir,
self.relpath)
file_list = []
scm.update(options, (), file_list)
self.assertEquals(scm.revinfo(options, (), None),
'9a51244740b25fa2ded5252ca00a3178d3f665a9')
# indicates detached HEAD
self.assertEquals(self.getCurrentBranch(), None)
self.checkInStdout(
'Checked out 9a51244740b25fa2ded5252ca00a3178d3f665a9 to a detached HEAD')
rmtree(origin_root_dir)
def testUpdateCloneOnCommit(self):
if not self.enabled:
return
......@@ -852,19 +792,18 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
expected_file_list = [join(self.base_path, "a"),
join(self.base_path, "b"),
join(self.base_path, "c"),
join(self.base_path, "d")]
join(self.base_path, "c")]
file_list = []
options.revision = 'unmanaged'
scm.update(options, (), file_list)
self.assertEquals(file_list, expected_file_list)
self.assertEquals(scm.revinfo(options, (), None),
'8980cdcc0b037755eec87c47f1a9d7e90d580015')
'9a51244740b25fa2ded5252ca00a3178d3f665a9')
# indicates detached HEAD
self.assertEquals(self.getCurrentBranch(), None)
self.checkInStdout(
'Checked out refs/remotes/origin/feature '
'Checked out 9a51244740b25fa2ded5252ca00a3178d3f665a9 '
'to a detached HEAD')
rmtree(origin_root_dir)
......@@ -886,15 +825,14 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
expected_file_list = [join(self.base_path, "a"),
join(self.base_path, "b"),
join(self.base_path, "c"),
join(self.base_path, "d")]
join(self.base_path, "c")]
file_list = []
options.revision = 'unmanaged'
scm.update(options, (), file_list)
self.assertEquals(file_list, expected_file_list)
self.assertEquals(scm.revinfo(options, (), None),
'8980cdcc0b037755eec87c47f1a9d7e90d580015')
'9a51244740b25fa2ded5252ca00a3178d3f665a9')
# indicates detached HEAD
self.assertEquals(self.getCurrentBranch(), None)
self.checkInStdout(
......@@ -919,16 +857,15 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
expected_file_list = [join(self.base_path, "a"),
join(self.base_path, "b"),
join(self.base_path, "c"),
join(self.base_path, "d")]
join(self.base_path, "c")]
file_list = []
options.revision = 'unmanaged'
scm.update(options, (), file_list)
self.assertEquals(file_list, expected_file_list)
self.assertEquals(scm.revinfo(options, (), None),
'8980cdcc0b037755eec87c47f1a9d7e90d580015')
# @refs/heads/feature is AKA @refs/heads/feature in the clone, so
'9a51244740b25fa2ded5252ca00a3178d3f665a9')
# @refs/heads/feature is AKA @refs/remotes/origin/feature in the clone, so
# should be treated as such by gclient.
# TODO(mmoss): Though really, we should only allow DEPS to specify branches
# as they are known in the upstream repo, since the mapping into the local
......
......@@ -39,7 +39,7 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase):
self.env['DEPOT_TOOLS_UPDATE'] = '0'
self.env['DEPOT_TOOLS_METRICS'] = '0'
def gclient(self, cmd, cwd=None, ignore_errors=False):
def gclient(self, cmd, cwd=None):
if not cwd:
cwd = self.root_dir
if COVERAGE:
......@@ -54,8 +54,6 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase):
(stdout, stderr) = process.communicate()
logging.debug("XXX: %s\n%s\nXXX" % (' '.join(cmd), stdout))
logging.debug("YYY: %s\n%s\nYYY" % (' '.join(cmd), stderr))
if process.returncode and not ignore_errors:
raise subprocess.CalledProcessError(process.returncode, cmd, stdout)
return (stdout.replace('\r\n', '\n'), stderr.replace('\r\n', '\n'),
process.returncode)
......@@ -160,14 +158,14 @@ class GClientSmoke(GClientSmokeBase):
def testNotConfigured(self):
res = ('', 'Error: client not configured; see \'gclient config\'\n', 1)
self.check(res, self.gclient(['diff'], ignore_errors=True))
self.check(res, self.gclient(['pack'], ignore_errors=True))
self.check(res, self.gclient(['revert'], ignore_errors=True))
self.check(res, self.gclient(['revinfo'], ignore_errors=True))
self.check(res, self.gclient(['runhooks'], ignore_errors=True))
self.check(res, self.gclient(['status'], ignore_errors=True))
self.check(res, self.gclient(['sync'], ignore_errors=True))
self.check(res, self.gclient(['update'], ignore_errors=True))
self.check(res, self.gclient(['diff']))
self.check(res, self.gclient(['pack']))
self.check(res, self.gclient(['revert']))
self.check(res, self.gclient(['revinfo']))
self.check(res, self.gclient(['runhooks']))
self.check(res, self.gclient(['status']))
self.check(res, self.gclient(['sync']))
self.check(res, self.gclient(['update']))
def testConfig(self):
# Get any bootstrapping out of the way.
......@@ -251,7 +249,7 @@ class GClientSmoke(GClientSmokeBase):
test(['config', '--spec', '["blah blah"]'], '["blah blah"]')
os.remove(p)
results = self.gclient(['config', 'foo', 'faa', 'fuu'], ignore_errors=True)
results = self.gclient(['config', 'foo', 'faa', 'fuu'])
err = ('Usage: gclient.py config [options] [url]\n\n'
'gclient.py: error: Inconsistent arguments. Use either --spec or one'
' or 2 args\n')
......@@ -383,7 +381,7 @@ class GClientSmokeGIT(GClientSmokeBase):
'src/repo2/': {
'scm': 'git',
'url':
self.git_base + 'repo_2@' + self.githash('repo_2', 1),
self.git_base + 'repo_2@' + self.githash('repo_2', 1)[:7],
'revision': self.githash('repo_2', 1),
'was_processed': True,
},
......@@ -726,8 +724,7 @@ class GClientSmokeGIT(GClientSmokeBase):
% (sys.executable, self.root_dir))
stdout, stderr, retcode = self.gclient(['sync', '--deps', 'mac', '--jobs=1',
'--revision',
'src@' + self.githash('repo_5', 3)],
ignore_errors=True)
'src@' + self.githash('repo_5', 3)])
self.assertEquals(stderr, expected_stderr)
self.assertEquals(2, retcode)
self.checkBlock(stdout, expectated_stdout)
......@@ -743,7 +740,7 @@ class GClientSmokeGIT(GClientSmokeBase):
'src/repo2/repo_renamed: %(base)srepo_3\n' %
{
'base': self.git_base,
'hash2': self.githash('repo_2', 1),
'hash2': self.githash('repo_2', 1)[:7],
})
self.check((out, '', 0), results)
......@@ -786,7 +783,7 @@ class GClientSmokeGIT(GClientSmokeBase):
out = ('src/repo2: %(base)srepo_2@%(hash2)s\n' %
{
'base': self.git_base,
'hash2': self.githash('repo_2', 1),
'hash2': self.githash('repo_2', 1)[:7],
})
self.check((out, '', 0), results)
......@@ -801,7 +798,7 @@ class GClientSmokeGIT(GClientSmokeBase):
'src/repo2: %(base)srepo_2@%(hash2)s\n' %
{
'base': self.git_base,
'hash2': self.githash('repo_2', 1),
'hash2': self.githash('repo_2', 1)[:7],
})
self.check((out, '', 0), results)
......@@ -822,7 +819,7 @@ class GClientSmokeGIT(GClientSmokeBase):
},
'src/repo2': {
'url': self.git_base + 'repo_2',
'rev': self.githash('repo_2', 1),
'rev': self.githash('repo_2', 1)[:7],
},
'src/repo2/repo_renamed': {
'url': self.git_base + 'repo_3',
......@@ -990,7 +987,7 @@ class GClientSmokeGIT(GClientSmokeBase):
' # src -> src/repo2',
' "src/repo2": {',
' "url": "' + self.git_base + 'repo_2@%s",' % (
self.githash('repo_2', 1)),
self.githash('repo_2', 1)[:7]),
' "condition": \'true_str_var\',',
' },',
'',
......@@ -1096,7 +1093,7 @@ class GClientSmokeGIT(GClientSmokeBase):
'}',
'',
'# ' + self.git_base + 'repo_2@%s, DEPS' % (
self.githash('repo_2', 1)),
self.githash('repo_2', 1)[:7]),
'# ' + self.git_base + 'repo_6, DEPS',
'# ' + self.git_base + 'repo_8, DEPS',
], deps_contents.splitlines())
......@@ -1294,7 +1291,7 @@ class GClientSmokeGIT(GClientSmokeBase):
self.maxDiff = None
self.assertEqual([
'gclient_gn_args_file = "src/repo9/gclient.args"',
'gclient_gn_args_file = "src/repo2/gclient.args"',
"gclient_gn_args = ['str_var']",
'deps = {',
' # src',
......@@ -1386,8 +1383,7 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertFalse(os.path.exists(output_deps))
self.gclient(['config', self.git_base + 'repo_14', '--name', 'src'])
# We can't sync since we haven't faked a CIPD server to get packages from.
self.gclient(['sync'], ignore_errors=True)
self.gclient(['sync'])
self.gclient(['flatten', '-v', '-v', '-v', '--output-deps', output_deps])
with open(output_deps) as f:
......@@ -1456,7 +1452,7 @@ class GClientSmokeGITMutates(GClientSmokeBase):
# Commit new change to repo to make repo_2's hash use a custom_var.
cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS']
repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0]
repo_2_hash = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7]
new_deps = cur_deps.replace('repo_2@%s\'' % repo_2_hash,
'repo_2@\' + Var(\'r2hash\')')
new_deps = 'vars = {\'r2hash\': \'%s\'}\n%s' % (repo_2_hash, new_deps)
......@@ -1533,7 +1529,7 @@ class GClientSmokeGITMutates(GClientSmokeBase):
return
# Create an extra commit in repo_2 and point DEPS to its hash.
cur_deps = self.FAKE_REPOS.git_hashes['repo_1'][-1][1]['DEPS']
repo_2_hash_old = self.FAKE_REPOS.git_hashes['repo_2'][1][0]
repo_2_hash_old = self.FAKE_REPOS.git_hashes['repo_2'][1][0][:7]
self.FAKE_REPOS._commit_git('repo_2', { # pylint: disable=protected-access
'last_file': 'file created in last commit',
})
......
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