]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toaster: layer-relative paths for config files
authorDave Lerner <dave.lerner@windriver.com>
Wed, 11 Mar 2015 20:05:08 +0000 (15:05 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 24 Mar 2015 22:54:36 +0000 (22:54 +0000)
Change bitbake variables table to show the path to the file in which
the variable was defined using a layer-relative path instead of the
full path to the file.

The layer-relative path is found by matching on the full defining file
path with entries in a list of layer names, sorted in descending order,
and with 'meta' appended as a built-in layer to the end of the list.

Additional filters are used to reduce false matches, although even if
there is a false match, the actual path to the defining file will be
obvious and not misleading.

[YOCTO #7414]

Signed-off-by: Dave Lerner <dave.lerner@windriver.com>
lib/toaster/toastergui/templates/configvars.html
lib/toaster/toastergui/templatetags/projecttags.py
lib/toaster/toastergui/views.py

index 1bd29aac0dcafc4d914beb091dc607fe650e2daa..3e4c7e85ea1bdfa2732e9a45ba4e2f2451ce8dfa 100644 (file)
@@ -55,7 +55,7 @@
         <td class="variable_value"><a data-toggle="modal" href="#variable-{{variable.pk}}">{{variable.variable_value|truncatechars:153}}</a></td>
         <td class="file"><a data-toggle="modal" href="#variable-{{variable.pk}}">
             {% if variable.vhistory.all %} {% autoescape off %}
-                {{variable.vhistory.all | filter_setin_files:file_filter }}
+                {{variable.vhistory.all | filter_setin_files:file_filter | cut_layer_path_prefix:layer_names}}
             {% endautoescape %} {% endif %}
         </a></td>
         <td class="description">
                 <tbody>
                     {% for vh in variable.vhistory.all %}
                     <tr>
-                        <td>{{forloop.counter}}</td><td>{{vh.file_name}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
+                        <td>{{forloop.counter}}</td><td>{{vh.file_name|cut_layer_path_prefix:layer_names}}</td><td>{{vh.operation}}</td><td>{{vh.line_number}}</td>
                     </tr>
                     {%endfor%}
                 </tbody>
index e66910cd9dcf52ccc34acdfae0f2b5100577e285..0ccf73a6193e7f0f118ac7c53be71ddcf21f2256 100644 (file)
@@ -307,3 +307,18 @@ def is_shaid(text):
         return False
     except ValueError:
         return False
+
+@register.filter
+def cut_layer_path_prefix(fullpath,layer_names):
+    ### if some part of the full local path to a layer matches
+    ### an entry in layer_names (sorted desc), return the layer
+    ### name relative path.
+    for lname in layer_names:
+        # import rpdb; rpdb.set_trace()
+        # only try layer names that are non-trivial to avoid false matches
+        if len(lname) >= 4:
+            # match layer name with as a subdir / or for remote layers /_
+            if re.search('/' + lname, fullpath) or re.search('/_' + lname, fullpath):
+                parts = re.split(lname, fullpath, 1)
+                return lname + parts[1]
+    return fullpath
index ea47d96eea1915b0af8a1cca1388cc1b11f017b6..9f3506292535c2d2ae5de9162e7a8720f675ad14 100755 (executable)
@@ -1261,6 +1261,11 @@ def configvars(request, build_id):
 
     variables = _build_page_range(Paginator(queryset, pagesize), request.GET.get('page', 1))
 
+    layers = Layer.objects.filter(layer_version_layer__projectlayer__project__build=build_id).order_by("-name")
+    layer_names = map(lambda layer : layer.name, layers)
+    # special case for meta built-in layer
+    layer_names.append('meta')
+
     # show all matching files (not just the last one)
     file_filter= search_term + ":"
     if filter_string.find('/conf/') > 0:
@@ -1283,6 +1288,7 @@ def configvars(request, build_id):
                 'total_count':queryset_with_search.count(),
                 'default_orderby' : 'variable_name:+',
                 'search_term':search_term,
+                'layer_names' : layer_names,
             # Specifies the display of columns for the table, appearance in "Edit columns" box, toggling default show/hide, and specifying filters for columns
                 'tablecols' : [
                 {'name': 'Variable',