def render_reviewlink(self, req): """Render the "143 commits." box that shows in the topnav.""" #add_stylesheet(req, 'icucodetools/css/icuxtn.css') els = [] ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() if not repos: raise TracError("Could not get repository for %s" % (req.authname)) revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if not revs: str = 'No commits.' li = tag.li(str) els.append(li) else: str = ' %d commits.' % len(revs) href = req.href.review(req.args['ticket']) a = tag.a('Review' + str, href=href) li = tag.li(a) els.append(li) ul = tag.ul(els, class_='review') className = '' title = "Reviews" add_ctxtnav(req, tag.span(ul, id='icureview', title=title, class_=className))
def render_reviewlink(self, req): #add_stylesheet(req, 'icucodetools/css/icuxtn.css') els = [] ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() if not repos: raise TracError("Could not get repository for %s" % (req.authname)) revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if not revs: str = 'No commits.' li = tag.li(str) els.append(li) else: str = ' %d commits.' % len(revs) href = req.href.review(req.args['ticket']) a = tag.a('Review', href=href) li = tag.li(a + str) els.append(li) ul = tag.ul(els, class_='review') className = '' title = "Reviews" add_ctxtnav(req, tag.span(tag.object(ul), id='icureview', title=title, class_=className))
def process_request(self, req): """This is the 'main' of this module.""" #db = self.env.get_db_cnx() #ticketlist = {} # dict of ticket->??? #revlist = {} # dict of revision-> repos = self.env.get_repository() context = Context.from_request(req, False) new_path = req.args.get('new_path') new_rev = req.args.get('new') old_path = req.args.get('old_path') old_rev = req.args.get('old') new_path = repos.normalize_path(new_path) new_rev = repos.normalize_rev(new_rev) old_path = repos.normalize_path(old_path) old_rev = repos.normalize_rev(old_rev) # if not req.perm.has_permission('TICKET_MODIFY'): # return req.redirect(req.href.browser()) old_rev = int(old_rev) new_rev = int(new_rev) ticket = req.args.get('ticket') try: ticket = int(ticket) except Exception: ticket = 0 # req.hdf['review.ticket'] = ticket # req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket)) data = {} data['overall_y'] = 0 data['ticket_id'] = req.args['ticket'] data['ticket_summary'] = '' data['ticket_href'] = req.href.ticket(req.args['ticket']) ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if (not revs or len(revs)==0): # nothing to review. shouldn't happen return ('nothing.html', data, 'text/html') elif(len(revs)==1): # only one change - just do a changeset view return req.redirect(req.href.changeset(revs[0])) revcount = 0 branches = {} # track each branch separately. files = {} # track all of the files which are affected # may be 0 revs. revisions = [] # array of munged revisions for rev in revs: chgset = repos.get_changeset(rev) # 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 message = chgset.message or '--' revcount = revcount + 1 revision = {} revision['rev'] = tag.a(rev, req.href.changeset(rev)) revision['author'] = chgset.author revision['num'] = rev revision['comment'] = message #wiki_to_oneliner( message, self.env, db, shorten=False ) try: revision['comment_wiki'] = format_to_oneliner( self.env, context, message, shorten=False ) except Exception, e: self.env.log.warn(e) revision['comment_wiki'] = "%s (could not format - %s)" % (message, str(e)) rbranches = revision['branches'] = [] # walk through all changes in this Changeset and apply them to the files[] array for chg in chgset.get_changes(): path = chg[0] # new path if path in files: item = files[path] # known file else: item = [] files[path] = item; # new file item.append(self.changeToRange(rev,chg,repos)) branch_name = self.pathToBranchName(path) if branch_name not in rbranches: # first time we have seen this branch rbranches.append(branch_name) revisions.append(revision)
def process_request(self, req): #ok, what are we about. #db = self.env.get_db_cnx() #ticketlist = {} # dict of ticket->??? #revlist = {} # dict of revision-> repos = self.env.get_repository() new_path = req.args.get('new_path') new_rev = req.args.get('new') old_path = req.args.get('old_path') old_rev = req.args.get('old') new_path = repos.normalize_path(new_path) new_rev = repos.normalize_rev(new_rev) old_path = repos.normalize_path(old_path) old_rev = repos.normalize_rev(old_rev) # if not req.perm.has_permission('TICKET_MODIFY'): # return req.redirect(req.href.browser()) old_rev = int(old_rev) new_rev = int(new_rev) ticket = req.args.get('ticket') try: ticket = int(ticket) except Exception: ticket = 0 # req.hdf['review.ticket'] = ticket # req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket)) data = {} data['overall_y'] = 0 data['ticket_id'] = req.args['ticket'] data['ticket_href'] = req.href.ticket(req.args['ticket']) ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if (not revs or len(revs)==0): # nothing to review. shouldn't happen return ('nothing.html', data, 'text/html') elif(len(revs)==1): # only one change - just do a changeset view return req.redirect(req.href.changeset(revs[0])) revcount = 0 branches = {} files = {} # may be 0 revs. revisions = [] for rev in revs: chgset = repos.get_changeset(rev) # 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 message = chgset.message or '--' revcount = revcount + 1 revision = {} revision['rev'] = tag.a(rev, req.href.changeset(rev)) revision['author'] = chgset.author 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: item = files[path] else: 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 if(revcount > 0): data['revcount'] = revcount # print "files: %d" % len(files) # go throuhg each file and calculate its minimum range filelist = files.keys() filelist.sort() # print 'bar to %d len of %s' % (len(filelist),str(filelist)) for file in filelist: changes = files[file] i = 0 # print " looping from %d to %d over %d " % (i,len(changes)-1,len(changes)) while len(changes)>1 and i<(len(changes)-1): if changes[i][1] == changes[i+1][0]: if changes[i][0] == -1: changes[i+1] = (changes[i][0],changes[i+1][1],'add+commits') # retain 'first' rev else: changes[i+1] = (changes[i][0],changes[i+1][1],'multiple commits') # retain 'first' rev changes = changes[:i] + changes[i+1:] # and shift down # print "merged: %s" % str(changes) files[file] = changes else: i = i + 1 # now, write 'em out sera = 0 #files_data = [] for file in filelist: sera = sera+1 file_data = {} file_data['name'] = Markup('<a href="%s">%s</a>' % (req.href.browser(file),file)) branch_name = self.pathToBranchName(file) #print "branch is: (%s)" % (branch_name) branches_data = branches.get(branch_name, {}) files_data = branches_data.get('files',[]) changes = files[file] cha = 0 changes_data = [] for change in changes: cha = cha + 1 # print "%s output %s " % (file, str(change)) changes_data.append(self.describeChange(file, change, req, db)) file_data['changes'] = changes_data if(len(changes)>1): whathtml = self.describeChange(file, (changes[0][0], changes[len(changes)-1][1], 'overall'), req, db) file_data['overall'] = whathtml file_data['overall_y'] = 1 data['overall_y'] = 1 else: file_data['overall_y'] = 0 files_data.append(file_data) # sets branches_data['files'] = files_data branches_data['len'] = len(files_data) branches_data['name'] = branch_name branches[branch_name] = branches_data # .. convert dict to array. branch_list = [] for branch in branches: branch_list.append(branches[branch]) data['branches'] = branch_list data['lastbranch'] = branch data['branchcount'] = len(branches) content_type = "text/html" add_stylesheet(req, 'icucodetools/css/icuxtn.css') add_script(req, 'icucodetools/js/review.js') return 'review.html', data, content_type
def process_request(self, req): #ok, what are we about. #db = self.env.get_db_cnx() #ticketlist = {} # dict of ticket->??? #revlist = {} # dict of revision-> repos = self.env.get_repository() new_path = req.args.get('new_path') new_rev = req.args.get('new') old_path = req.args.get('old_path') old_rev = req.args.get('old') new_path = repos.normalize_path(new_path) new_rev = repos.normalize_rev(new_rev) old_path = repos.normalize_path(old_path) old_rev = repos.normalize_rev(old_rev) # if not req.perm.has_permission('TICKET_MODIFY'): # return req.redirect(req.href.browser()) old_rev = int(old_rev) new_rev = int(new_rev) ticket = req.args.get('ticket') try: ticket = int(ticket) except Exception: ticket = 0 # req.hdf['review.ticket'] = ticket # req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket)) data = {} data['overall_y'] = 0 data['ticket_id'] = req.args['ticket'] data['ticket_href'] = req.href.ticket(req.args['ticket']) ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if (not revs or len(revs) == 0): # nothing to review. shouldn't happen return ('nothing.html', data, 'text/html') elif (len(revs) == 1): # only one change - just do a changeset view return req.redirect(req.href.changeset(revs[0])) revcount = 0 branches = {} files = {} # may be 0 revs. revisions = [] for rev in revs: chgset = repos.get_changeset(rev) # 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 message = chgset.message or '--' revcount = revcount + 1 revision = {} revision['rev'] = tag.a(rev, req.href.changeset(rev)) revision['author'] = chgset.author 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: item = files[path] else: 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 if (revcount > 0): data['revcount'] = revcount # print "files: %d" % len(files) # go throuhg each file and calculate its minimum range filelist = files.keys() filelist.sort() # print 'bar to %d len of %s' % (len(filelist),str(filelist)) for file in filelist: changes = files[file] i = 0 # print " looping from %d to %d over %d " % (i,len(changes)-1,len(changes)) while len(changes) > 1 and i < (len(changes) - 1): if changes[i][1] == changes[i + 1][0]: if changes[i][0] == -1: changes[i + 1] = (changes[i][0], changes[i + 1][1], 'add+commits') # retain 'first' rev else: changes[i + 1] = (changes[i][0], changes[i + 1][1], 'multiple commits' ) # retain 'first' rev changes = changes[:i] + changes[i + 1:] # and shift down # print "merged: %s" % str(changes) files[file] = changes else: i = i + 1 # now, write 'em out sera = 0 #files_data = [] for file in filelist: sera = sera + 1 file_data = {} file_data['name'] = Markup('<a href="%s">%s</a>' % (req.href.browser(file), file)) branch_name = self.pathToBranchName(file) #print "branch is: (%s)" % (branch_name) branches_data = branches.get(branch_name, {}) files_data = branches_data.get('files', []) changes = files[file] cha = 0 changes_data = [] for change in changes: cha = cha + 1 # print "%s output %s " % (file, str(change)) changes_data.append(self.describeChange(file, change, req, db)) file_data['changes'] = changes_data if (len(changes) > 1): whathtml = self.describeChange( file, (changes[0][0], changes[len(changes) - 1][1], 'overall'), req, db) file_data['overall'] = whathtml file_data['overall_y'] = 1 data['overall_y'] = 1 else: file_data['overall_y'] = 0 files_data.append(file_data) # sets branches_data['files'] = files_data branches_data['len'] = len(files_data) branches_data['name'] = branch_name branches[branch_name] = branches_data # .. convert dict to array. branch_list = [] for branch in branches: branch_list.append(branches[branch]) data['branches'] = branch_list data['lastbranch'] = branch data['branchcount'] = len(branches) content_type = "text/html" add_stylesheet(req, 'icucodetools/css/icuxtn.css') add_script(req, 'icucodetools/js/review.js') return 'review.html', data, content_type
def process_request(self, req): """This is the 'main' of this module.""" #db = self.env.get_db_cnx() #ticketlist = {} # dict of ticket->??? #revlist = {} # dict of revision-> repos = self.env.get_repository() context = Context.from_request(req, False) new_path = req.args.get('new_path') new_rev = req.args.get('new') old_path = req.args.get('old_path') old_rev = req.args.get('old') new_path = repos.normalize_path(new_path) new_rev = repos.normalize_rev(new_rev) old_path = repos.normalize_path(old_path) old_rev = repos.normalize_rev(old_rev) # if not req.perm.has_permission('TICKET_MODIFY'): # return req.redirect(req.href.browser()) old_rev = int(old_rev) new_rev = int(new_rev) ticket = req.args.get('ticket') try: ticket = int(ticket) except Exception: ticket = 0 # req.hdf['review.ticket'] = ticket # req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket)) data = {} data['overall_y'] = 0 data['ticket_id'] = req.args['ticket'] data['ticket_summary'] = '' data['ticket_href'] = req.href.ticket(req.args['ticket']) ticket_mgr = TicketManager(self.compmgr) db = self.env.get_db_cnx() repos = self.env.get_repository() revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket']) if (not revs or len(revs)==0): # nothing to review. shouldn't happen return ('nothing.html', data, 'text/html') elif(len(revs)==1): # only one change - just do a changeset view return req.redirect(req.href.changeset(revs[0])) revcount = 0 branches = {} # track each branch separately. files = {} # track all of the files which are affected # may be 0 revs. revisions = [] # array of munged revisions for rev in revs: chgset = repos.get_changeset(rev) # 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 message = chgset.message or '--' revcount = revcount + 1 revision = {} revision['rev'] = tag.a(rev, req.href.changeset(rev)) revision['author'] = chgset.author revision['num'] = rev revision['comment'] = message #wiki_to_oneliner( message, self.env, db, shorten=False ) try: revision['comment_wiki'] = format_to_oneliner( self.env, context, message, shorten=False ) except Exception, e: self.env.log.warn(e) revision['comment_wiki'] = "%s (could not format - %s)" % (message, str(e)) rbranches = revision['branches'] = [] # walk through all changes in this Changeset and apply them to the files[] array for chg in chgset.get_changes(): path = chg[0] # new path if path in files: item = files[path] # known file else: item = [] files[path] = item; # new file item.append(self.changeToRange(rev,chg,repos)) branch_name = self.pathToBranchName(path) if branch_name not in rbranches: # first time we have seen this branch rbranches.append(branch_name) revisions.append(revision)