Changeset 1675

Show
Ignore:
Timestamp:
12/12/06 18:05:25 (2 years ago)
Author:
eblot
Message:

RevtreePlugin:

Clean-up, CSS update, add FIXME tags, documents main classes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • revtreeplugin/0.10/revtree/htdocs/css/revtree.css

    r1669 r1675  
    1 div#settings { 
    2 } 
    3 form#prefs { 
    4  margin-top: 2em;    
    5 } 
    6 div.revtree .tip { 
    7  font: 10px/12px Arial,Helvetica,sans-serif;  
    8  border: solid 1px #666666;  
    9  width: 250px;  
    10  padding: 1px;  
    11  position: absolute;  
    12  z-index: 100;  
    13  visibility: hidden;  
    14  color: #333333; 
    15  top: 20px;  
    16  left: 90px;  
    17  background-color: #ffffcc;  
    18  layer-background-color: #ffffcc; 
    19 } 
    20  
    211div.revtree div#legend { 
    22  align: right;  
     2 text-align: right;  
    233} 
    244div.revtree div#errormsg { 
     
    3111 margin-left: 1ex; 
    3212 white-space: nowrap; 
    33  position: relative; 
    3413 float: left; 
    3514 border-right: solid 1px #333; 
    3615} 
    37 div#treestyle div { 
     16#treestyle div { 
    3817   display: block; 
    3918} 
    40 div#options { 
     19#treeoptions { 
    4120   white-space: normal; 
    4221   width: 12ex; 
    4322} 
    44 div#options label { 
    45    margin=top: 0; 
     23#treeoptions label { 
     24   margin-top: 0; 
    4625   padding-left: 3ex; 
    4726} 
    48 div#update { 
     27#treeupdate { 
    4928 border-right: none; 
    5029} 
     30#settings { 
     31   /* FIXME */ 
     32   width: 100%; 
     33   border-top: 4px solid red; 
     34   background-color: red; 
     35   margin-top: 0; 
     36   margin-left: 0; 
     37   margin-right: 0; 
     38   margin-bottom: 10em; 
     39} 
    5140#prefs { 
    52  position: relative
     41 margin-top: 2em
    5342 float: left; 
    5443} 
    5544div.svg { 
    56  position: relative; 
    57  float: left
     45 float: none; 
     46 margin-left: 4ex
    5847} 
    5948div#revtree { 
     
    111100        color:#333333; 
    112101} 
    113 .JT_loader{ 
     102#JT_loader{ 
    114103        background-image: url(../images/loader.gif); 
    115104        background-repeat: no-repeat; 
  • revtreeplugin/0.10/revtree/htdocs/js/svgtip.js

    r1669 r1675  
    8181  document.getElementsByTagName('body')[0].appendChild(d0); 
    8282 
     83  // netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
    8384  $('#JT').show(); 
    8485  $('#JT_copy').load(url); 
     
    8788function getSvgPosition(objectId) { 
    8889   var svg = document.getElementsByTagName('svg')[0]; 
    89    //alert('position: ' + svg.parentNode.offsetTop); 
    9090   var anodes = svg.getElementsByTagName('a'); 
    9191   var object; 
  • revtreeplugin/0.10/revtree/model.py

    r1668 r1675  
    2222 
    2323class ChangesetEmptyRange(TracError): 
     24    """Defines a RevTree error (no changeset in the selected range)""" 
    2425    def __init__(self, msg=None): 
    2526        TracError.__init__(self, "%sNo changeset" \ 
     
    220221        # Trac version control 
    221222        self._crepos = self.env.get_repository(authname) 
    222         #self._svnrepos = SubversionRepository(repository_path, None, self.log) 
    223         #self._reposcache = CachedRepository(env.get_db_cnx(), self._svnrepos,  
    224         #                                    None, self.log) 
    225223        # Dictionnary of changesets 
    226224        self._changesets = {} 
    227225        # Dictionnary of branches 
    228226        self._branches = {} 
    229         # Lowset revision number 
    230         #self._rev_min = 1 
    231         # Highest revision number 
    232         #self._rev_max = self._proxy.get_youngest_revision() 
    233227 
    234228    def _build_branches(self): 
     
    287281        return (node.get_name(), node.rev) 
    288282 
    289     #def get_revisions_by_date(self, dayrange): 
    290     #    """Returns a tuple of (min, max) revisions from  
    291     #       a date range (oldest, newest)""" 
    292     #    current = time.time() 
    293     #    mintime = current - (dayrange[0]*86400) 
    294     #    maxtime = current - (dayrange[1]*86400) 
    295     #    revisions = [] 
    296     #    for chg in self._changesets.values(): 
    297     #        if chg.time < mintime: 
    298     #            continue 
    299     #        if chg.time > maxtime: 
    300     #            continue 
    301     #        revisions.append(chg.revision) 
    302     #    revisions.sort() 
    303     #    if not revisions: 
    304     #        return (0, 0) 
    305     #    if len(revisions) >= 2: 
    306     #        return (revisions[0], revisions[-1]) 
    307     #    return (revisions[0], revisions[0]) 
    308  
    309283    def build(self, bcre, revrange=None, timerange=None): 
    310284        """Builds an internal representation of the repository, which  
    311285           is used to generate a graphical view of it""" 
     286        self._crepos.sync() 
    312287        start = 0 
    313288        stop = int(time.time()) 
     
    332307            raise ChangesetEmptyRange 
    333308        vcsort.sort() 
    334         self.log.debug("SORT %d" % len(vcsort)) 
    335309        self._revrange = (vcsort[0][1].rev,vcsort[-1][1].rev) 
    336310        vcsort.reverse() 
  • revtreeplugin/0.10/revtree/svgview.py

    r1669 r1675  
    2222 
    2323UNIT = 25 
     24SQRT2=sqrt(2) 
     25SQRT3=sqrt(3) 
     26 
     27# FIXME: This should be set in Trac properties, or event better:  
     28#        as CSS properties 
    2429FONT_NAME = 'Verdana' 
    2530FONT_SIZE = '14pt' 
    26 SQRT2=sqrt(2) 
    27 SQRT3=sqrt(3) 
    28  
    29 debugw = [] 
    30 def dbgPt(x,y,c='red',d=5): 
    31     debugw.append(SVG.circle(x,y,d, 'white', c, '2')) 
    32 def dbgLn(x1,y1,x2,y2,c='red',w=3): 
    33     debugw.append(SVG.line(x1,y1,x2,y2,c,w)) 
    34 def dbgDump(svg): 
    35     map(svg.addElement, debugw) 
     31 
     32# Debug functions to place debug circles on the SVG graph 
     33#debugw = [] 
     34#def dbgPt(x,y,c='red',d=5): 
     35#    debugw.append(SVG.circle(x,y,d, 'white', c, '2')) 
     36#def dbgLn(x1,y1,x2,y2,c='red',w=3): 
     37#    debugw.append(SVG.line(x1,y1,x2,y2,c,w)) 
     38#def dbgDump(svg): 
     39#    map(svg.addElement, debugw) 
    3640     
    3741def textwidth(text): 
     
    4650             
    4751class SvgColor(object): 
     52    """Helpers for color management (conversion, generation, ...)""" 
    4853     
    4954    colormap = { 'black':       (0,0,0), 
     
    133138 
    134139class SvgBaseChangeset(object): 
     140    """Base class for graphical changeset/revision nodes 
     141       This changeset cannot be rendered in the SVG graph""" 
    135142     
    136143    def __init__(self, parent, revision, position=None): 
     
    174181 
    175182    def render(self): 
    176         # debug only 
    177         #w = SVG.circle(self._position[0], self._position[1], 
    178         #               20, 'blue', 'blue', 3) 
    179         #self._parent.svg().addElement(w) 
    180183        pass 
    181184 
    182185 
    183186class SvgChangeset(SvgBaseChangeset): 
     187    """Changeset/revision node""" 
    184188     
    185189    def __init__(self, parent, changeset): 
     
    272276 
    273277class SvgBranchHeader(object): 
     278    """Branch title""" 
    274279     
    275280    def __init__(self, parent, title): 
     
    318323 
    319324class SvgBranch(object): 
    320      
     325    """Branch (set of changesets which whose commits share a common base 
     326       directory)""" 
     327        
    321328    def __init__(self, parent, branch, style): 
    322329        self._parent = parent 
     
    460467 
    461468class SvgAxis(object): 
    462  
     469    """Simple graphical line between a header and the youngest 
     470       revision of a branch""" 
     471        
    463472    def __init__(self, parent, head, tail, color='#7f7f7f'): 
    464473        self._parent = parent 
     
    483492 
    484493class SvgTransition(object): 
    485  
     494    """Simple graphical line between two consecutive changesets  
     495       on the same branch""" 
     496        
    486497    def __init__(self, parent, srcChg, dstChg, color): 
    487498        self._parent = parent 
     
    507518 
    508519class SvgChangeLink(object): 
     520    """Deprecated. Set of associated changeset on the same branch""" 
    509521     
    510522    def __init__(self, parent, srcChg, dstChg, color='#000'): 
     
    542554 
    543555class SvgGroup(object): 
     556    """Graphical group of consecutive changesets within a same branch""" 
    544557     
    545558    def __init__(self, parent, firstChg, lastChg, color='#fffbdb'): 
     
    579592         
    580593class SvgOperation(object): 
    581  
     594    """Graphical operation between two changesets of distinct branches  
     595       (such as a switch/branch creation, a merge operation, ...)""" 
     596        
    582597    def __init__(self, parent, srcChg, dstChg, color='black'): 
    583598        self._parent = parent 
     
    704719 
    705720class SvgArrows(object): 
     721    """Arrow headers for graphical links and operations""" 
    706722     
    707723    def __init__(self, parent): 
     
    734750     
    735751class SvgRevtree(object): 
    736      
     752    """Main object that represents the revision tree as a SVG graph""" 
     753 
    737754    def __init__(self, env, repos, urlbase): 
    738755        """Construct a new SVG revision tree""" 
     
    877894           Store every points of an operation path. If the point is already 
    878895           marked as used, find another point, looking around the original 
    879            point for a free slot 
    880         """ 
     896           point for a free slot""" 
    881897        (x, y) = point 
    882898        kx = int(x) 
     
    916932        map(lambda b: b.render(), self._svgbranches.values()) 
    917933        map(lambda e: e.render(2), self._enhancers) 
    918         dbgDump(self._svg) 
     934        #dbgDump(self._svg) 
  • revtreeplugin/0.10/revtree/templates/revtree.cs

    r1669 r1675  
    77 
    88<h1>Revision Tree</h1> 
     9 
     10<div id="settings"> 
     11 <form id="prefs" method="get" action=""> 
     12  <div class="revprops"> 
     13    <fieldset id="properties"> 
     14     <legend>Filters</legend> 
     15     <div class="field"> 
     16      <label for="branch">Branch</label> 
     17      <select id="branch" name="branch"><?cs each:br = revtree.branches ?> 
     18       <option value="<?cs var:br ?>" <?cs if:revtree.branch == br  
     19       ?>selected="selected"<?cs /if ?>><?cs var:br ?></option><?cs 
     20      /each ?></select> 
     21     </div> 
     22     <div class="field"> 
     23      <label for="author">Author</label> 
     24      <select id="author" name="author"><?cs each:auth = revtree.authors ?> 
     25       <option value="<?cs var:auth ?>" <?cs if:revtree.author == auth  
     26       ?>selected="selected"<?cs /if ?>><?cs var:auth ?></option><?cs 
     27      /each ?></select> 
     28     </div> 
     29    </fieldset> 
     30   </div> 
     31  
     32   <div class="revprops"> 
     33    <fieldset id="limits"> 
     34     <legend>Revisions</legend> 
     35     <div class="field"> 
     36      <input type="radio" id="limperiod" name="limits" value="limperiod" <?cs  
     37       if:revtree.limits == "limperiod" ?> checked="checked"<?cs /if ?>/> 
     38      <label for="period">Show last </label> 
     39      <select id="period" name="period"> 
     40       <?cs each:per = revtree.periods ?><option value="<?cs  
     41        var:per.value ?>" <?cs if:revtree.period == per.value  
     42        ?>selected="selected"<?cs /if ?>><?cs var:per.label ?></option> 
     43        <?cs /each ?></select> 
     44     </div> 
     45     <div class="field"> 
     46      <input type="radio" id="limrev" name="limits" value="limrev" <?cs  
     47       if:revtree.limits == "limrev" ?> checked="checked"<?cs /if ?>/> 
     48      <label for="revmin">From </label> 
     49       <select id="revmin" name="revmin"> 
     50        <?cs each:rev = revtree.revisions ?><option value="<?cs  
     51        var:rev ?>" <?cs if:revtree.revmin == rev ?>selected="selected"<?cs  
     52        /if ?>><?cs var:rev?></option> 
     53        <?cs /each ?></select> 
     54      <label for="revmax">up to </label> 
     55       <select id="revmax" name="revmax"> 
     56        <?cs each:rev = revtree.revisions ?><option value="<?cs  
     57        var:rev ?>" <?cs if:revtree.revmax == rev ?>selected="selected"<?cs  
     58        /if ?>><?cs var:rev ?></option> 
     59        <?cs /each ?></select> 
     60     </div> 
     61    </fieldset> 
     62   </div> 
     63  
     64   <div class="revprops" id="treestyle"> 
     65    <fieldset> 
     66     <legend>Style</legend> 
     67      <div class="field"> 
     68        <div> 
     69          <input type="radio" id="compact" name="treestyle" value="compact" <?cs  
     70         if:revtree.treestyle == "compact" ?> checked="checked"<?cs /if ?>/> 
     71        <label for="compact">Compact</label> 
     72        </div> 
     73        <div> 
     74        <input type="radio" id="timeline" name="treestyle" value="timeline" <?cs  
     75          if:revtree.treestyle == "timeline" ?> checked="checked"<?cs /if ?>/> 
     76         <label for="compact">Timeline</label> 
     77        </div> 
     78      </div> 
     79    </fieldset> 
     80   </div> 
     81  
     82   <div class="revprops" id="treeoptions"> 
     83    <fieldset> 
     84     <legend>Options</legend> 
     85     <div class="field"> 
     86      <input type="hidden" name="checkbox_hideterm"/> 
     87      <input type="checkbox" id="hideterm" 
     88        name="hideterm" <?cs if:revtree.hideterm 
     89        ?>checked="checked"<?cs /if ?> value="1"/><label for="hideterm">Hide  
     90        terminated branches</label> 
     91     </div> 
     92    </fieldset> 
     93   </div> 
     94  
     95   <div class="revprops" id="treeupdate"> 
     96    <div class="buttons"> 
     97     <input type="submit" value="Update"/> 
     98    </div> 
     99   </div> 
     100 </form> 
     101</div> 
    9102 
    10103<script type="text/javascript"> 
     
    21114</script> 
    22115 
    23 <div id="settings"> 
    24  <form id="prefs" method="get" action=""> 
    25   <div> 
    26    <div class="revprops"> 
    27      <fieldset id="properties"> 
    28       <legend>Filters</legend> 
    29       <div class="field"> 
    30        <label for="branch">Branch</label> 
    31        <select id="branch" name="branch"><?cs each:br = revtree.branches ?> 
    32         <option value="<?cs var:br ?>" <?cs if:revtree.branch == br  
    33         ?>selected="selected"<?cs /if ?>><?cs var:br ?></option><?cs 
    34        /each ?></select> 
    35       </div> 
    36       <div class="field"> 
    37        <label for="author">Author</label> 
    38        <select id="author" name="author"><?cs each:auth = revtree.authors ?> 
    39         <option value="<?cs var:auth ?>" <?cs if:revtree.author == auth  
    40         ?>selected="selected"<?cs /if ?>><?cs var:auth ?></option><?cs 
    41        /each ?></select> 
    42       </div> 
    43      </fieldset> 
    44     </div> 
    45   
    46     <div class="revprops"> 
    47      <fieldset id="limits"> 
    48       <legend>Revisions</legend> 
    49       <div class="field"> 
    50        <input type="radio" id="limperiod" name="limits" value="limperiod" <?cs  
    51         if:revtree.limits == "limperiod" ?> checked="checked"<?cs /if ?>/> 
    52        <label for="period">Show last </label> 
    53        <select id="period" name="period"> 
    54         <?cs each:per = revtree.periods ?><option value="<?cs  
    55          var:per.value ?>" <?cs if:revtree.period == per.value  
    56          ?>selected="selected"<?cs /if ?>><?cs var:per.label ?></option> 
    57          <?cs /each ?></select> 
    58       </div> 
    59       <div class="field"> 
    60        <input type="radio" id="limrev" name="limits" value="limrev" <?cs  
    61         if:revtree.limits == "limrev" ?> checked="checked"<?cs /if ?>/> 
    62        <label for="revmin">From </label> 
    63         <select id="revmin" name="revmin"> 
    64          <?cs each:rev = revtree.revisions ?><option value="<?cs  
    65          var:rev ?>" <?cs if:revtree.revmin == rev ?>selected="selected"<?cs  
    66          /if ?>><?cs var:rev?></option> 
    67          <?cs /each ?></select> 
    68        <label for="revmax">up to </label> 
    69         <select id="revmax" name="revmax"> 
    70          <?cs each:rev = revtree.revisions ?><option value="<?cs  
    71          var:rev ?>" <?cs if:revtree.revmax == rev ?>selected="selected"<?cs  
    72          /if ?>><?cs var:rev ?></option> 
    73          <?cs /each ?></select> 
    74       </div> 
    75      </fieldset> 
    76     </div> 
    77   
    78     <div class="revprops" id="treestyle"> 
    79      <fieldset> 
    80       <legend>Style</legend> 
    81        <div class="field"> 
    82          <div> 
    83            <input type="radio" id="compact" name="treestyle" value="compact" <?cs  
    84           if:revtree.treestyle == "compact" ?> checked="checked"<?cs /if ?>/> 
    85          <label for="compact">Compact</label> 
    86          </div> 
    87          <div> 
    88          <input type="radio" id="timeline" name="treestyle" value="timeline" <?cs  
    89            if:revtree.treestyle == "timeline" ?> checked="checked"<?cs /if ?>/> 
    90           <label for="compact">Timeline</label> 
    91          </div> 
    92        </div> 
    93      </fieldset> 
    94     </div> 
    95   
    96     <div class="revprops" id="options"> 
    97      <fieldset id="options"> 
    98       <legend>Options</legend> 
    99       <div class="field"> 
    100        <input type="hidden" name="checkbox_hideterm"/> 
    101        <input type="checkbox" id="hideterm" 
    102          name="hideterm" <?cs if:revtree.hideterm 
    103          ?>checked="checked"<?cs /if ?> value="1"/><label for="hideterm">Hide  
    104          terminated branches</label> 
    105       </div> 
    106      </fieldset> 
    107     </div> 
    108   
    109     <div class="revprops" id="update"> 
    110      <div class="buttons"> 
    111       <input type="submit" value="Update"/> 
    112      </div> 
    113     </div> 
    114   </div> 
    115  </form> 
    116 </div> 
    117  
    118116<?cs if revtree.legend ?> 
    119117<div id="legend"> 
     
    128126<?cs else ?> 
    129127<div class="svg"> 
     128  <!-- Inline SVG breaks the XHTML 1.0 strict conformance 
     129       XHTML + SVG + MathML document type does not help ... --> 
    130130  <?cs var:revtree.svg.image ?> 
    131131</div> 
  • revtreeplugin/0.10/revtree/web_ui.py

    r1669 r1675  
    369369 
    370370    def _select_parameters(self, repos, req, revstore): 
    371         """ """ 
     371        """Calculates the revisions/branches/authors to show as selectable 
     372           properties for the revtree generation""" 
    372373        revs = [c for c in repos.changesets()] 
    373374        revs.reverse()