<s> from gitutils import Commit <EOL> from htmlutils import htmlify , jsify <EOL> from profiling import Profiler <EOL> from time import time , mktime , strftime , localtime <EOL> import re <EOL> import log . commitset <EOL> def formatWhen ( when ) : <EOL> def relative_time ( delta , time_unit_singular ) : <EOL> time_unit = time_unit_singular <EOL> if delta > <NUM_LIT:1> : <EOL> time_unit += "<STR_LIT:s>" <EOL> return "<STR_LIT>" % ( delta , time_unit ) <EOL> def inner ( when ) : <EOL> delta = int ( time ( ) - mktime ( when ) ) <EOL> if delta < <NUM_LIT> : return relative_time ( delta , "<STR_LIT>" ) <EOL> elif delta < <NUM_LIT> * <NUM_LIT> : return relative_time ( delta / <NUM_LIT> , "<STR_LIT>" ) <EOL> elif delta < <NUM_LIT> * <NUM_LIT> * <NUM_LIT> : return relative_time ( delta / ( <NUM_LIT> * <NUM_LIT> ) , "<STR_LIT>" ) <EOL> elif delta < <NUM_LIT> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT:30> : return relative_time ( delta / ( <NUM_LIT> * <NUM_LIT> * <NUM_LIT> ) , "<STR_LIT>" ) <EOL> else : return strftime ( "<STR_LIT>" , localtime ( mktime ( when ) ) ) <EOL> return inner ( when ) . replace ( "<STR_LIT:U+0020>" , "<STR_LIT>" ) <EOL> def renderWhen ( target , when ) : <EOL> target . innerHTML ( formatWhen ( when ) ) <EOL> def linkToCommit ( commit , overrides = { } ) : <EOL> if "<STR_LIT>" in overrides : <EOL> review = overrides [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in overrides : <EOL> return "<STR_LIT>" % ( overrides [ "<STR_LIT>" ] . sha1 [ : <NUM_LIT:8> ] , commit . sha1 [ : <NUM_LIT:8> ] , review . id ) <EOL> return "<STR_LIT>" % ( commit . sha1 [ : <NUM_LIT:8> ] , review . id ) <EOL> return "<STR_LIT>" % ( commit . repository . name , commit . sha1 ) <EOL> re_remote_into_local = re . compile ( "<STR_LIT>" ) <EOL> re_side_into_main = re . compile ( "<STR_LIT>" ) <EOL> re_octopus = re . compile ( "<STR_LIT>" ) <EOL> class WhenColumn : <EOL> def className ( self , db , commit ) : <EOL> return "<STR_LIT>" <EOL> def heading ( self , target ) : <EOL> target . text ( "<STR_LIT>" ) <EOL> def render ( self , db , commit , target , overrides = { } ) : <EOL> renderWhen ( target , commit . committer . time ) <EOL> class TypeColumn : <EOL> def className ( self , db , commit ) : <EOL> return "<STR_LIT:type>" <EOL> def heading ( self , target ) : <EOL> target . text ( ) <EOL> def render ( self , db , commit , target , overrides = { } ) : <EOL> if "<STR_LIT:type>" in overrides : target . text ( overrides [ "<STR_LIT:type>" ] ) <EOL> if len ( commit . parents ) > <NUM_LIT:1> : target . text ( "<STR_LIT>" ) <EOL> else : target . text ( ) <EOL> class SummaryColumn : <EOL> def __init__ ( self , linkToCommit = linkToCommit ) : <EOL> self . linkToCommit = linkToCommit <EOL> self . isFixupOrSquash = None <EOL> def className ( self , db , commit ) : <EOL> return "<STR_LIT>" <EOL> def heading ( self , target ) : <EOL> target . text ( "<STR_LIT>" ) <EOL> def render ( self , db , commit , target , overrides = { } ) : <EOL> summary = overrides . get ( "<STR_LIT>" , commit . summary ( ) ) <EOL> classnames = ( [ "<STR_LIT>" , "<STR_LIT>" ] + <EOL> overrides . get ( "<STR_LIT>" , [ ] ) ) <EOL> if self . isFixupOrSquash is not None : <EOL> data = self . isFixupOrSquash ( commit ) <EOL> if data : <EOL> what , ref = data <EOL> target . span ( what , critic_ref = ref ) . text ( "<STR_LIT>" % what ) <EOL> lines = commit . message . splitlines ( ) [ <NUM_LIT:1> : ] <EOL> while lines and not lines [ <NUM_LIT:0> ] . strip ( ) : <EOL> lines . pop ( <NUM_LIT:0> ) <EOL> if lines : summary = lines [ <NUM_LIT:0> ] <EOL> else : summary = None <EOL> if not summary : <EOL> classnames . append ( "<STR_LIT>" ) <EOL> summary = "<STR_LIT>" <EOL> url = self . linkToCommit ( commit , overrides ) <EOL> if summary : <EOL> target . a ( "<STR_LIT:U+0020>" . join ( classnames ) , href = url ) . text ( summary ) <EOL> class AuthorColumn : <EOL> def __init__ ( self ) : <EOL> self . cache = { } <EOL> def className ( self , db , commit ) : <EOL> return "<STR_LIT>" <EOL> def heading ( self , target ) : <EOL> target . text ( "<STR_LIT>" ) <EOL> def render ( self , db , commit , target , overrides = { } ) : <EOL> if "<STR_LIT>" in overrides : <EOL> fullname = overrides [ "<STR_LIT>" ] . fullname <EOL> else : <EOL> fullname = commit . author . getFullname ( db ) <EOL> target . text ( fullname ) <EOL> DEFAULT_COLUMNS = [ ( <NUM_LIT:10> , WhenColumn ( ) ) , <EOL> ( <NUM_LIT:5> , TypeColumn ( ) ) , <EOL> ( <NUM_LIT> , SummaryColumn ( ) ) , <EOL> ( <NUM_LIT:20> , AuthorColumn ( ) ) ] <EOL> def render ( db , target , title , branch = None , commits = None , columns = DEFAULT_COLUMNS , title_right = None , listed_commits = None , rebases = None , branch_name = None , bottom_right = None , review = None , highlight = None , profiler = None , collapsable = False , user = None , extra_commits = None ) : <EOL> addResources ( target ) <EOL> if not profiler : profiler = Profiler ( ) <EOL> profiler . check ( "<STR_LIT>" ) <EOL> if branch is not None : <EOL> repository = branch . repository <EOL> commits = branch . getCommits ( db ) [ : ] <EOL> commit_set = log . commitset . CommitSet ( commits ) <EOL> else : <EOL> assert commits is not None <EOL> repository = commits [ <NUM_LIT:0> ] . repository if len ( commits ) else None <EOL> commit_set = log . commitset . CommitSet ( commits ) <EOL> profiler . check ( "<STR_LIT>" ) <EOL> heads = commit_set . getHeads ( ) <EOL> tails = commit_set . getTails ( ) <EOL> rebase_old_heads = set ( ) <EOL> if rebases : <EOL> class Rebase ( object ) : <EOL> def __init__ ( self , rebase_id , old_head , new_head , user , <EOL> new_upstream , equivalent_merge , replayed_rebase , <EOL> target_branch_name ) : <EOL> self . id = rebase_id <EOL> self . old_head = equivalent_merge or old_head <EOL> self . new_head = new_head <EOL> self . user = user <EOL> self . new_upstream = new_upstream <EOL> self . equivalent_merge = equivalent_merge <EOL> self . replayed_rebase = replayed_rebase <EOL> self . target_branch_name = target_branch_name <EOL> rebases = [ Rebase ( * rebase ) for rebase in sorted ( rebases ) ] <EOL> rebase_old_heads = set ( rebase . old_head for rebase in rebases ) <EOL> heads -= rebase_old_heads <EOL> assert <NUM_LIT:0> <= len ( heads ) <= <NUM_LIT:1> <EOL> if not heads : <EOL> heads = set ( [ rebases [ - <NUM_LIT:1> ] . new_head ] ) <EOL> if repository : <EOL> target . addInternalScript ( repository . getJS ( ) ) <EOL> processed = set ( ) <EOL> summaries = { } <EOL> for commit in commits : <EOL> summary = commit . summary ( ) . strip ( ) <EOL> summaries [ summary ] = commit <EOL> summaries [ commit . sha1 ] = commit <EOL> if extra_commits : <EOL> for commit in extra_commits : <EOL> summary = commit . summary ( ) . strip ( ) <EOL> summaries [ summary ] = commit <EOL> summaries [ commit . sha1 ] = commit <EOL> def isFixupOrSquash ( commit ) : <EOL> key , _ , summary = commit . summary ( ) . partition ( "<STR_LIT:U+0020>" ) <EOL> if key in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> what = key [ : - <NUM_LIT:1> ] <EOL> else : <EOL> return None <EOL> summary = summary . strip ( ) <EOL> commit = summaries . get ( summary ) <EOL> if not commit and re . match ( "<STR_LIT>" , summary ) : <EOL> commit = summaries . get ( summary ) <EOL> if not commit : <EOL> try : <EOL> sha1 = repository . revparse ( summary ) <EOL> commit = Commit . fromSHA1 ( db , repository , sha1 ) <EOL> except Exception : <EOL> pass <EOL> if commit : <EOL> summary = commit . summary ( ) <EOL> return what , summary <EOL> for width , column in columns : <EOL> if isinstance ( column , SummaryColumn ) : <EOL> column . isFixupOrSquash = isFixupOrSquash <EOL> break <EOL> def output ( table , commit , overrides = { } ) : <EOL> if commit not in processed : <EOL> classes = [ "<STR_LIT>" ] <EOL> row_id = None <EOL> if len ( commit . parents ) > <NUM_LIT:1> : <EOL> classes . append ( "<STR_LIT>" ) <EOL> if highlight == commit : <EOL> classes . append ( "<STR_LIT>" ) <EOL> row_id = commit . sha1 <EOL> if review : <EOL> overrides [ "<STR_LIT>" ] = review <EOL> row = table . tr ( "<STR_LIT:U+0020>" . join ( classes ) , id = row_id ) <EOL> profiler . check ( "<STR_LIT>" ) <EOL> for index , ( width , column ) in enumerate ( columns ) : <EOL> column . render ( db , commit , row . td ( column . className ( db , commit ) ) , overrides = overrides ) <EOL> profiler . check ( "<STR_LIT>" % ( index + <NUM_LIT:1> ) ) <EOL> processed . add ( commit ) <EOL> return row <EOL> else : <EOL> return None <EOL> cursor = db . cursor ( ) <EOL> def emptyChangeset ( child , parent = None ) : <EOL> if parent is None : <EOL> cursor . execute ( """<STR_LIT>""" , <EOL> ( child . getId ( db ) , review . id ) ) <EOL> else : <EOL> cursor . execute ( """<STR_LIT>""" , <EOL> ( parent . getId ( db ) , child . getId ( db ) , review . id ) ) <EOL> return not cursor . fetchone ( ) <EOL> def inner ( target , head , tails , align = '<STR_LIT:right>' , title = None , table = None , silent_if_empty = set ( ) , upstream = None ) : <EOL> if not table : <EOL> table = target . table ( '<STR_LIT>' , align = align , cellspacing = <NUM_LIT:0> ) <EOL> for width , column in columns : table . col ( width = ( '<STR_LIT>' % width ) ) <EOL> if title : <EOL> thead = table . thead ( ) <EOL> row = thead . tr ( "<STR_LIT:title>" ) <EOL> header = row . td ( "<STR_LIT>" , colspan = len ( columns ) ) . h1 ( ) <EOL> header . text ( title ) <EOL> if callable ( title_right ) : <EOL> title_right ( db , header . span ( "<STR_LIT:right>" ) ) <EOL> row = thead . tr ( '<STR_LIT>' ) <EOL> for width , column in columns : <EOL> column . heading ( row . td ( column . className ( db , None ) ) ) <EOL> elif head is None or head in tails : <EOL> if upstream : <EOL> tag = upstream . findInterestingTag ( db ) <EOL> if tag : what = tag <EOL> else : what = upstream . sha1 [ : <NUM_LIT:8> ] <EOL> message = "<STR_LIT>" % what <EOL> else : message = "<STR_LIT>" <EOL> thead = table . thead ( ) <EOL> row = thead . tr ( '<STR_LIT>' ) <EOL> row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) . text ( message ) <EOL> return ( None , None , None , False ) <EOL> tbody = table . tbody ( ) <EOL> commit = head <EOL> last_commit = None <EOL> skipped = True <EOL> while commit and commit not in tails : <EOL> suppress = False <EOL> optional_merge = False <EOL> listed = listed_commits is None or commit . getId ( db ) in listed_commits <EOL> if commit in silent_if_empty and emptyChangeset ( commit ) : <EOL> suppress = True <EOL> if not suppress and not listed : <EOL> suppress = len ( commit . parents ) == <NUM_LIT:1> <EOL> optional_merge = not suppress <EOL> if not suppress : commit_tr = output ( tbody , commit ) <EOL> else : commit_tr = None <EOL> if listed : skipped = False <EOL> last_commit = commit <EOL> if len ( commit . parents ) == <NUM_LIT:0> : <EOL> break <EOL> elif len ( commit . parents ) == <NUM_LIT:1> : <EOL> commit = commit_set . get ( commit . parents [ <NUM_LIT:0> ] ) <EOL> elif len ( commit . parents ) > <NUM_LIT:1> : <EOL> if len ( commit . parents ) > <NUM_LIT:2> : <EOL> common_ancestors = commit_set . getCommonAncestors ( commit ) <EOL> match = re_octopus . match ( commit . message . split ( "<STR_LIT:\n>" , <NUM_LIT:1> ) [ <NUM_LIT:0> ] ) <EOL> if match : <EOL> titles = re . findall ( "<STR_LIT>" , match . group ( <NUM_LIT:1> ) ) <EOL> if len ( titles ) != len ( commit . parents ) : <EOL> titles = None <EOL> else : <EOL> titles = None <EOL> for index , sha1 in enumerate ( commit . parents ) : <EOL> if sha1 in commit_set : <EOL> sublog = tbody . tr ( '<STR_LIT>' ) <EOL> inner_last_commit , inner_table , inner_tail , inner_skipped = inner ( sublog . td ( colspan = len ( columns ) ) , commit_set [ sha1 ] , common_ancestors , title = titles and titles [ index ] or None ) <EOL> if inner_skipped : <EOL> sublog . remove ( ) <EOL> if optional_merge and commit_tr : commit_tr . remove ( ) <EOL> if not common_ancestors : return ( None , None , None , False ) <EOL> commit = common_ancestors . pop ( ) <EOL> continue <EOL> parent1_sha1 = commit . parents [ <NUM_LIT:0> ] <EOL> parent2_sha1 = commit . parents [ <NUM_LIT:1> ] <EOL> parent1 = commit_set . get ( parent1_sha1 ) <EOL> parent2 = commit_set . get ( parent2_sha1 ) <EOL> if parent1_sha1 in rebase_old_heads : <EOL> if parent2 : <EOL> sublog = tbody . tr ( '<STR_LIT>' ) <EOL> inner_last_commit , inner_table , inner_tail , inner_skipped = inner ( sublog . td ( colspan = len ( columns ) ) , parent2 , tails ) <EOL> if inner_skipped : <EOL> sublog . remove ( ) <EOL> if optional_merge and commit_tr : commit_tr . remove ( ) <EOL> return ( commit , table , parent1_sha1 , False ) <EOL> elif parent2_sha1 in rebase_old_heads : <EOL> if parent1 : <EOL> sublog = tbody . tr ( '<STR_LIT>' ) <EOL> inner_last_commit , inner_table , inner_tail , inner_skipped = inner ( sublog . td ( colspan = len ( columns ) ) , parent1 , tails ) <EOL> if inner_skipped : <EOL> sublog . remove ( ) <EOL> if optional_merge and commit_tr : commit_tr . remove ( ) <EOL> return ( commit , table , parent2_sha1 , False ) <EOL> if parent1 and parent2 : <EOL> common_ancestors = commit_set . getCommonAncestors ( commit ) <EOL> merged_remote_into_local = re_remote_into_local . match ( commit . summary ( ) ) or re_side_into_main . match ( commit . summary ( ) ) <EOL> def rankPaths ( commit , tails ) : <EOL> shortest = None <EOL> shortest_length = len ( commit_set ) <EOL> longest = None <EOL> longest_length = <NUM_LIT:0> <EOL> for sha1 in commit . parents : <EOL> parent = commit_set [ sha1 ] <EOL> counted = set ( ) <EOL> pending = set ( [ parent ] ) <EOL> while pending : <EOL> candidate = pending . pop ( ) <EOL> if candidate in counted : continue <EOL> if candidate in tails : continue <EOL> counted . add ( candidate ) <EOL> pending . update ( commit_set . getParents ( candidate ) ) <EOL> length = len ( counted ) <EOL> if length < shortest_length : <EOL> shortest = parent <EOL> shortest_length = length <EOL> if length >= longest_length : <EOL> longest = parent <EOL> longest_length = length <EOL> return shortest , shortest_length , longest , longest_length <EOL> show_merged , shortest_length , show_normal , longest_length = rankPaths ( commit , common_ancestors | tails ) <EOL> display_parallel = False <EOL> if merged_remote_into_local and shortest_length * <NUM_LIT:2> > longest_length : <EOL> if len ( common_ancestors ) == <NUM_LIT:1> and len ( commit_set . filtered ( [ commit ] ) . getTails ( ) ) == <NUM_LIT:1> : <EOL> display_parallel = True <EOL> else : <EOL> show_merged = parent2 <EOL> show_normal = parent1 <EOL> if display_parallel : <EOL> all_empty = True <EOL> for sha1 in commit . parents : <EOL> sublog = tbody . tr ( '<STR_LIT>' ) <EOL> inner_last_commit , inner_table , inner_tail , inner_skipped = inner ( sublog . td ( colspan = len ( columns ) ) , commit_set [ sha1 ] , common_ancestors | tails ) <EOL> if inner_skipped : <EOL> sublog . remove ( ) <EOL> else : <EOL> all_empty = False <EOL> if all_empty and optional_merge and commit_tr : commit_tr . remove ( ) <EOL> commit = common_ancestors . pop ( ) <EOL> else : <EOL> sublog = tbody . tr ( '<STR_LIT>' ) <EOL> inner_last_commit , inner_table , inner_tail , inner_skipped = inner ( sublog . td ( colspan = len ( columns ) ) , show_merged , common_ancestors | tails ) <EOL> if inner_skipped : <EOL> sublog . remove ( ) <EOL> if optional_merge and commit_tr : commit_tr . remove ( ) <EOL> commit = show_normal <EOL> else : <EOL> if parent1 : upstream_sha1 = parent2_sha1 <EOL> else : upstream_sha1 = parent1_sha1 <EOL> if not commit in silent_if_empty : <EOL> inner ( tbody . tr ( '<STR_LIT>' ) . td ( colspan = len ( columns ) ) , None , None , upstream = Commit . fromSHA1 ( db , repository , upstream_sha1 ) ) <EOL> if parent1 : commit = parent1 <EOL> else : commit = parent2 <EOL> return ( last_commit , table , last_commit . parents [ <NUM_LIT:0> ] if last_commit and last_commit . parents else None , skipped ) <EOL> class_name = "<STR_LIT>" <EOL> if collapsable : <EOL> class_name += "<STR_LIT>" <EOL> table = target . table ( class_name , align = '<STR_LIT>' , cellspacing = <NUM_LIT:0> ) <EOL> for width , column in columns : table . col ( width = ( '<STR_LIT>' % width ) ) <EOL> thead = table . thead ( "<STR_LIT:title>" ) <EOL> row = thead . tr ( "<STR_LIT:title>" ) <EOL> header = row . td ( "<STR_LIT>" , colspan = len ( columns ) ) . h1 ( ) <EOL> error_message = None <EOL> if len ( commit_set ) == <NUM_LIT:0> : <EOL> thead = table . thead ( ) <EOL> row = thead . tr ( '<STR_LIT:error>' ) <EOL> cell = row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) <EOL> cell . text ( "<STR_LIT>" ) <EOL> if review : <EOL> cell . a ( href = "<STR_LIT>" % ( review . branch . head_sha1 , review . id ) ) . text ( "<STR_LIT>" ) <EOL> return <EOL> elif len ( heads ) > <NUM_LIT:1> : <EOL> error_message = "<STR_LIT>" <EOL> elif len ( heads ) == <NUM_LIT:0> : <EOL> error_message = "<STR_LIT>" <EOL> if error_message is not None : <EOL> thead = table . thead ( ) <EOL> row = thead . tr ( '<STR_LIT:error>' ) <EOL> cell = row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) <EOL> cell . text ( error_message ) <EOL> return <EOL> head = heads . pop ( ) if heads else None <EOL> row = thead . tr ( '<STR_LIT>' ) <EOL> for width , column in columns : <EOL> column . heading ( row . td ( column . className ( db , None ) ) ) <EOL> first_rebase = True <EOL> silent_if_empty = set ( ) <EOL> if rebases : <EOL> for rebase in rebases : <EOL> if rebase . equivalent_merge : <EOL> silent_if_empty . add ( rebase . equivalent_merge ) <EOL> top_rebases = [ ] <EOL> while rebases and head == rebases [ - <NUM_LIT:1> ] . new_head : <EOL> rebase = rebases . pop ( ) <EOL> top_rebases . append ( ( head , rebase ) ) <EOL> head = rebase . old_head <EOL> for rebase_head , rebase in top_rebases : <EOL> thead = table . thead ( "<STR_LIT>" ) <EOL> row = thead . tr ( '<STR_LIT>' ) <EOL> cell = row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) <EOL> if rebase . new_upstream is None and not rebase . target_branch_name : <EOL> cell . text ( "<STR_LIT>" ) <EOL> else : <EOL> cell . text ( "<STR_LIT>" ) <EOL> if rebase . target_branch_name : <EOL> anchor = cell . a ( href = ( "<STR_LIT>" <EOL> % ( repository . id , rebase . target_branch_name ) ) ) <EOL> anchor . text ( rebase . target_branch_name ) <EOL> else : <EOL> upstream_description = repository . describe ( db , rebase . new_upstream . sha1 ) <EOL> if upstream_description is None : <EOL> upstream_description = rebase . new_upstream . sha1 [ : <NUM_LIT:8> ] <EOL> anchor = cell . a ( href = "<STR_LIT>" % ( repository . name , rebase . new_upstream . sha1 ) ) <EOL> anchor . text ( upstream_description ) <EOL> cell . text ( "<STR_LIT>" % rebase . user . fullname ) <EOL> if first_rebase : <EOL> cell . text ( "<STR_LIT>" ) <EOL> review_param = "<STR_LIT>" % review . id if review else "<STR_LIT>" <EOL> cell . a ( href = "<STR_LIT>" % ( repository . id , branch_name , review_param ) ) . text ( "<STR_LIT>" ) <EOL> if user and user == rebase . user : <EOL> cell . text ( "<STR_LIT:U+0020>" ) <EOL> cell . a ( href = "<STR_LIT>" % rebase . id ) . text ( "<STR_LIT>" ) <EOL> first_rebase = False <EOL> else : <EOL> cell . text ( "<STR_LIT:.>" ) <EOL> if rebase . replayed_rebase and not emptyChangeset ( parent = rebase . replayed_rebase , <EOL> child = rebase . new_head ) : <EOL> output ( table , rebase . new_head , <EOL> overrides = { "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : rebase . user , <EOL> "<STR_LIT>" : rebase . replayed_rebase } ) <EOL> while True : <EOL> local_tails = tails . copy ( ) <EOL> if rebases : <EOL> local_tails . add ( rebases [ - <NUM_LIT:1> ] . new_head ) <EOL> last_commit , table , tail , skipped = inner ( <EOL> target , head , local_tails , '<STR_LIT>' , title , table , silent_if_empty ) <EOL> if rebases : <EOL> rebase = rebases . pop ( ) <EOL> assert tail == rebase . new_head , "<STR_LIT>" % ( tail , rebase . new_head ) <EOL> while True : <EOL> head = rebase . old_head <EOL> thead = table . thead ( "<STR_LIT>" ) <EOL> row = thead . tr ( '<STR_LIT>' ) <EOL> cell = row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) <EOL> if rebase . new_upstream is None and not rebase . target_branch_name : <EOL> cell . text ( "<STR_LIT>" ) <EOL> else : <EOL> cell . text ( "<STR_LIT>" ) <EOL> if rebase . target_branch_name : <EOL> anchor = cell . a ( href = ( "<STR_LIT>" <EOL> % ( repository . id , rebase . target_branch_name ) ) ) <EOL> anchor . text ( rebase . target_branch_name ) <EOL> else : <EOL> upstream_description = repository . describe ( db , rebase . new_upstream . sha1 ) <EOL> if upstream_description is None : <EOL> upstream_description = rebase . new_upstream . sha1 [ : <NUM_LIT:8> ] <EOL> anchor = cell . a ( href = "<STR_LIT>" % ( repository . name , rebase . new_upstream . sha1 ) ) <EOL> anchor . text ( upstream_description ) <EOL> cell . text ( "<STR_LIT>" % rebase . user . fullname ) <EOL> if first_rebase : <EOL> cell . text ( "<STR_LIT>" ) <EOL> review_param = "<STR_LIT>" % review . id if review else "<STR_LIT>" <EOL> cell . a ( href = "<STR_LIT>" % ( repository . id , branch_name , review_param ) ) . text ( "<STR_LIT>" ) <EOL> first_rebase = False <EOL> else : <EOL> cell . text ( "<STR_LIT:.>" ) <EOL> if rebase . replayed_rebase and not emptyChangeset ( parent = rebase . replayed_rebase , <EOL> child = rebase . new_head ) : <EOL> output ( table , rebase . new_head , <EOL> overrides = { "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : rebase . user , <EOL> "<STR_LIT>" : rebase . replayed_rebase } ) <EOL> if rebases and rebases [ - <NUM_LIT:1> ] . new_head == head : <EOL> rebase = rebases . pop ( ) <EOL> else : <EOL> break <EOL> continue <EOL> if last_commit : <EOL> if len ( last_commit . parents ) == <NUM_LIT:1> : <EOL> upstream = Commit . fromSHA1 ( db , repository , last_commit . parents [ <NUM_LIT:0> ] ) <EOL> upstream_description = repository . describe ( db , upstream . sha1 ) <EOL> if not upstream_description : <EOL> upstream_description = upstream . sha1 [ : <NUM_LIT:8> ] <EOL> row = table . thead ( "<STR_LIT>" ) . tr ( '<STR_LIT>' ) <EOL> cell = row . td ( colspan = len ( columns ) , align = '<STR_LIT>' ) <EOL> cell . text ( "<STR_LIT>" ) <EOL> anchor = cell . a ( href = "<STR_LIT>" % ( repository . name , upstream . sha1 ) ) <EOL> anchor . text ( upstream_description ) <EOL> if callable ( bottom_right ) : <EOL> bottom_right ( db , table . tfoot ( ) . tr ( ) . td ( colspan = len ( columns ) ) ) <EOL> break <EOL> profiler . check ( "<STR_LIT>" ) <EOL> if "<STR_LIT>" in title : header . text ( title % len ( processed ) ) <EOL> else : header . text ( title ) <EOL> if callable ( title_right ) : <EOL> title_right ( db , header . span ( "<STR_LIT:right>" ) ) <EOL> def renderList ( db , target , title , commits , columns = DEFAULT_COLUMNS , title_right = None , bottom_right = None , hide_merges = False , className = "<STR_LIT>" ) : <EOL> addResources ( target ) <EOL> table = target . table ( className , align = "<STR_LIT>" , cellspacing = <NUM_LIT:0> ) <EOL> for width , column in columns : table . col ( width = ( "<STR_LIT>" % width ) ) <EOL> thead = table . thead ( ) <EOL> title_h1 = None <EOL> if title : <EOL> row = thead . tr ( "<STR_LIT:title>" ) <EOL> title_h1 = row . td ( "<STR_LIT>" , colspan = len ( columns ) ) . h1 ( ) <EOL> title_h1 . text ( title ) <EOL> row = thead . tr ( "<STR_LIT>" ) <EOL> for width , column in columns : <EOL> column . heading ( row . td ( column . className ( db , None ) ) ) <EOL> tbody = table . tbody ( ) <EOL> merges = <NUM_LIT:0> <EOL> for commit in commits : <EOL> classname = "<STR_LIT>" <EOL> if hide_merges : <EOL> is_merge = len ( commit . parents ) > <NUM_LIT:1> <EOL> if is_merge : <EOL> classname += "<STR_LIT>" <EOL> merges += <NUM_LIT:1> <EOL> row = tbody . tr ( classname , id = commit . sha1 ) <EOL> for width , column in columns : <EOL> column . render ( db , commit , row . td ( column . className ( db , commit ) ) ) <EOL> if merges and title_h1 : <EOL> title_h1 . a ( href = "<STR_LIT>" , onclick = "<STR_LIT>" ) . text ( "<STR_LIT>" % merges ) <EOL> if callable ( title_right ) : <EOL> title_right ( db , title_h1 . span ( "<STR_LIT:right>" ) ) <EOL> if callable ( bottom_right ) : <EOL> bottom_right ( db , table . tfoot ( ) . tr ( ) . td ( colspan = len ( columns ) ) ) <EOL> def addResources ( target ) : <EOL> target . addExternalStylesheet ( "<STR_LIT>" ) <EOL> target . addExternalScript ( "<STR_LIT>" ) </s>
