Update script to roll chrome DEPS for all our variants

See instructions in file to set up.
Roll dartium:
> ./dartium_tools/update_deps.py

Roll multivm:
> ./dartium_tools/update_deps.py --target=multivm

Roll dartium clank:
> ./dartium_tools/update_deps.py --target=clank

Roll integration branch:
> ./dartium_tools/update_deps.py --target=integration

R=jacobr@google.com

Review URL: https://chromiumcodereview.appspot.com/243953003

git-svn-id: svn://svn.chromium.org/chrome/branches/dart/1847/src@264987 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/dartium_tools/update_deps.py b/dartium_tools/update_deps.py
index 0b675a1..b66efee 100755
--- a/dartium_tools/update_deps.py
+++ b/dartium_tools/update_deps.py
@@ -17,11 +17,11 @@
 #      > mkdir /usr/local/google/home/$USER/dartium_deps_updater
 #      > cd /usr/local/google/home/$USER/dartium_deps_updater
 #
-#  (b) Checkout a copy of the DEPS for the updater to process / update:
-#      > svn co https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps
+#  (b) Make a 'deps' directory to store temporary files:
+#      > mkdir deps
 #
-#  (c) Checkout dartium_tools (with this script) using the current branch instead of 1750:
-#      > svn co svn://svn.chromium.org/chrome/branches/dart/1750/src/dartium_tools
+#  (c) Checkout dartium_tools (with this script) using the current branch instead of 1847:
+#      > svn co svn://svn.chromium.org/chrome/branches/dart/1847/src/dartium_tools
 #
 #  (d) If your home directory is remote, consider redefining it for this shell/script:
 #      > cp -R $HOME/.subversion /usr/local/google/home/$USER
@@ -29,6 +29,9 @@
 #
 #  (e) Test by running (Ctrl-C to quit):
 #      > ./dartium_tools/update_deps.py
+#      > ./dartium_tools/update_deps.py --target=multivm
+#      > ./dartium_tools/update_deps.py --target=clank
+#      > ./dartium_tools/update_deps.py --target=integration
 #
 #  (f) Run periodical update:
 #      > while true; do ./dartium_tools/update_deps.py --force ; sleep 300 ; done
@@ -37,6 +40,37 @@
 # Repositories to auto-update
 ########################################################################
 
+BRANCH_CURRENT="dart/1847"
+BRANCH_NEXT="dart/1908"
+BRANCH_MULTIVM="dart/multivm"
+
+TARGETS = {
+  'dartium': (
+    'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps',
+    'dartium',
+    ['webkit', 'chromium'],
+    BRANCH_CURRENT,
+    ),
+  'integration': (
+    'https://dart.googlecode.com/svn/branches/dartium_integration/deps/dartium.deps',
+    'dartium',
+    ['webkit', 'chromium'],
+    BRANCH_NEXT,
+    ),
+  'clank': (
+    'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/clank.deps',
+    'dartium',
+    ['webkit', 'chromium'],
+    BRANCH_CURRENT,
+    ),
+  'multivm': (
+    'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/multivm.deps',
+    'multivm',
+    ['blink'],
+    BRANCH_MULTIVM,
+    ),
+}
+
 # Each element in this map represents a repository to update.  Entries
 # take the form:
 #  (repo_tag: (svn_url, view_url))
@@ -50,11 +84,14 @@
 # used to generated the commit message.
 REPOSITORY_INFO = {
     'webkit': (
-        'http://src.chromium.org/blink/branches/dart/1750',
-        'http://src.chromium.org/viewvc/blink/branches/dart/1750?view=rev&revision=%s'),
+        'http://src.chromium.org/blink/branches/%s',
+        'http://src.chromium.org/viewvc/blink?view=rev&revision=%s'),
+    'blink': (
+        'http://src.chromium.org/blink/branches/%s',
+        'http://src.chromium.org/viewvc/blink?view=rev&revision=%s'),
     'chromium': (
-        'http://src.chromium.org/chrome/branches/dart/1750/src',
-        'http://src.chromium.org/viewvc/chrome/branches/dart/1750/src?view=rev&revision=%s'),
+        'http://src.chromium.org/chrome/branches/%s',
+        'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'),
 }
 
 REPOSITORIES = REPOSITORY_INFO.keys()
@@ -148,31 +185,37 @@
 
 def main():
   option_parser = optparse.OptionParser()
+  option_parser.add_option('', '--target', help="Update one of [dartium|integration|multivm|clank]", action="store", dest="target", default="dartium")
   option_parser.add_option('', '--force', help="Push DEPS update to server without prompting", action="store_true", dest="force")
   options, args = option_parser.parse_args()
 
-  src_dir = "/usr/local/google/home/%s/dartium_deps_updater/dartium.deps" % os.environ["USER"]
+  target = options.target
+  if not target in TARGETS.keys():
+    print "Error: invalid target"
+    print "Choose one of " + str(TARGETS)
+  (deps_dir, prefix, repos, branch) = TARGETS[target]
+  deps_file = deps_dir + '/DEPS'
+
+  src_dir = "/usr/local/google/home/%s/dartium_deps_updater/deps/%s" % (os.environ["USER"], target)
   os.putenv("GIT_PAGER", "")
 
   if not os.path.exists(src_dir):
-    print "Error: prior to running this script, you need to check out a Dartium source tree at"
-    print "  %s" % src_dir
-    print "Please reserve the above directory for this script and do not use it for other purposes."
-    sys.exit(1)
+    print run_cmd(['svn', 'co', deps_dir, src_dir])
 
   os.chdir(src_dir)
 
   # parse DEPS
-  deps = run_cmd(['svn', 'cat', 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps/DEPS'])
+  deps = run_cmd(['svn', 'cat', deps_file])
   rev_num = {}
-  for repo in REPOSITORIES:
-    revision = 'dartium_%s_revision":\s*"(.+)"' % repo
+  for repo in repos:
+    revision = '%s_%s_revision":\s*"(.+)"' % (prefix, repo)
     rev_num[repo] = re.search(revision, deps).group(1)
 
   # update repos
   all_revs = []
-  for repo, (svn_url, _) in REPOSITORY_INFO.items():
-    output = run_cmd(["svn", "log",  "-r", "HEAD:%s" % rev_num[repo], svn_url])
+  for repo in repos:
+    (svn_url, _) = REPOSITORY_INFO[repo]
+    output = run_cmd(["svn", "log",  "-r", "HEAD:%s" % rev_num[repo], svn_url % branch])
     revs = parse_svn_log(output, repo)
     if revs and revs[-1]['rev'] == rev_num[repo]:
       revs.pop()
@@ -183,8 +226,8 @@
 
   print
   print "Current DEPS revisions:"
-  for repo in REPOSITORIES:
-    print '  dartium_%s_revision=%s' % (repo, rev_num[repo])
+  for repo in repos:
+    print '  %s_%s_revision=%s' % (prefix, repo, rev_num[repo])
 
   if len(pending_updates) == 0:
     print "DEPS is up-to-date."
@@ -200,8 +243,8 @@
   print run_cmd(['svn', 'update'])
   s = pending_updates[0]
 
-  pattern = re.compile('dartium_' + s['repo'] + '_revision":\s*"(.+)"')
-  new_deps = pattern.sub('dartium_' + s['repo'] + '_revision": "' + s['rev'] + '"', deps)
+  pattern = re.compile(prefix + '_' + s['repo'] + '_revision":\s*"(.+)"')
+  new_deps = pattern.sub(prefix + '_' + s['repo'] + '_revision": "' + s['rev'] + '"', deps)
   write_file('DEPS', new_deps)
 
   commit_log = 'DEPS AutoUpdate: %s to %s (%s) %s\n' % (s['repo'], s['rev'], s['isotime'], s['author'])