Add <remote project-name="..."> attribute within projects

By setting a project-name on a remote nested within a project forks
of a project like the Linux kernel can be easily handled by fetching
all relevant forks into the same client side project under different
remote names.  Developers can create branches off different remotes
using `git checkout --track -b $myname $remote/$branch` and later
`repo upload` automatically redirects to the proper fork project
in the code review server.

Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt
index 409524b..2b49d46 100644
--- a/docs/manifest-format.txt
+++ b/docs/manifest-format.txt
@@ -23,9 +23,10 @@
   <!ELEMENT manifest (remote*, default?, project*)>
 
   <!ELEMENT remote (EMPTY)>
-  <!ATTLIST remote name   ID    #REQUIRED>
-  <!ATTLIST remote fetch  CDATA #REQUIRED>
-  <!ATTLIST remote review CDATA #IMPLIED>
+  <!ATTLIST remote name         ID    #REQUIRED>
+  <!ATTLIST remote fetch        CDATA #REQUIRED>
+  <!ATTLIST remote review       CDATA #IMPLIED>
+  <!ATTLIST remote project-name CDATA #IMPLIED>
 
   <!ELEMENT default (EMPTY)>
   <!ATTLIST default remote   IDREF #IMPLIED>
@@ -67,6 +68,12 @@
 are uploaded to by `repo upload`.  This attribute is optional;
 if not specified then `repo upload` will not function.
 
+Attribute `project-name`: Specifies the name of this project used
+by the review server given in the review attribute of this element.
+Only permitted when the remote element is nested inside of a project
+element (see below).  If not given, defaults to the name supplied
+in the project's name attribute.
+
 
 Element default
 ---------------
diff --git a/manifest.py b/manifest.py
index ea68b68..6545568 100644
--- a/manifest.py
+++ b/manifest.py
@@ -206,10 +206,17 @@
     name = self._reqatt(node, 'name')
     fetch = self._reqatt(node, 'fetch')
     review = node.getAttribute('review')
+    if review == '':
+      review = None
+
+    projectName = node.getAttribute('project-name')
+    if projectName == '':
+      projectName = None
 
     r = Remote(name=name,
                fetch=fetch,
-               review=review)
+               review=review,
+               projectName=projectName)
 
     for n in node.childNodes:
       if n.nodeName == 'require':
diff --git a/project.py b/project.py
index 2a4adf7..9509cb9 100644
--- a/project.py
+++ b/project.py
@@ -904,7 +904,9 @@
       remote = self.GetRemote(r.name)
       remote.url = r.fetchUrl
       remote.review = r.reviewUrl
-      if remote.projectname is None:
+      if r.projectName:
+        remote.projectname = r.projectName
+      elif remote.projectname is None:
         remote.projectname = self.name
       remote.ResetFetch()
       remote.Save()
diff --git a/remote.py b/remote.py
index 27a8f7a..3bc30a5 100644
--- a/remote.py
+++ b/remote.py
@@ -14,8 +14,12 @@
 # limitations under the License.
 
 class Remote(object):
-  def __init__(self, name, fetch=None, review=None):
+  def __init__(self, name,
+               fetch=None,
+               review=None,
+               projectName=None):
     self.name = name
     self.fetchUrl = fetch
     self.reviewUrl = review
+    self.projectName = projectName
     self.requiredCommits = []