Teach update_from_chromium.py to preserve certain files through roll.

This CL adds a step to the process of rolling from Chromium wherein a specified
set of files have their contents preserved through the roll even though they
live in directories rolled in from Chromium.

The first usage of this infrastructure is to support the existence of a
//build/config/mojo.gni file that differs between Mojo and Chromium.

//build/config/mojo.gni will start being used in a followup CL.

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/864953003
diff --git a/build/config/mojo.gni b/build/config/mojo.gni
new file mode 100644
index 0000000..88961c2
--- /dev/null
+++ b/build/config/mojo.gni
@@ -0,0 +1,6 @@
+# Copyright 2015 The Chromium 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 variable should point to the parent directory of the Mojo SDK.
+mojo_sdk_root = "//"
diff --git a/mojo/tools/roll/update_from_chromium.py b/mojo/tools/roll/update_from_chromium.py
index 3e210f9..a446d24 100755
--- a/mojo/tools/roll/update_from_chromium.py
+++ b/mojo/tools/roll/update_from_chromium.py
@@ -87,6 +87,10 @@
 files_to_copy = ["sandbox/sandbox_export.h",
     ".clang-format"]
 
+# The contents of these files before the roll will be preserved after the roll,
+# even though they live in directories rolled in from Chromium.
+files_not_to_roll = [ "build/config/mojo.gni" ]
+
 dirs = dirs_to_snapshot + net_dirs
 
 def chromium_rev_number(src_commit):
@@ -122,8 +126,17 @@
       "snapshot of things imported from chromium.")
   parser.add_argument("chromium_dir", help="chromium source dir")
   args = parser.parse_args()
+  pre_roll_commit = system(
+      ["git", "rev-parse", "HEAD"], cwd=mojo_root_dir).strip()
+
   rev(args.chromium_dir)
   patch.patch()
+
+  print "Restoring files whose contents don't track Chromium"
+  for f in files_not_to_roll:
+    system(["git", "checkout", pre_roll_commit, "--", f], cwd=mojo_root_dir)
+  if files_not_to_roll:
+    commit("Restored pre-roll versions of files that don't get rolled")
   return 0
 
 if __name__ == "__main__":