Fossil

Check-in [afcdc7ec97]
Login

Check-in [afcdc7ec97]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "leaves" webpage and the "branches" CLI command. We need to work on the nomenclature.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: afcdc7ec979a27421ed8d03760eb7740fa11ba5c
User & Date: drh 2007-08-01 12:49:41.000
Context
2007-08-01
13:08
Avoid an unnecessary HTTP round-trip on syncs. ... (check-in: ae40356c57 user: drh tags: trunk)
12:49
Add the "leaves" webpage and the "branches" CLI command. We need to work on the nomenclature. ... (check-in: afcdc7ec97 user: drh tags: trunk)
12:20
The merge at [dd9633a03d] did not work because of the bug just fixed. This change moves the changes that should have been in that merge into the main line of the tree. ... (check-in: 04f7535ee3 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/descendents.c.
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
    " WHERE EXISTS(SELECT 1 FROM plink WHERE pid=rid)"
  );
}

/*
** COMMAND:  leaves
**
** Find all leaf versions

*/
void leaves_cmd(void){
  Stmt q;
  int base;

  db_must_be_within_tree();
  if( g.argc==2 ){







|
>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    " WHERE EXISTS(SELECT 1 FROM plink WHERE pid=rid)"
  );
}

/*
** COMMAND:  leaves
**
** Find all leaf descendents of the current version or of the
** specified version.
*/
void leaves_cmd(void){
  Stmt q;
  int base;

  db_must_be_within_tree();
  if( g.argc==2 ){
87
88
89
90
91
92
93






















































    " WHERE blob.rid=leaves.rid"
    "   AND event.objid=leaves.rid"
    " ORDER BY event.mtime DESC"
  );
  print_timeline(&q, 20);
  db_finalize(&q);
}





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    " WHERE blob.rid=leaves.rid"
    "   AND event.objid=leaves.rid"
    " ORDER BY event.mtime DESC"
  );
  print_timeline(&q, 20);
  db_finalize(&q);
}

/*
** COMMAND:  branches
**
** Find leaves of all branches.
*/
void branches_cmd(void){
  Stmt q;
  int base;

  db_must_be_within_tree();
  if( g.argc==2 ){
    base = db_lget_int("checkout", 0);
  }else{
    base = name_to_rid(g.argv[2]);
  }
  if( base==0 ) return;
  db_prepare(&q,
    "SELECT blob.uuid, datetime(event.mtime,'localtime'), event.comment"
    "  FROM blob, event"
    " WHERE blob.rid IN"
    "       (SELECT cid FROM plink EXCEPT SELECT pid FROM plink)"
    "   AND event.objid=blob.rid"
    " ORDER BY event.mtime DESC"
  );
  print_timeline(&q, 20);
  db_finalize(&q);
}

/*
** WEBPAGE:  leaves
**
** Find leaves of all branches.
*/
void branches_page(void){
  Stmt q;

  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }

  style_header("Leaves");
  db_prepare(&q,
    "SELECT blob.uuid, datetime(event.mtime,'localtime'),"
    "       event.comment, event.user"
    "  FROM blob, event"
    " WHERE blob.rid IN"
    "       (SELECT cid FROM plink EXCEPT SELECT pid FROM plink)"
    "   AND event.objid=blob.rid"
    " ORDER BY event.mtime DESC"
  );
  www_print_timeline(&q);
  db_finalize(&q);
  style_footer();
}
Changes to src/style.c.
83
84
85
86
87
88
89

90
91
92
93
94
95
96
    zLogInOut = "Login";
  }else{
    @ <small>logged in as %h(g.zLogin)</small>
  }
  @ </td><td valign="top" align="right">
  @ <a href="%s(g.zBaseURL)/index">Home</a>
  if( g.okRead ){

    @ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
  }
  if( g.okRdWiki ){
    @ | <a href="%s(g.zBaseURL)/wiki">Wiki</a>
  }
#if 0
  @ | <font color="#888888">Search</font>







>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    zLogInOut = "Login";
  }else{
    @ <small>logged in as %h(g.zLogin)</small>
  }
  @ </td><td valign="top" align="right">
  @ <a href="%s(g.zBaseURL)/index">Home</a>
  if( g.okRead ){
    @ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
    @ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
  }
  if( g.okRdWiki ){
    @ | <a href="%s(g.zBaseURL)/wiki">Wiki</a>
  }
#if 0
  @ | <font color="#888888">Search</font>
Changes to src/timeline.c.
49
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64

65
66
67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
























99
100
101
102
103
104
105
      @ <a href="%s(g.zBaseURL)/diff?v2=%s(zV1)">[diff]</a>
    }else{
      @ <a href="%s(g.zBaseURL)/diff?v1=%s(zV1)&v2=%s(zV2)">[diff]</a>
    }
  }
}


/*
** WEBPAGE: timeline

*/
void page_timeline(void){
  Stmt q;
  char zPrevDate[20];

  /* To view the timeline, must have permission to read project data.

  */
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }

  style_header("Timeline");

  zPrevDate[0] = 0;
  db_prepare(&q,
    "SELECT uuid, datetime(event.mtime,'localtime'), comment, user"
    "  FROM event, blob"
    " WHERE event.type='ci' AND blob.rid=event.objid"
    " ORDER BY event.mtime DESC"
  );
  @ <table cellspacing=0 border=0 cellpadding=0>
  while( db_step(&q)==SQLITE_ROW ){
    const char *zDate = db_column_text(&q, 1);
    if( memcmp(zDate, zPrevDate, 10) ){
      sprintf(zPrevDate, "%.10s", zDate);
      @ <tr><td colspan=3>
      @ <table cellpadding=2 border=0>
      @ <tr><td bgcolor="#a0b5f4" class="border1">
      @ <table cellpadding=2 cellspacing=0 border=0><tr>
      @ <td bgcolor="#d0d9f4" class="bkgnd1">%s(zPrevDate)</td>
      @ </tr></table>
      @ </td></tr></table>
      @ </td></tr>
    }
    @ <tr><td valign="top">%s(&zDate[11])</td>
    @ <td width="20"></td>
    @ <td valign="top" align="left">
    hyperlink_to_uuid(db_column_text(&q,0));
    @ %h(db_column_text(&q,2)) (by %h(db_column_text(&q,3)))</td>
  }
  db_finalize(&q);
  @ </table>
























  style_footer();
}
/*
** The input query q selects various records.  Print a human-readable
** summary of those records.
**
** Limit the number of entries printed to nLine.







<

|
>
|
<
|
|
|
<
>
|
<
<
|
<
>

<
<
<
<
<
<

|
|














|
|

<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







49
50
51
52
53
54
55

56
57
58
59

60
61
62

63
64


65

66
67






68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
      @ <a href="%s(g.zBaseURL)/diff?v2=%s(zV1)">[diff]</a>
    }else{
      @ <a href="%s(g.zBaseURL)/diff?v1=%s(zV1)&v2=%s(zV2)">[diff]</a>
    }
  }
}


/*
** Output a timeline in the web format given a query.  The query
** should return 4 columns:
**

**    0.  UUID
**    1.  Date/Time
**    2.  Comment string

**    3.  User
*/


void www_print_timeline(Stmt *pQuery){

  char zPrevDate[20];
  zPrevDate[0] = 0;






  @ <table cellspacing=0 border=0 cellpadding=0>
  while( db_step(pQuery)==SQLITE_ROW ){
    const char *zDate = db_column_text(pQuery, 1);
    if( memcmp(zDate, zPrevDate, 10) ){
      sprintf(zPrevDate, "%.10s", zDate);
      @ <tr><td colspan=3>
      @ <table cellpadding=2 border=0>
      @ <tr><td bgcolor="#a0b5f4" class="border1">
      @ <table cellpadding=2 cellspacing=0 border=0><tr>
      @ <td bgcolor="#d0d9f4" class="bkgnd1">%s(zPrevDate)</td>
      @ </tr></table>
      @ </td></tr></table>
      @ </td></tr>
    }
    @ <tr><td valign="top">%s(&zDate[11])</td>
    @ <td width="20"></td>
    @ <td valign="top" align="left">
    hyperlink_to_uuid(db_column_text(pQuery,0));
    @ %h(db_column_text(pQuery,2)) (by %h(db_column_text(pQuery,3)))</td>
  }

  @ </table>
}



/*
** WEBPAGE: timeline
*/
void page_timeline(void){
  Stmt q;

  /* To view the timeline, must have permission to read project data.
  */
  login_check_credentials();
  if( !g.okRead ){ login_needed(); return; }

  style_header("Timeline");
  db_prepare(&q,
    "SELECT uuid, datetime(event.mtime,'localtime'), comment, user"
    "  FROM event, blob"
    " WHERE event.type='ci' AND blob.rid=event.objid"
    " ORDER BY event.mtime DESC"
  );
  www_print_timeline(&q);
  db_finalize(&q);
  style_footer();
}
/*
** The input query q selects various records.  Print a human-readable
** summary of those records.
**
** Limit the number of entries printed to nLine.