Version 2.13.0-109.0.dev
Merge commit 'ee3dca4b9706d0418e7f47dab5a380edd5ae8334' into 'dev'
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart
new file mode 100644
index 0000000..2bbbfd4
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A<X> {}
+
+A<Function<Y extends Function<Z>(Z)>(Y)> foo() => throw 42;
+
+typedef F<U> = Function<V extends U>(V);
+
+A<F<Function<W>(W)>> bar() => throw 42;
+
+main() {}
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.expect
new file mode 100644
index 0000000..5c86a64
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+typedef F<invariant U extends core::Object? = dynamic> = <V extends U% = dynamic>(V%) → dynamic;
+class A<X extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::A<self::A::X%>
+ : super core::Object::•()
+ ;
+}
+static method foo() → self::A<<Y extends <Z extends core::Object? = dynamic>(Z%) → dynamic = dynamic>(Y) → dynamic>
+ return throw 42;
+static method bar() → self::A<<V extends <W extends core::Object? = dynamic>(W%) → dynamic = dynamic>(V) → dynamic>
+ return throw 42;
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.transformed.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.transformed.expect
new file mode 100644
index 0000000..5c86a64
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.strong.transformed.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+typedef F<invariant U extends core::Object? = dynamic> = <V extends U% = dynamic>(V%) → dynamic;
+class A<X extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::A<self::A::X%>
+ : super core::Object::•()
+ ;
+}
+static method foo() → self::A<<Y extends <Z extends core::Object? = dynamic>(Z%) → dynamic = dynamic>(Y) → dynamic>
+ return throw 42;
+static method bar() → self::A<<V extends <W extends core::Object? = dynamic>(W%) → dynamic = dynamic>(V) → dynamic>
+ return throw 42;
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline.expect
new file mode 100644
index 0000000..e905ef5
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline.expect
@@ -0,0 +1,6 @@
+class A<X> {}
+
+A<Function<Y extends Function<Z>(Z)>(Y)> foo() => throw 42;
+typedef F<U> = Function<V extends U>(V);
+A<F<Function<W>(W)>> bar() => throw 42;
+main() {}
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..5d6b1de
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.textual_outline_modelled.expect
@@ -0,0 +1,7 @@
+A<F<Function<W>(W)>> bar() => throw 42;
+A<Function<Y extends Function<Z>(Z)>(Y)> foo() => throw 42;
+
+class A<X> {}
+
+main() {}
+typedef F<U> = Function<V extends U>(V);
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.expect
new file mode 100644
index 0000000..5c86a64
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+typedef F<invariant U extends core::Object? = dynamic> = <V extends U% = dynamic>(V%) → dynamic;
+class A<X extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::A<self::A::X%>
+ : super core::Object::•()
+ ;
+}
+static method foo() → self::A<<Y extends <Z extends core::Object? = dynamic>(Z%) → dynamic = dynamic>(Y) → dynamic>
+ return throw 42;
+static method bar() → self::A<<V extends <W extends core::Object? = dynamic>(W%) → dynamic = dynamic>(V) → dynamic>
+ return throw 42;
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.outline.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.outline.expect
new file mode 100644
index 0000000..adb3640
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.outline.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+typedef F<invariant U extends core::Object? = dynamic> = <V extends U% = dynamic>(V%) → dynamic;
+class A<X extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::A<self::A::X%>
+ ;
+}
+static method foo() → self::A<<Y extends <Z extends core::Object? = dynamic>(Z%) → dynamic = dynamic>(Y) → dynamic>
+ ;
+static method bar() → self::A<<V extends <W extends core::Object? = dynamic>(W%) → dynamic = dynamic>(V) → dynamic>
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.transformed.expect b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.transformed.expect
new file mode 100644
index 0000000..5c86a64
--- /dev/null
+++ b/pkg/front_end/testcases/generic_metadata/nested_generic_arguments_and_bounds.dart.weak.transformed.expect
@@ -0,0 +1,15 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+typedef F<invariant U extends core::Object? = dynamic> = <V extends U% = dynamic>(V%) → dynamic;
+class A<X extends core::Object? = dynamic> extends core::Object {
+ synthetic constructor •() → self::A<self::A::X%>
+ : super core::Object::•()
+ ;
+}
+static method foo() → self::A<<Y extends <Z extends core::Object? = dynamic>(Z%) → dynamic = dynamic>(Y) → dynamic>
+ return throw 42;
+static method bar() → self::A<<V extends <W extends core::Object? = dynamic>(W%) → dynamic = dynamic>(V) → dynamic>
+ return throw 42;
+static method main() → dynamic {}
diff --git a/tools/VERSION b/tools/VERSION
index 5f3c950..0cee519 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 108
+PRERELEASE 109
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/clean_output_directory.py b/tools/clean_output_directory.py
deleted file mode 100755
index e7233b0..0000000
--- a/tools/clean_output_directory.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-#
-
-import os
-import shutil
-import sys
-import subprocess
-import utils
-
-
-def Main():
- build_root = utils.GetBuildRoot(utils.GuessOS())
- print 'Deleting %s' % build_root
- if sys.platform != 'win32':
- shutil.rmtree(build_root, ignore_errors=True)
- else:
- # Intentionally ignore return value since a directory might be in use.
- subprocess.call(['rmdir', '/Q', '/S', build_root],
- env=os.environ.copy(),
- shell=True)
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(Main())
diff --git a/tools/download_latest_dev_sdk.py b/tools/download_latest_dev_sdk.py
deleted file mode 100755
index 1a30b5e..0000000
--- a/tools/download_latest_dev_sdk.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2016 The Dart project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# This script downloads the latest dev SDK from
-# http://gsdview.appspot.com/dart-archive/channels/dev/raw/latest/sdk/
-# into tools/sdks/. It is intended to be invoked from Jiri hooks in
-# a Fuchsia checkout.
-
-import os
-import sys
-import zipfile
-import urllib
-import utils
-
-HOST_OS = utils.GuessOS()
-HOST_ARCH = utils.GuessArchitecture()
-SCRIPT_DIR = os.path.dirname(sys.argv[0])
-DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
-
-DEFAULT_DART_VERSION = 'latest'
-BASE_URL = 'http://gsdview.appspot.com/dart-archive/channels/dev/raw/%s/sdk/%s'
-
-
-def host_os_for_sdk(host_os):
- if host_os.startswith('macos'):
- return 'mac'
- if host_os.startswith('win'):
- return 'windows'
- return host_os
-
-
-# Python's zipfile doesn't preserve file permissions during extraction, so we
-# have to do it manually.
-def extract_file(zf, info, extract_dir):
- try:
- zf.extract(info.filename, path=extract_dir)
- out_path = os.path.join(extract_dir, info.filename)
- perm = info.external_attr >> 16L
- os.chmod(out_path, perm)
- except IOError as err:
- if 'dart-sdk/bin/dart' in err.filename:
- print(
- 'Failed to extract the new Dart SDK dart binary. ' +
- 'Kill stale instances (like the analyzer) and try the update again'
- )
- return False
- raise
- return True
-
-
-def main(argv):
- host_os = host_os_for_sdk(HOST_OS)
- zip_file = ('dartsdk-%s-x64-release.zip' % HOST_OS)
- sha_file = zip_file + '.sha256sum'
- sdk_path = os.path.join(DART_ROOT, 'tools', 'sdks')
- local_sha_path = os.path.join(sdk_path, sha_file)
- remote_sha_path = os.path.join(sdk_path, sha_file + '.remote')
- zip_path = os.path.join(sdk_path, zip_file)
-
- sdk_version = DEFAULT_DART_VERSION
- sha_url = (BASE_URL % (sdk_version, sha_file))
- zip_url = (BASE_URL % (sdk_version, zip_file))
-
- local_sha = ''
- if os.path.isfile(local_sha_path):
- with open(local_sha_path, 'r') as fp:
- local_sha = fp.read()
-
- remote_sha = ''
- urllib.urlretrieve(sha_url, remote_sha_path)
- with open(remote_sha_path, 'r') as fp:
- remote_sha = fp.read()
- os.remove(remote_sha_path)
-
- if local_sha == '' or local_sha != remote_sha:
- print 'Downloading prebuilt Dart SDK from: ' + zip_url
- urllib.urlretrieve(zip_url, zip_path)
- with zipfile.ZipFile(zip_path, 'r') as zf:
- for info in zf.infolist():
- if not extract_file(zf, info, sdk_path):
- return -1
- with open(local_sha_path, 'w') as fp:
- fp.write(remote_sha)
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/tools/execute_recorded_testcases.py b/tools/execute_recorded_testcases.py
deleted file mode 100755
index 3e8a41d..0000000
--- a/tools/execute_recorded_testcases.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import json
-import subprocess
-import time
-import threading
-
-
-def run_command(name, executable, arguments, timeout_in_seconds):
- print "Running %s: '%s'" % (name, [executable] + arguments)
-
- # The timeout_handler will set this to True if the command times out.
- timeout_value = {'did_timeout': False}
-
- start = time.time()
-
- process = subprocess.Popen(
- [executable] + arguments,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
-
- def timeout_handler():
- timeout_value['did_timeout'] = True
- process.kill()
-
- timer = threading.Timer(timeout_in_seconds, timeout_handler)
- timer.start()
-
- stdout, stderr = process.communicate()
- exit_code = process.wait()
- timer.cancel()
-
- end = time.time()
-
- return (exit_code, stdout, stderr, end - start,
- timeout_value['did_timeout'])
-
-
-def main(args):
- recording_file = args[0]
- result_file = args[1]
-
- with open(recording_file) as fd:
- test_cases = json.load(fd)
-
- for test_case in test_cases:
- name = test_case['name']
- command = test_case['command']
- executable = command['executable']
- arguments = command['arguments']
- timeout_limit = command['timeout_limit']
-
- exit_code, stdout, stderr, duration, did_timeout = (run_command(
- name, executable, arguments, timeout_limit))
-
- test_case['command_output'] = {
- 'exit_code': exit_code,
- 'stdout': stdout,
- 'stderr': stderr,
- 'duration': duration,
- 'did_timeout': did_timeout,
- }
- with open(result_file, 'w') as fd:
- json.dump(test_cases, fd)
-
-
-if __name__ == '__main__':
- if len(sys.argv) != 3:
- print >> sys.stderr, (
- "Usage: %s <input-file.json> <output-file.json>" % sys.argv[0])
- sys.exit(1)
- sys.exit(main(sys.argv[1:]))
diff --git a/tools/list_files.py b/tools/list_files.py
deleted file mode 100755
index 0dfc8b6..0000000
--- a/tools/list_files.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-"""Tool for listing files whose name match a pattern.
-
-If the first argument is 'relative', the script produces paths relative to the
-current working directory. If the first argument is 'absolute', the script
-produces absolute paths.
-
-Usage:
- python tools/list_files.py {absolute, relative} PATTERN DIRECTORY...
-"""
-
-import os
-import re
-import sys
-
-
-def main(argv):
- mode = argv[1]
- if mode not in ['absolute', 'relative']:
- raise Exception("First argument must be 'absolute' or 'relative'")
- pattern = re.compile(argv[2])
- for directory in argv[3:]:
- if mode in 'absolute' and not os.path.isabs(directory):
- directory = os.path.realpath(directory)
- for root, directories, files in os.walk(directory):
- if '.git' in directories:
- directories.remove('.git')
- for filename in files:
- if mode in 'absolute':
- fullname = os.path.join(directory, root, filename)
- else:
- fullname = os.path.relpath(os.path.join(root, filename))
- fullname = fullname.replace(os.sep, '/')
- if re.search(pattern, fullname):
- print (fullname)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/tools/make_bundle_unittest.py b/tools/make_bundle_unittest.py
deleted file mode 100755
index d6c75a0..0000000
--- a/tools/make_bundle_unittest.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-#
-"""Unit tests for make_bundle.py."""
-
-import os
-from os import path
-import shutil
-import subprocess
-import sys
-import tempfile
-import unittest
-
-import make_bundle
-
-
-class BundleMakerTest(unittest.TestCase):
- """Unit test class for BundleMaker."""
-
- def setUp(self):
- self._tempdir = tempfile.mkdtemp()
- self._top_dir = path.normpath(
- path.join(path.dirname(sys.argv[0]), os.pardir))
- self._dest = path.join(self._tempdir, 'new_bundle')
-
- def tearDown(self):
- shutil.rmtree(self._tempdir)
-
- def testBuildOptions(self):
- op = make_bundle.BundleMaker.BuildOptions()
- op.parse_args(args=[])
-
- def testCheckOptions(self):
- op = make_bundle.BundleMaker.BuildOptions()
- options = make_bundle.BundleMaker.CheckOptions(op, self._top_dir,
- ['--dest', self._dest])
- self.failUnless(path.exists(self._dest))
- os.rmdir(self._dest)
- self.assertEquals(self._dest, options['dest'])
- self.assertEquals(self._top_dir, options['top_dir'])
- self.failIf(options['verbose'])
- self.failIf(options['skip_build'])
- options = make_bundle.BundleMaker.CheckOptions(
- op, self._top_dir, ['--dest', self._dest, '-v'])
- self.failUnless(path.exists(self._dest))
- self.assertEquals(self._dest, options['dest'])
- self.assertEquals(self._top_dir, options['top_dir'])
- self.failUnless(options['verbose'])
- self.failIf(options['skip_build'])
-
- def _RunCommand(self, *args):
- proc = subprocess.Popen(
- args,
- cwd=self._dest,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- stdout = proc.communicate()[0]
- self.assertEqual(
- 0, proc.wait(), msg='%s\n%s' % (' '.join(args), stdout))
-
- def testMakeBundle(self):
- os.mkdir(self._dest)
- maker = make_bundle.BundleMaker(dest=self._dest, top_dir=self._top_dir)
- self.assertEquals(0, maker.MakeBundle())
- commands = [
- './dart samples/hello.dart',
- './dart samples/deltablue.dart',
- './dart samples/mandelbrot.dart',
- './dart samples/towers.dart',
- ]
- for command in commands:
- args = command.split(' ')
- self._RunCommand(*args)
- args.append('--arch=dartc')
- self._RunCommand(*args)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tools/only_in_release_mode.py b/tools/only_in_release_mode.py
deleted file mode 100644
index 4e6efc3..0000000
--- a/tools/only_in_release_mode.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-"""
-Wrapper around a build action that should only be executed in release mode.
-
-The mode is defined via an environment variable DART_BUILD_MODE.
-
-The arguments to the script are:
-
- only_in_release_mode.py files... -- command arguments...
-
-If mode is not 'release', the script will create the files listed
-before --. If mode is release, the script will execute the command
-after --.
-"""
-
-import os
-import subprocess
-import sys
-
-
-def Main():
- # Throws an error if '--' is not in the argument list.
- separator_index = sys.argv.index('--')
- outputs = sys.argv[1:separator_index]
- arguments = sys.argv[separator_index + 1:]
- arguments[0] = os.path.normpath(arguments[0])
- mode = os.getenv('DART_BUILD_MODE', 'release')
- if mode != 'release':
- print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode)
- for output in outputs:
- with open(output, 'w'):
- # Create an empty file to ensure that we don't rerun this
- # command unnecessarily.
- pass
- return 0
- else:
- try:
- subprocess.check_call(arguments)
- except subprocess.CalledProcessError as e:
- return e.returncode
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(Main())
diff --git a/tools/revert.py b/tools/revert.py
deleted file mode 100755
index 59d383d..0000000
--- a/tools/revert.py
+++ /dev/null
@@ -1,219 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-import optparse
-import os
-import platform
-import subprocess
-import sys
-"""A script used to revert one or a sequence of consecutive CLs, for svn and
-git-svn users.
-"""
-
-
-def parse_args():
- parser = optparse.OptionParser()
- parser.add_option(
- '--revisions',
- '-r',
- dest='rev_range',
- action='store',
- default=None,
- help='The revision number(s) of the commits '
- 'you wish to undo. An individual number, or a range (8-10, '
- '8..10, or 8:10).')
- args, _ = parser.parse_args()
- revision_range = args.rev_range
- if revision_range is None:
- maybe_fail('You must specify at least one revision number to revert.')
- if revision_range.find('-') > -1 or revision_range.find(':') > -1 or \
- revision_range.find('..') > -1:
- # We have a range of commits to revert.
- split = revision_range.split('-')
- if len(split) == 1:
- split = revision_range.split(':')
- if len(split) == 1:
- split = revision_range.split('..')
- start = int(split[0])
- end = int(split[1])
- if start > end:
- temp = start
- start = end
- end = temp
- if start != end:
- maybe_fail(
- 'Warning: Are you sure you want to revert a range of '
- 'revisions? If you just want to revert one CL, only specify '
- 'one revision number.',
- user_input=True)
- else:
- start = end = int(revision_range)
- return start, end
-
-
-def maybe_fail(msg, user_input=False):
- """Determine if we have encountered a condition upon which our script cannot
- continue, and abort if so.
- Args:
- - msg: The error or user prompt message to print.
- - user_input: True if we require user confirmation to continue. We assume
- that the user must enter y to proceed.
- """
- if user_input:
- force = raw_input(msg + ' (y/N) ')
- if force != 'y':
- sys.exit(0)
- else:
- print msg
- sys.exit(1)
-
-
-def has_new_code(is_git):
- """Tests if there are any newer versions of files on the server.
- Args:
- - is_git: True if we are working in a git repository.
- """
- os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
- if not is_git:
- results, _ = run_cmd(['svn', 'st'])
- else:
- results, _ = run_cmd(['git', 'status'])
- for line in results.split('\n'):
- if not is_git and (not line.strip().startswith('?') and line != ''):
- return True
- elif is_git and ('Changes to be committed' in line or
- 'Changes not staged for commit:' in line):
- return True
- if is_git:
- p = subprocess.Popen(['git', 'log', '-1'],
- stdout=subprocess.PIPE,
- shell=(platform.system() == 'Windows'))
- output, _ = p.communicate()
- if find_git_info(output) is None:
- return True
- return False
-
-
-def run_cmd(cmd_list, suppress_output=False, std_in=''):
- """Run the specified command and print out any output to stdout."""
- print ' '.join(cmd_list)
- p = subprocess.Popen(
- cmd_list,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- stdin=subprocess.PIPE,
- shell=(platform.system() == 'Windows'))
- output, stderr = p.communicate(std_in)
- if output and not suppress_output:
- print output
- if stderr and not suppress_output:
- print stderr
- return output, stderr
-
-
-def runs_git():
- """Returns True if we're standing in an svn-git repository."""
- p = subprocess.Popen(['svn', 'info'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=(platform.system() == 'Windows'))
- output, err = p.communicate()
- if err is not None and 'is not a working copy' in err:
- p = subprocess.Popen(['git', 'status'],
- stdout=subprocess.PIPE,
- shell=(platform.system() == 'Windows'))
- output, _ = p.communicate()
- if 'fatal: Not a git repository' in output:
- maybe_fail('Error: not running git or svn.')
- else:
- return True
- return False
-
-
-def find_git_info(git_log, rev_num=None):
- """Determine the latest svn revision number if rev_num = None, or find the
- git commit_id that corresponds to a particular svn revision number.
- """
- for line in git_log.split('\n'):
- tokens = line.split()
- if len(tokens) == 2 and tokens[0] == 'commit':
- current_commit_id = tokens[1]
- elif len(tokens) > 0 and tokens[0] == 'git-svn-id:':
- revision_number = int(tokens[1].split('@')[1])
- if revision_number == rev_num:
- return current_commit_id
- if rev_num is None:
- return revision_number
-
-
-def revert(start, end, is_git):
- """Revert the sequence of CLs.
- Args:
- - start: The first CL to revert.
- - end: The last CL to revert.
- - is_git: True if we are in a git-svn checkout.
- """
- if not is_git:
- _, err = run_cmd(
- ['svn', 'merge', '-r',
- '%d:%d' % (end, start - 1), '.'], std_in='p')
- if 'Conflict discovered' in err:
- maybe_fail(
- 'Please fix the above conflicts before submitting. Then create'
- ' a CL and submit your changes to complete the revert.')
-
- else:
- # If we're running git, we have to use the log feature to find the commit
- # id(s) that correspond to the particular revision number(s).
- output, _ = run_cmd(['git', 'log', '-1'], suppress_output=True)
- current_revision = find_git_info(output)
- distance = (current_revision - start) + 1
- output, _ = run_cmd(['git', 'log', '-%d' % distance],
- suppress_output=True)
- reverts = [start]
- commit_msg = '"Reverting %d"' % start
- if end != start:
- reverts = range(start, end + 1)
- reverts.reverse()
- commit_msg = '%s-%d"' % (commit_msg[:-1], end)
- for the_revert in reverts:
- git_commit_id = find_git_info(output, the_revert)
- if git_commit_id is None:
- maybe_fail(
- 'Error: Revision number not found. Is this earlier than your'
- ' git checkout history?')
- _, err = run_cmd(['git', 'revert', '-n', git_commit_id])
- if 'error: could not revert' in err or 'unmerged' in err:
- command_sequence = ''
- for a_revert in reverts:
- git_commit_id = find_git_info(output, a_revert)
- command_sequence += 'git revert -n %s\n' % git_commit_id
- maybe_fail(
- 'There are conflicts while reverting. Please resolve these '
- 'after manually running:\n' + command_sequence + 'and then '
- 'create a CL and submit to complete the revert.')
- run_cmd(['git', 'commit', '-m', commit_msg])
-
-
-def main():
- revisions = parse_args()
- git_user = runs_git()
- if has_new_code(git_user):
- maybe_fail(
- 'WARNING: This checkout has local modifications!! This could '
- 'result in a CL that is not just a revert and/or you could lose your'
- ' local changes! Are you **SURE** you want to continue? ',
- user_input=True)
- if git_user:
- run_cmd(['git', 'cl', 'rebase'])
- run_cmd(['gclient', 'sync'])
- revert(revisions[0], revisions[1], git_user)
- print('Now, create a CL and submit! The buildbots and your teammates thank '
- 'you!')
-
-
-if __name__ == '__main__':
- main()
diff --git a/tools/safari_factory_reset.py b/tools/safari_factory_reset.py
deleted file mode 100755
index daf7e41..0000000
--- a/tools/safari_factory_reset.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-import os
-import string
-import subprocess
-import sys
-
-import utils
-
-
-def Main():
- args = sys.argv[1:]
- tools_dir = os.path.dirname(os.path.realpath(__file__))
- dart_script_name = os.path.join(tools_dir, 'testing', 'dart',
- 'reset_safari.dart')
- command = [utils.CheckedInSdkExecutable(), '--checked', dart_script_name
- ] + args
- exit_code = subprocess.call(command)
- utils.DiagnoseExitCode(exit_code, command)
- return exit_code
-
-
-if __name__ == '__main__':
- sys.exit(Main())