Don't allow package:-URIs as package locations when creating .packages file.

R=pquitslund@google.com

Review URL: https://codereview.chromium.org//1227283002 .
diff --git a/lib/discovery.dart b/lib/discovery.dart
index a399395..8e42af7 100644
--- a/lib/discovery.dart
+++ b/lib/discovery.dart
@@ -179,7 +179,7 @@
 /// script.
 /// The [nonFileUri] should not be a `file:` URI since the algorithm for
 /// finding a package resolution strategy is more elaborate for `file:` URIs.
-/// In that case, use [findPackagesFile].
+/// In that case, use [findPackagesFromFile].
 ///
 /// This function first tries to locate a `.packages` file in the [nonFileUri]
 /// directory. If that is not found, it instead assumes a `packages/` directory
diff --git a/lib/packages_file.dart b/lib/packages_file.dart
index 73e6061..25d2d68 100644
--- a/lib/packages_file.dart
+++ b/lib/packages_file.dart
@@ -80,6 +80,9 @@
 ///
 /// If [baseUri] is provided, package locations will be made relative
 /// to the base URI, if possible, before writing.
+///
+/// All the keys of [packageMapping] must be valid package names,
+/// and the values must be URIs that do not have the `package:` scheme.
 void write(StringSink output, Map<String, Uri> packageMapping,
            {Uri baseUri, String comment}) {
   if (baseUri != null && !baseUri.isAbsolute) {
@@ -104,6 +107,10 @@
     if (!isValidPackageName(packageName)) {
       throw new ArgumentError('"$packageName" is not a valid package name');
     }
+    if (uri.scheme == "package") {
+      throw new ArgumentError.value(
+          "Package location must not be a package: URI", uri);
+    }
     output.write(packageName);
     output.write(':');
     // If baseUri provided, make uri relative.
diff --git a/pubspec.yaml b/pubspec.yaml
index 7240680..d3acb90 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: package_config
-version: 0.1.1
+version: 0.1.2
 description: Support for working with Package Resolution config files.
 author: Dart Team <misc@dartlang.org>
 homepage: https://github.com/dart-lang/package_config