From 35f2596c27ae041235b88076888870b8ba2e2c8c Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 11 Nov 2008 17:03:13 -0800 Subject: [PATCH] Refactor part of GetUploadableBranches to lookup one specific branch This way project.GetUploadableBranch(project.CurrentBranch) can tell us how (if at all) to upload the currently checked out branch. Signed-off-by: Shawn O. Pearce --- project.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/project.py b/project.py index 9509cb98..1e25c2c9 100644 --- a/project.py +++ b/project.py @@ -428,14 +428,22 @@ class Project(object): if branch in pubed and pubed[branch] == id: continue - branch = self.GetBranch(branch) - base = branch.LocalMerge - if branch.LocalMerge: - rb = ReviewableBranch(self, branch, base) - if rb.commits: - ready.append(rb) + rb = self.GetUploadableBranch(branch) + if rb: + ready.append(rb) return ready + def GetUploadableBranch(self, branch_name): + """Get a single uploadable branch, or None. + """ + branch = self.GetBranch(branch_name) + base = branch.LocalMerge + if branch.LocalMerge: + rb = ReviewableBranch(self, branch, base) + if rb.commits: + return rb + return None + def UploadForReview(self, branch=None): """Uploads the named branch for code review. """