Add resource locking in gclient

There are entries in the DEPS file where two folders uses the same
git URL (ie. freetype2).  This doesn't work well with git caches because
each task will run on it's own and might try to clobber on top of each other.

This adds another field in a WorkItem which is a list of resources.  When the
work queue is flushed, it has to make sure that none of a newly added workitem
has any resource conflicts.

BUG=618124

Review-Url: https://codereview.chromium.org/2049583003
diff --git a/gclient.py b/gclient.py
index 3569f8e..9b6a3c0 100755
--- a/gclient.py
+++ b/gclient.py
@@ -375,6 +375,11 @@
     # It will be a dictionary of {deps_name: {"deps_file": depfile_name}} or
     # None.
     self.recursedeps = None
+    # This is inherited from WorkItem.  We want the URL to be a resource.
+    if url and isinstance(url, basestring):
+      # The url is usually given to gclient either as https://blah@123
+      # or just https://blah.  The @123 portion is irrelevent.
+      self.resources.append(url.split('@')[0])
 
     if not self.name and self.parent:
       raise gclient_utils.Error('Dependency without name')