]> granicus.if.org Git - icu/commitdiff
ICU-8988 checkin for v0.12 - merge
authorSteven R. Loomis <srl@icu-project.org>
Tue, 21 Feb 2012 19:56:42 +0000 (19:56 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Tue, 21 Feb 2012 19:56:42 +0000 (19:56 +0000)
X-SVN-Rev: 31474

tools/trac/IcuCodeTools/0.12/icucodetools/review.py
tools/trac/IcuCodeTools/0.12/icucodetools/templates/review.html

index 9cbf64997307df1ff464b101bb76febb01686ce8..f3d1110d3af543c05100e461e056c0a191d81a29 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 International Business Machines Corporation and Others. All Rights Reserved.
+# Copyright (C) 2007-2012 International Business Machines Corporation and Others. All Rights Reserved.
 
 # Review module.
 # TODO: refactor ticket manipulation items into ticketmgr.
@@ -32,6 +32,12 @@ class ReviewModule(Component):
     voteable_paths = ListOption('icucodetools', 'paths', '/ticket*',
         doc='List of URL paths to show reviews on. Globs are supported.')
 
+    #  search for earliest match, and how many segments to include following
+    #    trunk
+    #    branches/maint/maint-4-8
+    #    tags/release-2-0
+    branchList = [['trunk',0],['branches',2],['tags',1]]
+
     # IPermissionRequestor methods
     def get_permission_actions(self):
         return ['ICUREVIEW_VIEW']
@@ -99,6 +105,26 @@ class ReviewModule(Component):
             req.args['ticket'] = match.group(1)
             return True
 
+    def pathToBranchName(self, path):
+        #return '/'.join(path.split('/')[0:2])
+        windex = None
+        win = None
+        for branch in self.branchList:
+            if(path == branch[0]):  # catch changes to just 'trunk'
+                idx = 0
+            else:
+                idx = path.find(branch[0]+'/')
+            if(idx > -1 and (windex == None or windex > idx)):
+                windex = idx
+                win = branch
+        if windex == None:
+            segments = path.split('/')
+            return '/'.join(segments[0:2])
+        else:
+            #print "found %s foll %s @ %d" % (win[0],win[1],windex)
+            segments = path[windex:].split('/')
+            return path[:windex] + ('/'.join(segments[0:win[1]+1])) # use specified # of following segments
+
     def changeToRange(self, c_new, change):
         # q: (u'trunk/Locale.java', 'file', 'add', None, u'-1')  from r3
         # q: (u'trunk/util.c',      'file', 'edit', u'trunk/util.c', u'2')  from r4
@@ -210,6 +236,7 @@ class ReviewModule(Component):
             revision['rev'] =  tag.a(rev, req.href.changeset(rev))
             revision['num'] =  rev
             revision['comment'] =  message #wiki_to_oneliner( message, self.env, db, shorten=False )
+            rbranches = revision['branches'] = []
             for chg in chgset.get_changes():
                 path = chg[0]
                 if path in files:
@@ -218,6 +245,9 @@ class ReviewModule(Component):
                     item = []
                     files[path] = item;
                 item.append(self.changeToRange(rev,chg))
+                branch_name = self.pathToBranchName(path)
+                if branch_name not in rbranches:
+                    rbranches.append(branch_name)
             revisions.append(revision)
         data['revisions'] = revisions
         
@@ -253,7 +283,7 @@ class ReviewModule(Component):
             sera = sera+1
             file_data = {}
             file_data['name'] = Markup('<a href="%s">%s</a>' % (req.href.browser(file),file))
-            branch_name = '/'.join(file.split('/')[0:2])
+            branch_name = self.pathToBranchName(file)
             #print "branch is: (%s)" % (branch_name)
             branches_data = branches.get(branch_name, {})
             files_data = branches_data.get('files',[])
@@ -279,8 +309,6 @@ class ReviewModule(Component):
             branches_data['len'] = len(files_data)
             branches_data['name'] = branch_name
             branches[branch_name] = branches_data
-        #data['files'] = files_data
-        #data['branches'] = branches
 
         # .. convert dict to array.
         branch_list = []
index d86205e57b540985ef37de973b69797500ebe533..49219f8a1fa4caaeb58d0a1f575183e4f3b606b1 100644 (file)
@@ -2,7 +2,7 @@
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <!--
-# Copyright (C) 2007-2010 IBM and Others. All Rights Reserved
+# Copyright (C) 2007-2012 IBM and Others. All Rights Reserved
 -->
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:py="http://genshi.edgewall.org/"
 
 <py:if test="revcount">
 
-<h2>${revcount} Changesets</h2>
-<ul>
-<py:for each="rev in revisions">
-    <li><a href="${href.changeset(rev.num)}">r${rev.num}</a> &mdash; ${rev.comment}</li>
-</py:for>
-</ul>
-
+  <h2>${revcount} Changesets</h2>
+  <table class='icureview'>
+    <thead>
+      <tr>
+       <th>r</th>
+       <th>section(s)</th>
+       <th>comment</th>
+      </tr>
+    </thead>
+    <tbody>
+      <py:for each="rev in revisions">
+       <tr>
+         <th>
+           <a href="${href.changeset(rev.num)}">r${rev.num}</a>
+         </th>
+         <td>
+           <!-- sections -->
+           <py:for each="branch in rev.branches">
+             <b>
+               <a href="#${branch}">${branch}</a> 
+             </b>
+           </py:for>
+         </td>
+         <td>
+           ${rev.comment}
+         </td>
+       </tr>
+      </py:for>
+    </tbody>
+  </table>
+  
 <py:if test="branchcount > 1">
 <h2>Files</h2>
 <h3>Jump to Sections</h3>