Skip to contentSkip to conversation

buildman: Allow conflicting tags to avoid spurious errors

PATCH New Simon Glass 2 participants 5 messages May 3, 2013 – May 13, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 buildman: Allow conflicting tags to avoid spurious errors

Conflicting tags can prevent buildman from building two series which exist one after the other in a branch. There is no reason not to allow this sort of workflow with buildman, so ignore conflicting tags in buildman.

---
 tools/buildman/control.py | 5 +++++
 tools/patman/series.py    | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
tools/buildman/control.py +5 -0
index 8d7b9b5..1ce8b6f 100644
@@ -137,6 +137,11 @@ def DoBuildman(options, args):
     upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch)
     series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir,
             1)
+    # Conflicting tags are not a problem for buildman, since it does not use
+    # then. For example, Series-version is not useful for buildman. On the
+    # other hand conflicting tags will cause an error. So allow later tags
+    # to overwrite earlier ones.
+    series.allow_overwrite = True
     series = patchstream.GetMetaDataForList(range_expr, options.git_dir, None,
             series)
 
tools/patman/series.py +3 -1
index 783b3dd..85ed316 100644
@@ -40,6 +40,7 @@ class Series(dict):
         notes: List of lines in the notes
         changes: (dict) List of changes for each version, The key is
             the integer version number
+        allow_overwrite: Allow tags to overwrite an existing tag
     """
     def __init__(self):
         self.cc = []
@@ -49,6 +50,7 @@ class Series(dict):
         self.cover = None
         self.notes = []
         self.changes = {}
+        self.allow_overwrite = False
 
         # Written in MakeCcFile()
         #  key: name of patch file
@@ -72,7 +74,7 @@ class Series(dict):
         """
         # If we already have it, then add to our list
         name = name.replace('-', '_')
-        if name in self:
+        if name in self and not self.allow_overwrite:
             values = value.split(',')
             values = [str.strip() for str in values]
             if type(self[name]) != type([]):
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 2/2 buildman: Produce a sensible error message when branch is missing

Rather than a backtrace, produce a nice error message when an invalid branch is provided to buildman.

---
 tools/buildman/control.py |  4 ++++
 tools/patman/gitutil.py   | 21 +++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
tools/buildman/control.py +4 -0
index 1ce8b6f..85a4a34 100644
@@ -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:
tools/patman/gitutil.py +15 -6
index e31da15..b7f6739 100644
@@ -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']]
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 1/2 buildman: Allow conflicting tags to avoid spurious errors

In reply to Simon Glass
Quoted 15 lines · Simon Glass

Conflicting tags can prevent buildman from building two series which exist one after the other in a branch. There is no reason not to allow this sort of workflow with buildman, so ignore conflicting tags in buildman.

---
 tools/buildman/control.py | 5 +++++
 tools/patman/series.py    | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
tools/buildman/control.py +0 -0
index 8d7b9b5..1ce8b6f 100644

tools/buildman/control.py def DoBuildman(options, args): · line 141

Quoted 5 lines
tools/buildman/control.py +2 -0
@@ -137,6 +137,11 @@ def DoBuildman(options, args):
     upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch)
     series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir,
             1)
+    # Conflicting tags are not a problem for buildman, since it does not use
+    # then. For example, Series-version is not useful for buildman. On the

s/then/them/

Feel free to fix in-line and pull request.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130503/ea58d53c/attachment.pgp>
#3 lore raw

PATCH 1/2 buildman: Allow conflicting tags to avoid spurious errors

Hi Tom,

Quoted 25 lines · Tom Rini
Quoted 15 lines · Simon Glass

Conflicting tags can prevent buildman from building two series which exist one after the other in a branch. There is no reason not to allow this sort of workflow with buildman, so ignore conflicting tags in buildman.

---
 tools/buildman/control.py | 5 +++++
 tools/patman/series.py    | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
tools/buildman/control.py +0 -0
index 8d7b9b5..1ce8b6f 100644

tools/buildman/control.py def DoBuildman(options, args): · line 141

Quoted 5 lines
tools/buildman/control.py +2 -0
@@ -137,6 +137,11 @@ def DoBuildman(options, args):
     upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch)
     series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir,
             1)
+    # Conflicting tags are not a problem for buildman, since it does not use
+    # then. For example, Series-version is not useful for buildman. On the

s/then/them/

Quoted 3 lines

Feel free to fix in-line and pull request.

OK, will do.

Regards,
Simon

author Applied
#4 lore raw

PATCH 1/2 buildman: Allow conflicting tags to avoid spurious errors

Quoted 28 lines · Simon Glass

Hi Tom,

Quoted 25 lines · Tom Rini
Quoted 15 lines · Simon Glass

Conflicting tags can prevent buildman from building two series which exist one after the other in a branch. There is no reason not to allow this sort of workflow with buildman, so ignore conflicting tags in buildman.

---
 tools/buildman/control.py | 5 +++++
 tools/patman/series.py    | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
tools/buildman/control.py +0 -0
index 8d7b9b5..1ce8b6f 100644

tools/buildman/control.py def DoBuildman(options, args): · line 141

Quoted 5 lines
tools/buildman/control.py +2 -0
@@ -137,6 +137,11 @@ def DoBuildman(options, args):
     upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch)
     series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir,
             1)
+    # Conflicting tags are not a problem for buildman, since it does not use
+    # then. For example, Series-version is not useful for buildman. On the

s/then/them/

Quoted 5 lines
Quoted 3 lines

Feel free to fix in-line and pull request.

OK, will do.

Fixed typo, and:

Applied to x86/patman.