public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 07/17] buildman: Allow specifying a range of commits to build
Date: Sun, 14 Dec 2014 18:30:00 +0100	[thread overview]
Message-ID: <548DC918.90404@gmail.com> (raw)
In-Reply-To: <1417480447-5763-8-git-send-email-sjg@chromium.org>

Hi Simon,

On 02.12.2014 01:33, Simon Glass wrote:
> 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>

works great, thanks.

Tested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

> ---
> 
>  tools/buildman/README     | 11 +++++++++++
>  tools/buildman/control.py | 19 +++++++++++++++----
>  tools/patman/gitutil.py   | 24 +++++++++++++++++++-----
>  3 files changed, 45 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/buildman/README b/tools/buildman/README
> index db1ec68..0500ce5 100644
> --- a/tools/buildman/README
> +++ b/tools/buildman/README
> @@ -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
>  =============
>  
> diff --git a/tools/buildman/control.py b/tools/buildman/control.py
> index 331b4f9..6a6743e 100644
> --- a/tools/buildman/control.py
> +++ b/tools/buildman/control.py
> @@ -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,
> diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
> index 34c6b04..cc5a55a 100644
> --- a/tools/patman/gitutil.py
> +++ b/tools/patman/gitutil.py
> @@ -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.
> 

-- 
- Daniel

  reply	other threads:[~2014-12-14 17:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02  0:33 [U-Boot] [PATCH 0/17] buildman: A few more features and improvements (Christmas edition) Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 01/17] buildman: Add tests that check the correct output directory is used Simon Glass
2014-12-16  4:54   ` Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 02/17] buildman: Put build in 'current', not 'current/current' Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 03/17] buildman: Don't prune output space for 'current source' build Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 04/17] buildman: Try to guess the upstream commit Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 05/17] buildman: Add an option to flatten output directory trees Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 06/17] buildman: Don't remove entire output directory when testing Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 07/17] buildman: Allow specifying a range of commits to build Simon Glass
2014-12-14 17:30   ` Daniel Schwierzeck [this message]
2014-12-02  0:33 ` [U-Boot] [PATCH 08/17] buildman: Try to avoid hard-coded string parsing Simon Glass
2014-12-02  0:33 ` [U-Boot] [PATCH 09/17] buildman: Put the toolchain path first instead of last in PATH Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 10/17] buildman: Add an option to use the full tool chain path Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 11/17] buildman: Add a note about Python pre-requisites Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 12/17] buildman: Add documentation about the .buildman file Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 13/17] buildman: Don't complain about missing sections in ~/.buildman Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 14/17] buildman: Don't use the local settings when running tests Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 15/17] buildman: Allow architecture to alias to multiple toolchains Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 16/17] buildman: Add the option to download toolchains from kernel.org Simon Glass
2014-12-02  0:34 ` [U-Boot] [PATCH 17/17] buildman: Add an option to write the full build output Simon Glass
2014-12-02  0:50 ` [U-Boot] [PATCH 0/17] buildman: A few more features and improvements (Christmas edition) Simon Glass
2014-12-10  5:29   ` Simon Glass
2014-12-10 19:58     ` Steve Rae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=548DC918.90404@gmail.com \
    --to=daniel.schwierzeck@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox