Commit 07b5283a authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

Revert "gclient: delete unversioned directory before adding cipd dep for the same path"

This reverts commit 67ef3f67.

Reason for revert: might have broken GCE/ccompute fleet.

Original change's description:
> gclient: delete unversioned directory before adding cipd dep for the same path
> 
> Bug: 882611
> Change-Id: I46e41cc9693b90874b5d6569a12ec638eaac1050
> Reviewed-on: https://chromium-review.googlesource.com/1228655
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>

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

Change-Id: Ia2172b1b0d236357edf93dacf57f3bf7d80d5968
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 882611
Reviewed-on: https://chromium-review.googlesource.com/1231699Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent 78eed01c
......@@ -1614,6 +1614,9 @@ it or fix the checkout.
patch_repo + '@' + patch_ref
for patch_repo, patch_ref in patch_refs.iteritems())))
if self._cipd_root:
self._cipd_root.run(command)
# Once all the dependencies have been processed, it's now safe to write
# out the gn_args_file and run the hooks.
if command == 'update':
......@@ -1721,12 +1724,6 @@ it or fix the checkout.
gclient_utils.rmtree(e_dir)
# record the current list of entries for next time
self._SaveEntries()
# Sync CIPD dependencies once removed deps are deleted. In case a git
# dependency was moved to CIPD, we want to remove the old git directory
# first and then sync the CIPD dep.
self.GetCipdRoot().run(command)
return 0
def PrintRevInfo(self):
......
......@@ -5,27 +5,10 @@
import argparse
import os
import re
import shutil
import sys
CIPD_SUBDIR_RE = '@Subdir (.*)'
def parse_cipd(root, contents):
tree = {}
current_subdir = None
for line in contents:
line = line.strip()
match = re.match(CIPD_SUBDIR_RE, line)
if match:
current_subdir = os.path.join(root, *match.group(1).split('/'))
elif line and current_subdir:
tree.setdefault(current_subdir, []).append(line)
return tree
def main():
assert sys.argv[1] == 'ensure'
parser = argparse.ArgumentParser()
......@@ -33,18 +16,12 @@ def main():
parser.add_argument('-root')
args, _ = parser.parse_known_args()
with open(args.ensure_file) as f:
new_content = parse_cipd(args.root, f.readlines())
# Install new packages
for path, packages in new_content.iteritems():
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path, '_cipd'), 'w') as f:
f.write('\n'.join(packages))
cipd_root = os.path.join(args.root, '.cipd')
if not os.path.isdir(cipd_root):
os.makedirs(cipd_root)
# Save the ensure file that we got
shutil.copy(args.ensure_file, os.path.join(args.root, '_cipd'))
if args.ensure_file:
shutil.copy(args.ensure_file, os.path.join(cipd_root, 'ensure'))
return 0
......
......@@ -743,23 +743,6 @@ deps = {
'origin': 'git/repo_13@2\n',
})
# src/repo12 is now a CIPD dependency.
self._commit_git('repo_13', {
'DEPS': """
deps = {
'src/repo12': {
'packages': [
{
'package': 'foo',
'version': '1.3',
},
],
'dep_type': 'cipd',
},
}""",
'origin': 'git/repo_13@3\n'
})
self._commit_git('repo_14', {
'DEPS': textwrap.dedent("""\
vars = {}
......@@ -949,9 +932,9 @@ class FakeReposTestBase(trial_dir.TestCase):
actual = read_tree(tree_root)
diff = dict_diff(tree, actual)
if diff:
logging.error('Actual %s\n%s' % (tree_root, pprint.pformat(actual)))
logging.error('Expected\n%s' % pprint.pformat(tree))
logging.error('Diff\n%s' % pprint.pformat(diff))
logging.debug('Actual %s\n%s' % (tree_root, pprint.pformat(actual)))
logging.debug('Expected\n%s' % pprint.pformat(tree))
logging.debug('Diff\n%s' % pprint.pformat(diff))
self.assertEquals(diff, {})
def mangle_git_tree(self, *args):
......
......@@ -514,8 +514,7 @@ class GClientSmokeGIT(GClientSmokeBase):
if not self.enabled:
return
self.gclient(['config', self.git_base + 'repo_13', '--name', 'src'])
_out, _err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 2)])
_out, _err, rc = self.gclient(['sync', '-v', '-v', '-v'])
self.assertEquals(0, rc)
def testSyncFetchUpdate(self):
......@@ -530,8 +529,7 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(0, rc)
# Make sure update that pulls a non-standard ref works.
_out, _err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 2)])
_out, _err, rc = self.gclient(['sync', '-v', '-v', '-v'])
self.assertEquals(0, rc)
def testSyncDirect(self):
......@@ -696,7 +694,7 @@ class GClientSmokeGIT(GClientSmokeBase):
'--revision', 'src@' + self.githash('repo_5', 2)],
expectation)
self.assertEquals('Cloning into ', out[0][1][:13])
self.assertEquals(2, len(out[1]), out[1])
self.assertEquals(2, len(out[1]))
self.assertEquals('pre-deps hook', out[1][1])
tree = self.mangle_git_tree(('repo_5@2', 'src'),
('repo_1@2', 'src/repo1'),
......@@ -1895,103 +1893,25 @@ class GClientSmokeCipd(GClientSmokeBase):
def testSyncCipd(self):
self.gclient(['config', self.git_base + 'repo_14', '--name', 'src'])
out, err, rc = self.gclient(['sync'])
self.assertEquals(0, rc, out + err)
tree = self.mangle_git_tree(('repo_14@1', 'src'))
tree.update({
'_cipd': '\n'.join([
'$ParanoidMode CheckPresence',
'',
'@Subdir src/another_cipd_dep',
'package1 1.1-cr0',
'package2 1.13',
'',
'@Subdir src/cipd_dep',
'package0 0.1',
'',
'@Subdir src/cipd_dep_with_cipd_variable',
'package3/${platform} 1.2',
'',
'',
]),
'src/another_cipd_dep/_cipd': '\n'.join([
'package1 1.1-cr0',
'package2 1.13',
]),
'src/cipd_dep/_cipd': 'package0 0.1',
'src/cipd_dep_with_cipd_variable/_cipd': 'package3/${platform} 1.2',
})
self.assertTree(tree)
def testConvertGitToCipd(self):
self.gclient(['config', self.git_base + 'repo_13', '--name', 'src'])
# repo_13@1 has src/repo12 as a git dependency.
out, err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 1)])
self.assertEquals(0, rc, out + err)
tree = self.mangle_git_tree(('repo_13@1', 'src'),
('repo_12@1', 'src/repo12'))
tree['_cipd'] = '$ParanoidMode CheckPresence\n\n'
self.assertTree(tree)
# repo_13@3 has src/repo12 as a cipd dependency.
out, err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 3),
'--delete_unversioned_trees'])
self.assertEquals(0, rc, out + err)
tree = self.mangle_git_tree(('repo_13@3', 'src'))
tree.update({
'_cipd': '\n'.join([
'$ParanoidMode CheckPresence',
'',
'@Subdir src/repo12',
'foo 1.3',
'',
'',
]),
'src/repo12/_cipd': 'foo 1.3',
})
self.assertTree(tree)
def testConvertCipdToGit(self):
self.gclient(['config', self.git_base + 'repo_13', '--name', 'src'])
# repo_13@3 has src/repo12 as a cipd dependency.
out, err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 3),
'--delete_unversioned_trees'])
self.assertEquals(0, rc, out + err)
tree = self.mangle_git_tree(('repo_13@3', 'src'))
tree.update({
'_cipd': '\n'.join([
'$ParanoidMode CheckPresence',
'',
'@Subdir src/repo12',
'foo 1.3',
'',
'',
]),
'src/repo12/_cipd': 'foo 1.3',
})
self.assertTree(tree)
self.gclient(['sync'])
# repo_13@1 has src/repo12 as a git dependency.
out, err, rc = self.gclient(
['sync', '-v', '-v', '-v', '--revision', self.githash('repo_13', 1)])
self.assertEquals(0, rc, out + err)
with open(os.path.join(self.root_dir, '.cipd', 'ensure')) as f:
contents = f.read()
tree = self.mangle_git_tree(('repo_13@1', 'src'),
('repo_12@1', 'src/repo12'))
tree.update({
'_cipd': '$ParanoidMode CheckPresence\n\n',
'src/repo12/_cipd': 'foo 1.3',
})
self.assertTree(tree)
self.assertEqual([
'$ParanoidMode CheckPresence',
'',
'@Subdir src/another_cipd_dep',
'package1 1.1-cr0',
'package2 1.13',
'',
'@Subdir src/cipd_dep',
'package0 0.1',
'',
'@Subdir src/cipd_dep_with_cipd_variable',
'package3/${platform} 1.2',
'',
], contents.splitlines())
if __name__ == '__main__':
......
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