Add the ability to check out a single file from a repo.

The syntax is:
deps {
  'path': File('http://svn..../path/file@42')
}

This will checkout a single file and use scm.update to
keep it up to date.

See https://bugs.webkit.org/show_bug.cgi?id=36578#c7 for a
description of why I want to add this.

Review URL: http://codereview.chromium.org/1356005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@43911 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 4363763..3a3bd1a 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -97,8 +97,8 @@
     if file_list is None:
       file_list = []
 
-    commands = ['cleanup', 'export', 'update', 'revert', 'revinfo',
-                'status', 'diff', 'pack', 'runhooks']
+    commands = ['cleanup', 'export', 'update', 'updatesingle', 'revert',
+                'revinfo', 'status', 'diff', 'pack', 'runhooks']
 
     if not command in commands:
       raise gclient_utils.Error('Unknown command %s' % command)
@@ -746,6 +746,20 @@
       command.extend(['--revision', str(revision)])
     scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list)
 
+  def updatesingle(self, options, args, file_list):
+    checkout_path = os.path.join(self._root_dir, self.relpath)
+    filename = args.pop()
+    if not os.path.exists(checkout_path):
+      # Create an empty checkout and then update the one file we want.  Future
+      # operations will only apply to the one file we checked out.
+      command = ["checkout", "--depth", "empty", self.url, checkout_path]
+      scm.SVN.Run(command, self._root_dir)
+      command = ["update", filename]
+      scm.SVN.RunAndGetFileList(options, command, checkout_path, file_list)
+    # After the initial checkout, we can use update as if it were any other
+    # dep.
+    self.update(options, args, file_list)
+
   def revert(self, options, args, file_list):
     """Reverts local modifications. Subversion specific.