]> git.sur5r.net Git - u-boot/commitdiff
buildman: Allow specifying a range of commits to build
authorSimon Glass <sjg@chromium.org>
Tue, 2 Dec 2014 00:33:57 +0000 (17:33 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 15 Jan 2015 05:16:53 +0000 (21:16 -0800)
Adjust the -b flag to permit a range expression as well as a branch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Tested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
tools/buildman/README
tools/buildman/control.py
tools/patman/gitutil.py

index 8e7a68c34ff3d7b8b1448401e85091537cb4c4a3..68456ceff73c7f4202cecbde3c84a4160e7dfc94 100644 (file)
@@ -699,6 +699,17 @@ build the selected boards and display build status as it runs (i.e. -v is
 enabled automatically). Use -e to see errors/warnings as well.
 
 
+Building Ranges
+===============
+
+You can build a range of commits by specifying a range instead of a branch
+when using the -b flag. For example:
+
+    upstream/master..us-buildman
+
+will build commits in us-buildman that are not in upstream/master.
+
+
 Other options
 =============
 
index 2249b0f70036cb4d0a7a1d0bb41bac92f446c882..e10ed867fb371d176acfb370195b5f52775e364c 100644 (file)
@@ -123,14 +123,22 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
     # problems introduced by the first commit on the branch.
     col = terminal.Color()
     count = options.count
+    has_range = options.branch and '..' in options.branch
     if count == -1:
         if not options.branch:
             count = 1
         else:
-            count, msg = gitutil.CountCommitsInBranch(options.git_dir,
-                                                      options.branch)
+            if has_range:
+                count, msg = gitutil.CountCommitsInRange(options.git_dir,
+                                                         options.branch)
+            else:
+                count, msg = gitutil.CountCommitsInBranch(options.git_dir,
+                                                          options.branch)
             if count is None:
                 sys.exit(col.Color(col.RED, msg))
+            elif count == 0:
+                sys.exit(col.Color(col.RED, "Range '%s' has no commits" %
+                                   options.branch))
             if msg:
                 print col.Color(col.YELLOW, msg)
             count += 1   # Build upstream commit also
@@ -172,8 +180,11 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
     # to overwrite earlier ones by setting allow_overwrite=True
     if options.branch:
         if count == -1:
-            range_expr = gitutil.GetRangeInBranch(options.git_dir,
-                                                  options.branch)
+            if has_range:
+                range_expr = options.branch
+            else:
+                range_expr = gitutil.GetRangeInBranch(options.git_dir,
+                                                      options.branch)
             upstream_commit = gitutil.GetUpstream(options.git_dir,
                                                   options.branch)
             series = patchstream.GetMetaDataForList(upstream_commit,
index 34c6b04853e0280635989676642542b443c89299..cc5a55ab3ffefd7fce9c0107c9470bbd0d05ed2e 100644 (file)
@@ -154,6 +154,24 @@ def GetRangeInBranch(git_dir, branch, include_upstream=False):
     rstr = '%s%s..%s' % (upstream, '~' if include_upstream else '', branch)
     return rstr, msg
 
+def CountCommitsInRange(git_dir, range_expr):
+    """Returns the number of commits in the given range.
+
+    Args:
+        git_dir: Directory containing git repo
+        range_expr: Range to check
+    Return:
+        Number of patches that exist in the supplied rangem or None if none
+        were found
+    """
+    pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True)]
+    result = command.RunPipe(pipe, capture=True, capture_stderr=True,
+                             raise_on_error=False)
+    if result.return_code:
+        return None, "Range '%s' not found or is invalid" % range_expr
+    patch_count = len(result.stdout.splitlines())
+    return patch_count, None
+
 def CountCommitsInBranch(git_dir, branch, include_upstream=False):
     """Returns the number of commits in the given branch.
 
@@ -167,11 +185,7 @@ def CountCommitsInBranch(git_dir, branch, include_upstream=False):
     range_expr, msg = GetRangeInBranch(git_dir, branch, include_upstream)
     if not range_expr:
         return None, msg
-    pipe = [LogCmd(range_expr, git_dir=git_dir, oneline=True),
-            ['wc', '-l']]
-    result = command.RunPipe(pipe, capture=True, oneline=True)
-    patch_count = int(result.stdout)
-    return patch_count, msg
+    return CountCommitsInRange(git_dir, range_expr)
 
 def CountCommits(commit_range):
     """Returns the number of commits in the given range.