Explorar el Código

Add branch support to repo upload

This commit adds a --br=<branch> option to repo upload.

repo currently examines every non-published branch. This is problematic
for my workflow. I have many branches in my kernel tree. Many of these
branches are based off of upstream remotes (I have many remotes) and
will never be uploaded (they'll get sent upstream as a patch).

Having repo scan these branches adds to my upload processing time
and clutters the branch selection buffer. I've also seen repo get
confused when one of my branches is 1000s of commits different from
m/master.

Change-Id: I68fa18951ea59ba373277b57ffcaf8cddd7e7a40
Mandeep Singh Baines hace 14 años
padre
commit
d6c93a28ca
Se han modificado 2 ficheros con 11 adiciones y 2 borrados
  1. 3 1
      project.py
  2. 8 1
      subcmds/upload.py

+ 3 - 1
project.py

@@ -791,7 +791,7 @@ class Project(object):
       if R_HEADS + n not in heads:
       if R_HEADS + n not in heads:
         self.bare_git.DeleteRef(name, id)
         self.bare_git.DeleteRef(name, id)
 
 
-  def GetUploadableBranches(self):
+  def GetUploadableBranches(self, selected_branch=None):
     """List any branches which can be uploaded for review.
     """List any branches which can be uploaded for review.
     """
     """
     heads = {}
     heads = {}
@@ -807,6 +807,8 @@ class Project(object):
     for branch, id in heads.iteritems():
     for branch, id in heads.iteritems():
       if branch in pubed and pubed[branch] == id:
       if branch in pubed and pubed[branch] == id:
         continue
         continue
+      if selected_branch and branch != selected_branch:
+        continue
 
 
       rb = self.GetUploadableBranch(branch)
       rb = self.GetUploadableBranch(branch)
       if rb:
       if rb:

+ 8 - 1
subcmds/upload.py

@@ -120,6 +120,9 @@ Gerrit Code Review:  http://code.google.com/p/gerrit/
     p.add_option('--cc',
     p.add_option('--cc',
                  type='string',  action='append', dest='cc',
                  type='string',  action='append', dest='cc',
                  help='Also send email to these email addresses.')
                  help='Also send email to these email addresses.')
+    p.add_option('--br',
+                 type='string',  action='store', dest='branch',
+                 help='Branch to upload.')
 
 
     # Options relating to upload hook.  Note that verify and no-verify are NOT
     # Options relating to upload hook.  Note that verify and no-verify are NOT
     # opposites of each other, which is why they store to different locations.
     # opposites of each other, which is why they store to different locations.
@@ -336,9 +339,13 @@ Gerrit Code Review:  http://code.google.com/p/gerrit/
     pending = []
     pending = []
     reviewers = []
     reviewers = []
     cc = []
     cc = []
+    branch = None
+
+    if opt.branch:
+      branch = opt.branch
 
 
     for project in project_list:
     for project in project_list:
-      avail = project.GetUploadableBranches()
+      avail = project.GetUploadableBranches(branch)
       if avail:
       if avail:
         pending.append((project, avail))
         pending.append((project, avail))