From patchwork Fri May 3 00:46:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 241122 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 389242C00AB for ; Fri, 3 May 2013 10:46:48 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8A32A4A321; Fri, 3 May 2013 02:46:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UUN+lE2IC9zt; Fri, 3 May 2013 02:46:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 74FD14A338; Fri, 3 May 2013 02:46:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C471B4A320 for ; Fri, 3 May 2013 02:46:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KIAyfnqXg8VN for ; Fri, 3 May 2013 02:46:23 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ye0-f201.google.com (mail-ye0-f201.google.com [209.85.213.201]) by theia.denx.de (Postfix) with ESMTPS id 0815F4A321 for ; Fri, 3 May 2013 02:46:15 +0200 (CEST) Received: by mail-ye0-f201.google.com with SMTP id m14so127730yen.2 for ; Thu, 02 May 2013 17:46:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=vJwQTwNI1ZzXC+QEVtngoPsH37zAZgvk9qE6WjEkMRE=; b=iyVzxFugz4d5oMq49iQN0Yghr4gigpmmYGLnw7eTRp3sM8b98XbBGyBtyMHZvlwo/5 e+y6wuQGcjKxGeCJAPqPxZeeK6dG5sAdLE8e0uRII5hAYZZfNmL9uc3prfexCcOurfTj 28BStp6XfruEwBOzPiLaj2a0sEj7b28ovekMnzGO05Qo5R4rye5BXLPhRGD/03c+4oP+ d1+dO1F6MU53PJSwZDvM/HW7NLdwFO3lF0eq7FdQHaP8T8Gv/VrM26iGxdxWM9ppx0kr Bzsq+tg5g5+PeE/2pAspgEAVVDActr8ed7ozC2zIlKf432O1bYqFKWmvCfRSIsmBerti u0sQ== X-Received: by 10.236.28.43 with SMTP id f31mr4023426yha.1.1367541973662; Thu, 02 May 2013 17:46:13 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id n23si749668yhi.7.2013.05.02.17.46.13 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Thu, 02 May 2013 17:46:13 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 811215A420E; Thu, 2 May 2013 17:46:13 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 3AE09160978; Thu, 2 May 2013 17:46:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 2 May 2013 17:46:03 -0700 Message-Id: <1367541963-21649-2-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1367541963-21649-1-git-send-email-sjg@chromium.org> References: <1367541963-21649-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQl5+CwYSmpGvAGUtFyGEnDly889KoGss3TY6dK3nO95YgIsvSD6cFE2h17TbY4D0IOieiQpK7t6ULC7H8D5RDikyhaRIkPtryH4RxwxNogHM+GPDQcikIec6mqUSTu6QwDdjsLT6uK6iYIX2f8th/ECe3dQsk4alZwwt91ucDl8MPr0GrpXNDeGLT8j3FlHEEjuPcB0 Cc: Tom Rini Subject: [U-Boot] [PATCH 2/2] buildman: Produce a sensible error message when branch is missing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Rather than a backtrace, produce a nice error message when an invalid branch is provided to buildman. Signed-off-by: Simon Glass --- tools/buildman/control.py | 4 ++++ tools/patman/gitutil.py | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 1ce8b6f..85a4a34 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -111,6 +111,10 @@ def DoBuildman(options, args): print col.Color(col.RED, str) sys.exit(1) count = gitutil.CountCommitsInBranch(options.git_dir, options.branch) + if count is None: + str = "Branch '%s' not found or has no upstream" % options.branch + print col.Color(col.RED, str) + sys.exit(1) count += 1 # Build upstream commit also if not count: diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index e31da15..b7f6739 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -56,10 +56,14 @@ def GetUpstream(git_dir, branch): Returns: Name of upstream branch (e.g. 'upstream/master') or None if none """ - remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config', - 'branch.%s.remote' % branch) - merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config', - 'branch.%s.merge' % branch) + try: + remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config', + 'branch.%s.remote' % branch) + merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config', + 'branch.%s.merge' % branch) + except: + return None + if remote == '.': return merge elif remote and merge: @@ -78,9 +82,11 @@ def GetRangeInBranch(git_dir, branch, include_upstream=False): branch: Name of branch Return: Expression in the form 'upstream..branch' which can be used to - access the commits. + access the commits. If the branch does not exist, returns None. """ upstream = GetUpstream(git_dir, branch) + if not upstream: + return None return '%s%s..%s' % (upstream, '~' if include_upstream else '', branch) def CountCommitsInBranch(git_dir, branch, include_upstream=False): @@ -90,9 +96,12 @@ def CountCommitsInBranch(git_dir, branch, include_upstream=False): git_dir: Directory containing git repo branch: Name of branch Return: - Number of patches that exist on top of the branch + Number of patches that exist on top of the branch, or None if the + branch does not exist. """ range_expr = GetRangeInBranch(git_dir, branch, include_upstream) + if not range_expr: + return None pipe = [['git', '--git-dir', git_dir, 'log', '--oneline', '--no-decorate', range_expr], ['wc', '-l']]