diff --git a/manifest_xml.py b/manifest_xml.py index 39656975..68ead53c 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -887,13 +887,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md if groups: p.groups.extend(groups) if revision: - p.revisionExpr = revision - if IsId(revision): - p.revisionId = revision - else: - p.revisionId = None + p.SetRevision(revision) + if remote: p.remote = remote.ToRemoteSpec(name) + if dest_path: del self._paths[p.relpath] relpath, worktree, gitdir, objdir, _ = self.GetProjectPaths(name, dest_path) diff --git a/project.py b/project.py index 9ff9df0b..5b26b64c 100644 --- a/project.py +++ b/project.py @@ -520,14 +520,7 @@ class Project(object): self.name = name self.remote = remote self.UpdatePaths(relpath, worktree, gitdir, objdir) - self.revisionExpr = revisionExpr - - if revisionId is None \ - and revisionExpr \ - and IsId(revisionExpr): - self.revisionId = revisionExpr - else: - self.revisionId = revisionId + self.SetRevision(revisionExpr, revisionId=revisionId) self.rebase = rebase self.groups = groups @@ -557,6 +550,14 @@ class Project(object): # project containing repo hooks. self.enabled_repo_hooks = [] + def SetRevision(self, revisionExpr, revisionId=None): + """Set revisionId based on revision expression and id""" + self.revisionExpr = revisionExpr + if revisionId is None and revisionExpr and IsId(revisionExpr): + self.revisionId = self.revisionExpr + else: + self.revisionId = revisionId + def UpdatePaths(self, relpath, worktree, gitdir, objdir): """Update paths used by this project""" self.gitdir = gitdir.replace('\\', '/')