From ae6e0949d187c35d79dbc0b21788fdbb2c65bf78 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 6 Nov 2008 10:25:35 -0800 Subject: [PATCH] Add 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 --- docs/manifest-format.txt | 13 ++++++++++--- manifest.py | 9 ++++++++- project.py | 4 +++- remote.py | 6 +++++- 4 files changed, 26 insertions(+), 6 deletions(-) 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 @@ following DTD: - - - + + + + @@ -67,6 +68,12 @@ Attribute `review`: Hostname of the Gerrit server where reviews 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 @@ class Manifest(object): 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 @@ class Project(object): 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 = []