1 |
bertho |
1.1 |
/*
|
2 |
|
|
* CvsGraph graphical representation generator of brances and revisions
|
3 |
|
|
* of a file in cvs/rcs.
|
4 |
|
|
*
|
5 |
bertho |
1.29 |
* Copyright (C) 2001,2002,2003 B. Stultiens
|
6 |
bertho |
1.1 |
*
|
7 |
|
|
* This program is free software; you can redistribute it and/or modify
|
8 |
|
|
* it under the terms of the GNU General Public License as published by
|
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
10 |
|
|
* (at your option) any later version.
|
11 |
|
|
*
|
12 |
|
|
* This program is distributed in the hope that it will be useful,
|
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
* GNU General Public License for more details.
|
16 |
|
|
*
|
17 |
|
|
* You should have received a copy of the GNU General Public License
|
18 |
|
|
* along with this program; if not, write to the Free Software
|
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
bertho |
1.14 |
#include "config.h"
|
23 |
|
|
|
24 |
bertho |
1.1 |
#include <stdio.h>
|
25 |
|
|
#include <stdlib.h>
|
26 |
|
|
#include <unistd.h>
|
27 |
|
|
#include <string.h>
|
28 |
|
|
#include <assert.h>
|
29 |
|
|
#include <sys/types.h>
|
30 |
|
|
#include <sys/stat.h>
|
31 |
|
|
#include <sys/wait.h>
|
32 |
|
|
#include <fcntl.h>
|
33 |
|
|
#include <regex.h>
|
34 |
|
|
#include <errno.h>
|
35 |
bertho |
1.8 |
#include <ctype.h>
|
36 |
bertho |
1.9 |
#include <time.h>
|
37 |
bertho |
1.18 |
#include <limits.h>
|
38 |
bertho |
1.30 |
#include <regex.h>
|
39 |
bertho |
1.35 |
#include <math.h>
|
40 |
bertho |
1.9 |
|
41 |
bertho |
1.14 |
#ifdef HAVE_GETOPT_H
|
42 |
|
|
# include <getopt.h>
|
43 |
|
|
#endif
|
44 |
|
|
|
45 |
bertho |
1.1 |
#include <gd.h>
|
46 |
|
|
#include <gdfontt.h>
|
47 |
|
|
|
48 |
|
|
#include "cvsgraph.h"
|
49 |
|
|
#include "utils.h"
|
50 |
|
|
#include "readconf.h"
|
51 |
bertho |
1.7 |
#include "rcs.h"
|
52 |
bertho |
1.1 |
|
53 |
bertho |
1.5 |
#if !defined(HAVE_IMAGE_GIF) && !defined(HAVE_IMAGE_PNG) && !defined(HAVE_IMAGE_JPEG)
|
54 |
|
|
# error No image output format available. Check libgd
|
55 |
|
|
#endif
|
56 |
|
|
|
57 |
|
|
|
58 |
bertho |
1.21 |
/*#define DEBUG 1*/
|
59 |
bertho |
1.19 |
/*#define NOGDFILL 1*/
|
60 |
bertho |
1.26 |
/*#define DEBUG_IMAGEMAP 1*/
|
61 |
bertho |
1.19 |
|
62 |
bertho |
1.32 |
#define LOOPSAFEGUARD 10000 /* Max itterations in possible infinite loops */
|
63 |
bertho |
1.1 |
|
64 |
|
|
#ifndef MAX
|
65 |
|
|
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
66 |
|
|
#endif
|
67 |
|
|
|
68 |
|
|
#ifndef MIN
|
69 |
|
|
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
70 |
|
|
#endif
|
71 |
|
|
|
72 |
|
|
#define ALIGN_HL 0x00
|
73 |
|
|
#define ALIGN_HC 0x01
|
74 |
|
|
#define ALIGN_HR 0x02
|
75 |
bertho |
1.9 |
#define ALIGN_HX 0x0f
|
76 |
bertho |
1.1 |
#define ALIGN_VT 0x00
|
77 |
|
|
#define ALIGN_VC 0x10
|
78 |
|
|
#define ALIGN_VB 0x20
|
79 |
|
|
#define ALIGN_VX 0xf0
|
80 |
bertho |
1.9 |
|
81 |
bertho |
1.35 |
#ifndef M_PI /* math.h should have defined this */
|
82 |
|
|
# define M_PI 3.14159265358979323846
|
83 |
|
|
#endif
|
84 |
|
|
#define ROUND(f) ((f >= 0.0)?((int)(f + 0.5)):((int)(f - 0.5)))
|
85 |
|
|
|
86 |
|
|
#define ARROW_LENGTH 12 /* Default arrow dimensions */
|
87 |
|
|
#define ARROW_WIDTH 3
|
88 |
|
|
|
89 |
bertho |
1.1 |
/*
|
90 |
|
|
**************************************************************************
|
91 |
|
|
* Globals
|
92 |
|
|
**************************************************************************
|
93 |
|
|
*/
|
94 |
|
|
|
95 |
|
|
config_t conf;
|
96 |
bertho |
1.7 |
int debuglevel;
|
97 |
bertho |
1.9 |
color_t white_color = {255, 255, 255, 0};
|
98 |
|
|
color_t black_color = {0, 0, 0, 0};
|
99 |
|
|
|
100 |
bertho |
1.30 |
/*
|
101 |
|
|
**************************************************************************
|
102 |
|
|
* Forwards
|
103 |
|
|
**************************************************************************
|
104 |
|
|
*/
|
105 |
|
|
static void zap_string(void);
|
106 |
|
|
static char *dup_string(void);
|
107 |
|
|
static void add_string_str(const char *s);
|
108 |
|
|
static void add_string_ch(int ch);
|
109 |
|
|
static void add_string_date(const char *d);
|
110 |
|
|
static void add_string_str_html(const char *s, int maxlen);
|
111 |
|
|
static void add_string_str_len(const char *s, int maxlen);
|
112 |
bertho |
1.1 |
|
113 |
|
|
/*
|
114 |
|
|
**************************************************************************
|
115 |
bertho |
1.17 |
* Debug routines
|
116 |
bertho |
1.1 |
**************************************************************************
|
117 |
|
|
*/
|
118 |
bertho |
1.19 |
static void dump_rev(char *p, rev_t *r)
|
119 |
bertho |
1.1 |
{
|
120 |
bertho |
1.7 |
printf("%s", p);
|
121 |
|
|
if(r)
|
122 |
|
|
printf("'%s', '%s', %d\n", r->rev, r->branch, r->isbranch);
|
123 |
|
|
else
|
124 |
|
|
printf("<null>\n");
|
125 |
bertho |
1.1 |
}
|
126 |
|
|
|
127 |
bertho |
1.19 |
static void dump_id(char *p, char *d)
|
128 |
bertho |
1.1 |
{
|
129 |
bertho |
1.7 |
printf("%s", p);
|
130 |
|
|
if(d)
|
131 |
|
|
printf("'%s'\n", d);
|
132 |
|
|
else
|
133 |
|
|
printf("<null>\n");
|
134 |
bertho |
1.1 |
}
|
135 |
|
|
|
136 |
bertho |
1.19 |
static void dump_idrev(char *p, idrev_t *t)
|
137 |
bertho |
1.1 |
{
|
138 |
bertho |
1.7 |
printf("%s", p);
|
139 |
|
|
if(t)
|
140 |
bertho |
1.1 |
{
|
141 |
bertho |
1.7 |
printf("'%s' -> ", t->id);
|
142 |
|
|
dump_rev("", t->rev);
|
143 |
bertho |
1.1 |
}
|
144 |
|
|
else
|
145 |
bertho |
1.7 |
printf("<null>\n");
|
146 |
bertho |
1.1 |
}
|
147 |
|
|
|
148 |
bertho |
1.19 |
static void dump_tag(char *p, tag_t *t)
|
149 |
bertho |
1.1 |
{
|
150 |
bertho |
1.7 |
printf("%s", p);
|
151 |
|
|
if(t)
|
152 |
bertho |
1.1 |
{
|
153 |
bertho |
1.7 |
printf("'%s' -> ", t->tag);
|
154 |
|
|
dump_rev("", t->rev);
|
155 |
bertho |
1.1 |
}
|
156 |
bertho |
1.7 |
else
|
157 |
|
|
printf("<null>\n");
|
158 |
bertho |
1.1 |
}
|
159 |
|
|
|
160 |
bertho |
1.19 |
static void dump_delta(char *p, delta_t *d)
|
161 |
bertho |
1.1 |
{
|
162 |
bertho |
1.7 |
int i;
|
163 |
|
|
printf("%sdelta.rev : ", p);
|
164 |
|
|
dump_rev("", d->rev);
|
165 |
|
|
printf("%sdelta.date : %s\n", p, d->date);
|
166 |
|
|
printf("%sdelta.author: %s\n", p, d->author);
|
167 |
|
|
printf("%sdelta.state : %s\n", p, d->state);
|
168 |
|
|
for(i = 0; d->branches && i < d->branches->nrevs; i++)
|
169 |
bertho |
1.1 |
{
|
170 |
bertho |
1.7 |
printf("%sdelta.branch: ", p);
|
171 |
|
|
dump_rev("", d->branches->revs[i]);
|
172 |
bertho |
1.1 |
}
|
173 |
bertho |
1.7 |
printf("%sdelta.next : ", p);
|
174 |
|
|
dump_rev("", d->next);
|
175 |
|
|
printf("\n");
|
176 |
bertho |
1.1 |
}
|
177 |
|
|
|
178 |
bertho |
1.19 |
static void dump_dtext(char *p, dtext_t *d)
|
179 |
bertho |
1.1 |
{
|
180 |
bertho |
1.7 |
printf("%sdtext.rev : ", p);
|
181 |
|
|
dump_rev("", d->rev);
|
182 |
|
|
printf("%sdtext.log : %d bytes\n", p, d->log ? strlen(d->log) : -1);
|
183 |
|
|
printf("%sdtext.text : %d bytes\n", p, d->text ? strlen(d->text) : -1);
|
184 |
|
|
printf("\n");
|
185 |
bertho |
1.1 |
}
|
186 |
|
|
|
187 |
bertho |
1.19 |
static void dump_rcsfile(rcsfile_t *rcs)
|
188 |
bertho |
1.1 |
{
|
189 |
bertho |
1.7 |
int i;
|
190 |
|
|
printf("root : '%s'\n", rcs->root);
|
191 |
|
|
printf("module : '%s'\n", rcs->module);
|
192 |
|
|
printf("file : '%s'\n", rcs->file);
|
193 |
|
|
dump_rev("head : ", rcs->head);
|
194 |
|
|
dump_rev("branch : ", rcs->branch);
|
195 |
|
|
printf("access :\n");
|
196 |
|
|
for(i = 0; rcs->access && i < rcs->access->nids; i++)
|
197 |
|
|
dump_id("\t", rcs->access->ids[i]);
|
198 |
|
|
printf("tags :\n");
|
199 |
|
|
for(i = 0; rcs->tags && i < rcs->tags->ntags; i++)
|
200 |
|
|
dump_tag("\t", rcs->tags->tags[i]);
|
201 |
|
|
printf("locks :%s\n", rcs->strict ? " (strict)" : "");
|
202 |
|
|
for(i = 0; rcs->locks && i < rcs->locks->nidrevs; i++)
|
203 |
|
|
dump_idrev("\t", rcs->locks->idrevs[i]);
|
204 |
|
|
printf("comment: '%s'\n", rcs->comment);
|
205 |
|
|
printf("expand : '%s'\n", rcs->expand ? rcs->expand : "(default -kv)");
|
206 |
|
|
printf("deltas :\n");
|
207 |
|
|
for(i = 0; rcs->deltas && i < rcs->deltas->ndeltas; i++)
|
208 |
|
|
dump_delta("\t", rcs->deltas->deltas[i]);
|
209 |
|
|
printf("desc : '%s'\n", rcs->desc);
|
210 |
|
|
printf("dtexts :\n");
|
211 |
|
|
for(i = 0; rcs->dtexts && i < rcs->dtexts->ndtexts; i++)
|
212 |
|
|
dump_dtext("\t", rcs->dtexts->dtexts[i]);
|
213 |
|
|
|
214 |
|
|
fflush(stdout);
|
215 |
bertho |
1.1 |
}
|
216 |
|
|
|
217 |
bertho |
1.7 |
/*
|
218 |
|
|
**************************************************************************
|
219 |
|
|
* Read the rcs file
|
220 |
|
|
**************************************************************************
|
221 |
|
|
*/
|
222 |
|
|
rcsfile_t *get_rcsfile(const char *cvsroot, const char *module, const char *file)
|
223 |
bertho |
1.1 |
{
|
224 |
bertho |
1.7 |
char *cmd = NULL;
|
225 |
|
|
int rv;
|
226 |
bertho |
1.1 |
|
227 |
bertho |
1.18 |
if(file)
|
228 |
bertho |
1.9 |
{
|
229 |
bertho |
1.18 |
cmd = xmalloc(strlen(cvsroot) + strlen(module) + strlen(file) + 1);
|
230 |
|
|
sprintf(cmd, "%s%s%s", cvsroot, module, file);
|
231 |
|
|
if(!(rcsin = fopen(cmd, "rb")))
|
232 |
|
|
{
|
233 |
|
|
perror(cmd);
|
234 |
|
|
return NULL;
|
235 |
|
|
}
|
236 |
|
|
input_file = cmd;
|
237 |
|
|
}
|
238 |
|
|
else
|
239 |
|
|
{
|
240 |
|
|
rcsin = stdin;
|
241 |
|
|
input_file = "<stdin>";
|
242 |
bertho |
1.9 |
}
|
243 |
bertho |
1.7 |
line_number = 1;
|
244 |
|
|
rv = rcsparse();
|
245 |
bertho |
1.18 |
if(file)
|
246 |
|
|
{
|
247 |
|
|
fclose(rcsin);
|
248 |
|
|
xfree(cmd);
|
249 |
|
|
}
|
250 |
bertho |
1.7 |
if(rv)
|
251 |
bertho |
1.1 |
return NULL;
|
252 |
bertho |
1.7 |
input_file = NULL;
|
253 |
bertho |
1.18 |
if(file)
|
254 |
|
|
{
|
255 |
|
|
rcsfile->root = xstrdup(cvsroot);
|
256 |
|
|
rcsfile->module = xstrdup(module);
|
257 |
|
|
rcsfile->file = xstrdup(file);
|
258 |
|
|
}
|
259 |
|
|
else
|
260 |
|
|
{
|
261 |
|
|
rcsfile->root = xstrdup("");
|
262 |
|
|
rcsfile->module = xstrdup("");
|
263 |
|
|
rcsfile->file = xstrdup("<stdin>");
|
264 |
|
|
}
|
265 |
bertho |
1.7 |
return rcsfile;
|
266 |
bertho |
1.1 |
}
|
267 |
|
|
|
268 |
|
|
/*
|
269 |
|
|
**************************************************************************
|
270 |
|
|
* Sort and find helpers
|
271 |
|
|
**************************************************************************
|
272 |
|
|
*/
|
273 |
bertho |
1.5 |
int count_dots(const char *s)
|
274 |
|
|
{
|
275 |
|
|
int i;
|
276 |
|
|
for(i = 0; *s; s++)
|
277 |
|
|
{
|
278 |
|
|
if(*s == '.')
|
279 |
|
|
i++;
|
280 |
|
|
}
|
281 |
|
|
return i;
|
282 |
|
|
}
|
283 |
|
|
|
284 |
bertho |
1.7 |
int compare_rev(int bcmp, const rev_t *r1, const rev_t *r2)
|
285 |
bertho |
1.5 |
{
|
286 |
|
|
int d1, d2;
|
287 |
bertho |
1.7 |
char *c1, *c2;
|
288 |
bertho |
1.5 |
char *v1, *v2;
|
289 |
|
|
char *s1, *s2;
|
290 |
|
|
int retval = 0;
|
291 |
|
|
assert(r1 != NULL);
|
292 |
|
|
assert(r2 != NULL);
|
293 |
bertho |
1.7 |
if(bcmp)
|
294 |
|
|
{
|
295 |
|
|
assert(r1->branch != NULL);
|
296 |
|
|
assert(r2->branch != NULL);
|
297 |
|
|
c1 = r1->branch;
|
298 |
|
|
c2 = r2->branch;
|
299 |
|
|
}
|
300 |
|
|
else
|
301 |
|
|
{
|
302 |
|
|
assert(r1->rev != NULL);
|
303 |
|
|
assert(r2->rev != NULL);
|
304 |
|
|
c1 = r1->rev;
|
305 |
|
|
c2 = r2->rev;
|
306 |
|
|
}
|
307 |
bertho |
1.5 |
|
308 |
bertho |
1.7 |
d1 = count_dots(c1);
|
309 |
|
|
d2 = count_dots(c2);
|
310 |
bertho |
1.5 |
if(d1 != d2)
|
311 |
|
|
{
|
312 |
|
|
return d1 - d2;
|
313 |
|
|
}
|
314 |
|
|
|
315 |
bertho |
1.7 |
s1 = v1 = xstrdup(c1);
|
316 |
|
|
s2 = v2 = xstrdup(c2);
|
317 |
bertho |
1.5 |
while(1)
|
318 |
|
|
{
|
319 |
|
|
char *vc1 = strchr(s1, '.');
|
320 |
|
|
char *vc2 = strchr(s2, '.');
|
321 |
|
|
if(vc1 && vc2)
|
322 |
|
|
*vc1 = *vc2 = '\0';
|
323 |
|
|
if(*s1 && *s2)
|
324 |
|
|
{
|
325 |
|
|
d1 = atoi(s1);
|
326 |
|
|
d2 = atoi(s2);
|
327 |
|
|
if(d1 != d2)
|
328 |
|
|
{
|
329 |
|
|
retval = d1 - d2;
|
330 |
|
|
break;
|
331 |
|
|
}
|
332 |
|
|
}
|
333 |
|
|
if(!vc1 || !vc2)
|
334 |
|
|
break;
|
335 |
|
|
s1 = vc1 + 1;
|
336 |
|
|
s2 = vc2 + 1;
|
337 |
|
|
}
|
338 |
|
|
xfree(v1);
|
339 |
|
|
xfree(v2);
|
340 |
|
|
return retval;
|
341 |
|
|
}
|
342 |
|
|
|
343 |
bertho |
1.7 |
/*
|
344 |
|
|
**************************************************************************
|
345 |
|
|
* Reorganise the rcsfile for the branches
|
346 |
|
|
*
|
347 |
|
|
* Basically, we have a list of deltas (i.e. administrative info on
|
348 |
|
|
* revisions) and a list of delta text (the actual logs and diffs).
|
349 |
|
|
* The deltas are linked through the 'next' and the 'branches' fields
|
350 |
|
|
* which describe the tree-structure of revisions.
|
351 |
|
|
* The reorganisation means that we put each delta and corresponding
|
352 |
|
|
* delta text in a revision structure and assign it to a specific
|
353 |
|
|
* branch. This is required because we want to be able to calculate
|
354 |
|
|
* the bounding boxes of each branch. The revisions expand vertically
|
355 |
|
|
* and the branches expand horizontally.
|
356 |
|
|
* The reorganisation is performed in these steps:
|
357 |
bertho |
1.17 |
* 1 - sort deltas and delta text on revision number for quick lookup
|
358 |
bertho |
1.7 |
* 2 - start at the denoted head revision:
|
359 |
|
|
* * create a branch structure and add this revision
|
360 |
|
|
* * for each 'branches' in the delta do:
|
361 |
|
|
* - walk all 'branches' of the delta and recursively goto 2
|
362 |
|
|
* with the denoted branch delta as new head
|
363 |
|
|
* - backlink the newly create sub-branch to the head revision
|
364 |
|
|
* so that we can draw them recursively
|
365 |
|
|
* * set head to the 'next' field and goto 2 until no next is
|
366 |
|
|
* available
|
367 |
|
|
* 3 - update the administration
|
368 |
|
|
**************************************************************************
|
369 |
|
|
*/
|
370 |
bertho |
1.19 |
static int sort_delta(const void *d1, const void *d2)
|
371 |
bertho |
1.7 |
{
|
372 |
|
|
return compare_rev(0, (*(delta_t **)d1)->rev, (*(delta_t **)d2)->rev);
|
373 |
|
|
}
|
374 |
|
|
|
375 |
bertho |
1.19 |
static int search_delta(const void *r, const void *d)
|
376 |
bertho |
1.1 |
{
|
377 |
bertho |
1.7 |
return compare_rev(0, (rev_t *)r, (*(delta_t **)d)->rev);
|
378 |
bertho |
1.1 |
}
|
379 |
|
|
|
380 |
bertho |
1.19 |
static delta_t *find_delta(delta_t **dl, int n, rev_t *r)
|
381 |
bertho |
1.1 |
{
|
382 |
bertho |
1.7 |
delta_t **d;
|
383 |
bertho |
1.23 |
if(!n)
|
384 |
|
|
return NULL;
|
385 |
bertho |
1.7 |
d = bsearch(r, dl, n, sizeof(*dl), search_delta);
|
386 |
|
|
if(!d)
|
387 |
|
|
return NULL;
|
388 |
|
|
return *d;
|
389 |
bertho |
1.1 |
}
|
390 |
|
|
|
391 |
bertho |
1.19 |
static int sort_dtext(const void *d1, const void *d2)
|
392 |
bertho |
1.1 |
{
|
393 |
bertho |
1.7 |
return compare_rev(0, (*(dtext_t **)d1)->rev, (*(dtext_t **)d2)->rev);
|
394 |
bertho |
1.1 |
}
|
395 |
|
|
|
396 |
bertho |
1.19 |
static int search_dtext(const void *r, const void *d)
|
397 |
bertho |
1.1 |
{
|
398 |
bertho |
1.7 |
return compare_rev(0, (rev_t *)r, (*(dtext_t **)d)->rev);
|
399 |
bertho |
1.1 |
}
|
400 |
|
|
|
401 |
bertho |
1.19 |
static dtext_t *find_dtext(dtext_t **dl, int n, rev_t *r)
|
402 |
bertho |
1.1 |
{
|
403 |
bertho |
1.7 |
dtext_t **d;
|
404 |
bertho |
1.23 |
if(!n)
|
405 |
|
|
return NULL;
|
406 |
bertho |
1.7 |
d = bsearch(r, dl, n, sizeof(*dl), search_dtext);
|
407 |
|
|
if(!d)
|
408 |
bertho |
1.1 |
return NULL;
|
409 |
bertho |
1.7 |
return *d;
|
410 |
|
|
}
|
411 |
|
|
|
412 |
bertho |
1.19 |
static rev_t *dup_rev(const rev_t *r)
|
413 |
bertho |
1.7 |
{
|
414 |
|
|
rev_t *t = xmalloc(sizeof(*t));
|
415 |
|
|
t->rev = xstrdup(r->rev);
|
416 |
|
|
t->branch = xstrdup(r->branch);
|
417 |
|
|
t->isbranch = r->isbranch;
|
418 |
|
|
return t;
|
419 |
|
|
}
|
420 |
|
|
|
421 |
bertho |
1.19 |
static branch_t *new_branch(delta_t *d, dtext_t *t)
|
422 |
bertho |
1.7 |
{
|
423 |
|
|
branch_t *b = xmalloc(sizeof(*b));
|
424 |
|
|
revision_t *r = xmalloc(sizeof(*r));
|
425 |
|
|
r->delta = d;
|
426 |
|
|
r->dtext = t;
|
427 |
|
|
r->rev = d->rev;
|
428 |
|
|
r->branch = b;
|
429 |
|
|
b->branch = dup_rev(d->rev);
|
430 |
|
|
b->branch->isbranch = 1;
|
431 |
|
|
b->nrevs = 1;
|
432 |
|
|
b->revs = xmalloc(sizeof(b->revs[0]));
|
433 |
|
|
b->revs[0] = r;
|
434 |
|
|
return b;
|
435 |
|
|
}
|
436 |
|
|
|
437 |
bertho |
1.19 |
static revision_t *add_to_branch(branch_t *b, delta_t *d, dtext_t *t)
|
438 |
bertho |
1.7 |
{
|
439 |
|
|
revision_t *r = xmalloc(sizeof(*r));
|
440 |
|
|
r->delta = d;
|
441 |
|
|
r->dtext = t;
|
442 |
|
|
r->rev = d->rev;
|
443 |
|
|
r->branch = b;
|
444 |
|
|
b->revs = xrealloc(b->revs, (b->nrevs+1) * sizeof(b->revs[0]));
|
445 |
|
|
b->revs[b->nrevs] = r;
|
446 |
|
|
b->nrevs++;
|
447 |
|
|
return r;
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
void build_branch(branch_t ***bl, int *nbl, delta_t **sdl, int nsdl, dtext_t **sdt, int nsdt, delta_t *head)
|
451 |
|
|
{
|
452 |
|
|
branch_t *b;
|
453 |
|
|
dtext_t *text;
|
454 |
|
|
revision_t *currev;
|
455 |
|
|
|
456 |
|
|
assert(head != NULL);
|
457 |
|
|
|
458 |
|
|
if(head->flag)
|
459 |
|
|
{
|
460 |
|
|
fprintf(stderr, "Circular reference on '%s' in branchpoint\n", head->rev->rev);
|
461 |
|
|
return;
|
462 |
|
|
}
|
463 |
|
|
head->flag++;
|
464 |
|
|
text = find_dtext(sdt, nsdt, head->rev);
|
465 |
|
|
|
466 |
|
|
/* Create a new branch for this head */
|
467 |
|
|
b = new_branch(head, text);
|
468 |
|
|
*bl = xrealloc(*bl, (*nbl+1)*sizeof((*bl)[0]));
|
469 |
|
|
(*bl)[*nbl] = b;
|
470 |
|
|
(*nbl)++;
|
471 |
|
|
currev = b->revs[0];
|
472 |
|
|
while(1)
|
473 |
|
|
{
|
474 |
|
|
/* Process all sub-branches */
|
475 |
|
|
if(head->branches)
|
476 |
|
|
{
|
477 |
|
|
int i;
|
478 |
|
|
for(i = 0; i < head->branches->nrevs; i++)
|
479 |
|
|
{
|
480 |
|
|
delta_t *d = find_delta(sdl, nsdl, head->branches->revs[i]);
|
481 |
|
|
int btag = *nbl;
|
482 |
|
|
if(!d)
|
483 |
|
|
continue;
|
484 |
|
|
build_branch(bl, nbl, sdl, nsdl, sdt, nsdt, d);
|
485 |
|
|
|
486 |
|
|
/* Set the new branch's origin */
|
487 |
|
|
(*bl)[btag]->branchpoint = currev;
|
488 |
|
|
|
489 |
|
|
/* Add branch to this revision */
|
490 |
|
|
currev->branches = xrealloc(currev->branches, (currev->nbranches+1)*sizeof(currev->branches[0]));
|
491 |
|
|
currev->branches[currev->nbranches] = (*bl)[btag];
|
492 |
|
|
currev->nbranches++;
|
493 |
|
|
}
|
494 |
|
|
}
|
495 |
|
|
|
496 |
|
|
/* Walk through the next list */
|
497 |
|
|
if(!head->next)
|
498 |
|
|
return;
|
499 |
bertho |
1.9 |
|
500 |
bertho |
1.7 |
head = find_delta(sdl, nsdl, head->next);
|
501 |
|
|
if(!head)
|
502 |
|
|
{
|
503 |
|
|
fprintf(stderr, "Next revision (%s) not found in deltalist\n", head->next->rev);
|
504 |
|
|
return;
|
505 |
|
|
}
|
506 |
|
|
if(head->flag)
|
507 |
|
|
{
|
508 |
|
|
fprintf(stderr, "Circular reference on '%s'\n", head->rev->rev);
|
509 |
|
|
return;
|
510 |
|
|
}
|
511 |
|
|
head->flag++;
|
512 |
|
|
text = find_dtext(sdt, nsdt, head->rev);
|
513 |
|
|
currev = add_to_branch(b, head, text);
|
514 |
|
|
}
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
int reorganise_branches(rcsfile_t *rcs)
|
518 |
|
|
{
|
519 |
|
|
delta_t **sdelta;
|
520 |
|
|
int nsdelta;
|
521 |
|
|
dtext_t **sdtext;
|
522 |
|
|
int nsdtext;
|
523 |
|
|
delta_t *head;
|
524 |
|
|
branch_t **bl;
|
525 |
|
|
int nbl;
|
526 |
|
|
int i;
|
527 |
|
|
|
528 |
|
|
assert(rcs->deltas != NULL);
|
529 |
|
|
assert(rcs->head != NULL);
|
530 |
|
|
|
531 |
|
|
/* Make a new list for quick lookup */
|
532 |
|
|
nsdelta = rcs->deltas->ndeltas;
|
533 |
|
|
sdelta = xmalloc(nsdelta * sizeof(sdelta[0]));
|
534 |
|
|
memcpy(sdelta, rcs->deltas->deltas, nsdelta * sizeof(sdelta[0]));
|
535 |
|
|
qsort(sdelta, nsdelta, sizeof(sdelta[0]), sort_delta);
|
536 |
|
|
|
537 |
|
|
/* Do the same for the delta text */
|
538 |
bertho |
1.22 |
if(rcs->dtexts)
|
539 |
|
|
{
|
540 |
|
|
nsdtext = rcs->dtexts->ndtexts;
|
541 |
|
|
sdtext = xmalloc(nsdtext * sizeof(sdtext[0]));
|
542 |
|
|
memcpy(sdtext, rcs->dtexts->dtexts, nsdtext * sizeof(sdtext[0]));
|
543 |
|
|
qsort(sdtext, nsdtext, sizeof(sdtext[0]), sort_dtext);
|
544 |
|
|
}
|
545 |
|
|
else
|
546 |
|
|
{
|
547 |
|
|
nsdtext = 0;
|
548 |
|
|
sdtext = NULL;
|
549 |
|
|
}
|
550 |
bertho |
1.7 |
|
551 |
|
|
/* Start from the head of the trunk */
|
552 |
|
|
head = find_delta(sdelta, nsdelta, rcs->head);
|
553 |
|
|
if(!head)
|
554 |
|
|
{
|
555 |
|
|
fprintf(stderr, "Head revision (%s) not found in deltalist\n", rcs->head->rev);
|
556 |
|
|
return 0;
|
557 |
|
|
}
|
558 |
|
|
bl = NULL;
|
559 |
|
|
nbl = 0;
|
560 |
|
|
build_branch(&bl, &nbl, sdelta, nsdelta, sdtext, nsdtext, head);
|
561 |
|
|
|
562 |
|
|
/* Reverse the head branch */
|
563 |
|
|
for(i = 0; i < bl[0]->nrevs/2; i++)
|
564 |
|
|
{
|
565 |
|
|
revision_t *r;
|
566 |
|
|
r = bl[0]->revs[i];
|
567 |
|
|
bl[0]->revs[i] = bl[0]->revs[bl[0]->nrevs-i-1];
|
568 |
|
|
bl[0]->revs[bl[0]->nrevs-i-1] = r;
|
569 |
|
|
}
|
570 |
|
|
|
571 |
|
|
/* Update the branch-number of the head because it was reversed */
|
572 |
|
|
xfree(bl[0]->branch->branch);
|
573 |
|
|
bl[0]->branch->branch = xstrdup(bl[0]->revs[0]->rev->branch);
|
574 |
|
|
|
575 |
|
|
/* Keep the admin */
|
576 |
|
|
rcs->branches = bl;
|
577 |
|
|
rcs->nbranches = nbl;
|
578 |
|
|
rcs->sdelta = sdelta;
|
579 |
|
|
rcs->nsdelta = nsdelta;
|
580 |
|
|
rcs->sdtext = sdtext;
|
581 |
|
|
rcs->nsdtext = nsdtext;
|
582 |
|
|
rcs->active = bl[0];
|
583 |
|
|
return 1;
|
584 |
|
|
}
|
585 |
|
|
|
586 |
|
|
/*
|
587 |
|
|
**************************************************************************
|
588 |
|
|
* Assign the symbolic tags to the revisions and branches
|
589 |
|
|
*
|
590 |
|
|
* The tags point to revision numbers somewhere in the tree structure
|
591 |
|
|
* of branches and revisions. First we make a sorted list of all
|
592 |
|
|
* revisions and then we assign each tag to the proper revision.
|
593 |
|
|
**************************************************************************
|
594 |
|
|
*/
|
595 |
bertho |
1.19 |
static int sort_revision(const void *r1, const void *r2)
|
596 |
bertho |
1.7 |
{
|
597 |
|
|
return compare_rev(0, (*(revision_t **)r1)->delta->rev, (*(revision_t **)r2)->delta->rev);
|
598 |
|
|
}
|
599 |
|
|
|
600 |
bertho |
1.19 |
static int search_revision(const void *t, const void *r)
|
601 |
bertho |
1.7 |
{
|
602 |
|
|
return compare_rev(0, (rev_t *)t, (*(revision_t **)r)->delta->rev);
|
603 |
|
|
}
|
604 |
|
|
|
605 |
bertho |
1.19 |
static int sort_branch(const void *b1, const void *b2)
|
606 |
bertho |
1.7 |
{
|
607 |
|
|
return compare_rev(1, (*(branch_t **)b1)->branch, (*(branch_t **)b2)->branch);
|
608 |
bertho |
1.1 |
}
|
609 |
|
|
|
610 |
bertho |
1.19 |
static int search_branch(const void *t, const void *b)
|
611 |
bertho |
1.1 |
{
|
612 |
bertho |
1.7 |
return compare_rev(1, (rev_t *)t, (*(branch_t **)b)->branch);
|
613 |
bertho |
1.1 |
}
|
614 |
|
|
|
615 |
bertho |
1.19 |
static char *previous_rev(const char *c)
|
616 |
bertho |
1.1 |
{
|
617 |
bertho |
1.7 |
int dots = count_dots(c);
|
618 |
|
|
char *cptr;
|
619 |
|
|
char *r;
|
620 |
|
|
if(!dots)
|
621 |
bertho |
1.9 |
{
|
622 |
|
|
fprintf(stderr, "FIXME: previous_rev(\"%s\"): Cannot determine parent branch revision\n", c);
|
623 |
bertho |
1.7 |
return xstrdup("1.0"); /* FIXME: don't know what the parent is */
|
624 |
bertho |
1.9 |
}
|
625 |
bertho |
1.7 |
if(dots & 1)
|
626 |
|
|
{
|
627 |
|
|
/* Is is a revision we want the parent of */
|
628 |
|
|
r = xstrdup(c);
|
629 |
|
|
cptr = strrchr(r, '.');
|
630 |
|
|
assert(cptr != NULL);
|
631 |
|
|
if(dots == 1)
|
632 |
|
|
{
|
633 |
bertho |
1.9 |
fprintf(stderr, "FIXME: previous_rev(\"%s\"): Going beyond top-level?\n", c);
|
634 |
bertho |
1.7 |
/* FIXME: What is the parent of 1.1? */
|
635 |
|
|
cptr[1] = '\0';
|
636 |
|
|
strcat(r, "0");
|
637 |
|
|
return r;
|
638 |
|
|
}
|
639 |
|
|
/* Here we have a "x.x[.x.x]+" case */
|
640 |
|
|
*cptr = '\0';
|
641 |
|
|
cptr = strrchr(r, '.');
|
642 |
|
|
assert(cptr != NULL);
|
643 |
|
|
*cptr = '\0';
|
644 |
|
|
return r;
|
645 |
|
|
}
|
646 |
|
|
/* It is a branch we want the parent of */
|
647 |
|
|
r = xstrdup(c);
|
648 |
|
|
cptr = strrchr(r, '.');
|
649 |
|
|
assert(cptr != NULL);
|
650 |
|
|
*cptr = '\0';
|
651 |
|
|
return r;
|
652 |
bertho |
1.1 |
}
|
653 |
|
|
|
654 |
bertho |
1.30 |
static char *build_regex(size_t n, regmatch_t *m, const char *ms)
|
655 |
|
|
{
|
656 |
|
|
char *cptr;
|
657 |
|
|
int i;
|
658 |
|
|
|
659 |
|
|
if(!conf.merge_to || !conf.merge_to[0])
|
660 |
|
|
return NULL;
|
661 |
|
|
|
662 |
|
|
zap_string();
|
663 |
|
|
for(cptr = conf.merge_to; *cptr; cptr++)
|
664 |
|
|
{
|
665 |
|
|
if(*cptr == '%')
|
666 |
|
|
{
|
667 |
|
|
if(cptr[1] >= '1' && cptr[1] <= '9')
|
668 |
|
|
{
|
669 |
|
|
int idx = cptr[1] - '0';
|
670 |
|
|
regmatch_t *p = &m[idx];
|
671 |
|
|
if(idx < n && !(p->rm_so == -1 || p->rm_so >= p->rm_eo))
|
672 |
|
|
{
|
673 |
|
|
for(i = p->rm_so; i < p->rm_eo; i++)
|
674 |
|
|
{
|
675 |
|
|
if(strchr("^$.*+\\[{()", ms[i]))
|
676 |
|
|
add_string_ch('\\');
|
677 |
|
|
add_string_ch(ms[i]);
|
678 |
|
|
}
|
679 |
|
|
}
|
680 |
|
|
cptr++;
|
681 |
|
|
}
|
682 |
|
|
else
|
683 |
|
|
add_string_ch('%');
|
684 |
|
|
}
|
685 |
|
|
else
|
686 |
|
|
add_string_ch(*cptr);
|
687 |
|
|
}
|
688 |
|
|
return dup_string();
|
689 |
|
|
}
|
690 |
|
|
|
691 |
bertho |
1.31 |
static void find_merges(rcsfile_t *rcs)
|
692 |
bertho |
1.1 |
{
|
693 |
|
|
int i;
|
694 |
bertho |
1.30 |
int err;
|
695 |
bertho |
1.31 |
int rcflags = REG_EXTENDED | (conf.merge_nocase ? REG_ICASE : 0);
|
696 |
bertho |
1.30 |
regex_t *refrom = NULL;
|
697 |
|
|
regex_t *reto = NULL;
|
698 |
|
|
regmatch_t *matchfrom = NULL;
|
699 |
|
|
|
700 |
bertho |
1.31 |
if(!conf.merge_from || !conf.merge_from[0] || !conf.merge_to || !conf.merge_to[0])
|
701 |
|
|
return;
|
702 |
|
|
|
703 |
|
|
refrom = xmalloc(sizeof(*refrom));
|
704 |
|
|
reto = xmalloc(sizeof(*reto));
|
705 |
|
|
|
706 |
|
|
/* Compile the 'from' regex match for merge identification */
|
707 |
|
|
err = regcomp(refrom, conf.merge_from, rcflags);
|
708 |
|
|
if(err)
|
709 |
bertho |
1.30 |
{
|
710 |
bertho |
1.31 |
if(!quiet)
|
711 |
|
|
{
|
712 |
|
|
char *msg;
|
713 |
|
|
i = regerror(err, refrom, NULL, 0);
|
714 |
|
|
msg = xmalloc(i+1);
|
715 |
|
|
regerror(err, refrom, msg, i+1);
|
716 |
|
|
fprintf(stderr, "%s\n", msg);
|
717 |
|
|
xfree(msg);
|
718 |
|
|
}
|
719 |
|
|
xfree(refrom);
|
720 |
|
|
xfree(reto);
|
721 |
|
|
return;
|
722 |
|
|
}
|
723 |
|
|
else
|
724 |
|
|
matchfrom = xmalloc((refrom->re_nsub+1) * sizeof(*matchfrom));
|
725 |
bertho |
1.30 |
|
726 |
bertho |
1.31 |
for(i = 0; i < rcs->tags->ntags; i++)
|
727 |
|
|
{
|
728 |
|
|
tag_t *t = rcs->tags->tags[i];
|
729 |
|
|
|
730 |
|
|
/* Must be revision tags and not detached */
|
731 |
|
|
if(t->rev->isbranch || !t->logrev)
|
732 |
|
|
continue;
|
733 |
|
|
|
734 |
|
|
/* Try to find merge tag matches */
|
735 |
|
|
if(!regexec(refrom, t->tag, refrom->re_nsub+1, matchfrom, 0))
|
736 |
|
|
{
|
737 |
|
|
int n;
|
738 |
|
|
char *to;
|
739 |
|
|
|
740 |
|
|
to = build_regex(refrom->re_nsub+1, matchfrom, t->tag);
|
741 |
|
|
if(to)
|
742 |
|
|
{
|
743 |
|
|
err = regcomp(reto, to, rcflags);
|
744 |
|
|
if(err && !quiet)
|
745 |
|
|
{
|
746 |
|
|
char *msg;
|
747 |
|
|
i = regerror(err, reto, NULL, 0);
|
748 |
|
|
msg = xmalloc(i+1);
|
749 |
|
|
regerror(err, reto, msg, i+1);
|
750 |
|
|
fprintf(stderr, "%s\n", msg);
|
751 |
|
|
}
|
752 |
|
|
else if(!err)
|
753 |
|
|
{
|
754 |
|
|
for(n = 0; n < rcs->tags->ntags; n++)
|
755 |
|
|
{
|
756 |
|
|
tag_t *nt = rcs->tags->tags[n];
|
757 |
|
|
/* From and To never should match the same tag or belong to a branch */
|
758 |
|
|
if(n == i || nt->rev->isbranch || !nt->logrev)
|
759 |
|
|
continue;
|
760 |
|
|
|
761 |
bertho |
1.36 |
if(!regexec(reto, nt->tag, 0, NULL, 0))
|
762 |
bertho |
1.31 |
{
|
763 |
|
|
/* Tag matches */
|
764 |
|
|
rcs->merges = xrealloc(rcs->merges,
|
765 |
|
|
sizeof(rcs->merges[0]) * (rcs->nmerges+1));
|
766 |
|
|
rcs->merges[rcs->nmerges].to = nt;
|
767 |
|
|
rcs->merges[rcs->nmerges].from = t;
|
768 |
|
|
rcs->nmerges++;
|
769 |
bertho |
1.40 |
/* Merges cannot be ignored tags */
|
770 |
|
|
nt->ignore = 0;
|
771 |
|
|
t->ignore = 0;
|
772 |
bertho |
1.31 |
/* We cannot (should not) match multiple times */
|
773 |
|
|
break;
|
774 |
|
|
}
|
775 |
|
|
}
|
776 |
|
|
regfree(reto);
|
777 |
|
|
}
|
778 |
|
|
xfree(to);
|
779 |
|
|
}
|
780 |
bertho |
1.30 |
}
|
781 |
|
|
}
|
782 |
bertho |
1.31 |
if(matchfrom) xfree(matchfrom);
|
783 |
|
|
if(refrom) { regfree(refrom); xfree(refrom); }
|
784 |
|
|
if(reto) xfree(reto);
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
static void assign_tags(rcsfile_t *rcs)
|
788 |
|
|
{
|
789 |
|
|
int i;
|
790 |
|
|
int nr;
|
791 |
bertho |
1.40 |
regex_t *regextag = NULL;
|
792 |
|
|
|
793 |
|
|
if(conf.tag_ignore && conf.tag_ignore[0])
|
794 |
|
|
{
|
795 |
|
|
int err;
|
796 |
|
|
regextag = xmalloc(sizeof(*regextag));
|
797 |
|
|
err = regcomp(regextag, conf.tag_ignore, REG_EXTENDED | REG_NOSUB | (conf.tag_nocase ? REG_ICASE : 0));
|
798 |
|
|
if(err)
|
799 |
|
|
{
|
800 |
|
|
if(!quiet)
|
801 |
|
|
{
|
802 |
|
|
char *msg;
|
803 |
|
|
i = regerror(err, regextag, NULL, 0);
|
804 |
|
|
msg = xmalloc(i+1);
|
805 |
|
|
regerror(err, regextag, msg, i+1);
|
806 |
|
|
fprintf(stderr, "%s\n", msg);
|
807 |
|
|
xfree(msg);
|
808 |
|
|
}
|
809 |
|
|
xfree(regextag);
|
810 |
|
|
regextag = NULL;
|
811 |
|
|
}
|
812 |
|
|
}
|
813 |
bertho |
1.7 |
|
814 |
|
|
for(i = nr = 0; i < rcs->nbranches; i++)
|
815 |
|
|
nr += rcs->branches[i]->nrevs;
|
816 |
|
|
|
817 |
|
|
rcs->srev = xmalloc(nr * sizeof(rcs->srev[0]));
|
818 |
|
|
rcs->nsrev = nr;
|
819 |
|
|
for(i = nr = 0; i < rcs->nbranches; i++)
|
820 |
|
|
{
|
821 |
|
|
memcpy(&rcs->srev[nr], rcs->branches[i]->revs, rcs->branches[i]->nrevs * sizeof(rcs->branches[i]->revs[0]));
|
822 |
|
|
nr += rcs->branches[i]->nrevs;
|
823 |
|
|
}
|
824 |
|
|
|
825 |
|
|
qsort(rcs->srev, rcs->nsrev, sizeof(rcs->srev[0]), sort_revision);
|
826 |
|
|
qsort(rcs->branches, rcs->nbranches, sizeof(rcs->branches[0]), sort_branch);
|
827 |
|
|
|
828 |
|
|
if(!rcs->branch)
|
829 |
|
|
{
|
830 |
|
|
/* The main trunk is the active trunk */
|
831 |
|
|
rcs->tags->tags = xrealloc(rcs->tags->tags, (rcs->tags->ntags+1)*sizeof(rcs->tags->tags[0]));
|
832 |
|
|
rcs->tags->tags[rcs->tags->ntags] = xmalloc(sizeof(tag_t));
|
833 |
|
|
rcs->tags->tags[rcs->tags->ntags]->tag = xstrdup("MAIN");
|
834 |
|
|
rcs->tags->tags[rcs->tags->ntags]->rev = xmalloc(sizeof(rev_t));
|
835 |
|
|
rcs->tags->tags[rcs->tags->ntags]->rev->rev = xstrdup(rcs->active->branch->rev);
|
836 |
|
|
rcs->tags->tags[rcs->tags->ntags]->rev->branch = xstrdup(rcs->active->branch->branch);
|
837 |
|
|
rcs->tags->tags[rcs->tags->ntags]->rev->isbranch = 1;
|
838 |
|
|
rcs->tags->ntags++;
|
839 |
|
|
}
|
840 |
|
|
|
841 |
|
|
/* We should have at least two tags (HEAD and MAIN) */
|
842 |
|
|
assert(rcs->tags != 0);
|
843 |
|
|
|
844 |
|
|
for(i = 0; i < rcs->tags->ntags; i++)
|
845 |
|
|
{
|
846 |
|
|
tag_t *t = rcs->tags->tags[i];
|
847 |
|
|
if(t->rev->isbranch)
|
848 |
|
|
{
|
849 |
|
|
branch_t **b;
|
850 |
|
|
add_btag:
|
851 |
|
|
b = bsearch(t->rev, rcs->branches, rcs->nbranches, sizeof(rcs->branches[0]), search_branch);
|
852 |
|
|
if(!b)
|
853 |
|
|
{
|
854 |
|
|
rev_t rev;
|
855 |
|
|
revision_t **r;
|
856 |
|
|
/* This happens for the magic branch numbers if there are
|
857 |
bertho |
1.12 |
* no commits within the new branch yet. So, we add the
|
858 |
|
|
* branch and try to continue.
|
859 |
bertho |
1.7 |
*/
|
860 |
|
|
rev.rev = previous_rev(t->rev->branch);
|
861 |
|
|
rev.branch = NULL;
|
862 |
|
|
rev.isbranch = 0;
|
863 |
|
|
r = bsearch(&rev, rcs->srev, rcs->nsrev, sizeof(rcs->srev[0]), search_revision);
|
864 |
|
|
xfree(rev.rev);
|
865 |
|
|
if(!r)
|
866 |
|
|
{
|
867 |
bertho |
1.12 |
if(!quiet)
|
868 |
|
|
fprintf(stderr, "No branch found for tag '%s:%s'\n", t->tag, t->rev->branch);
|
869 |
bertho |
1.7 |
}
|
870 |
|
|
else
|
871 |
|
|
{
|
872 |
|
|
rcs->branches = xrealloc(rcs->branches, (rcs->nbranches+1)*sizeof(rcs->branches[0]));
|
873 |
|
|
rcs->branches[rcs->nbranches] = xmalloc(sizeof(branch_t));
|
874 |
|
|
rcs->branches[rcs->nbranches]->branch = dup_rev(t->rev);
|
875 |
|
|
rcs->branches[rcs->nbranches]->branchpoint = *r;
|
876 |
|
|
(*r)->branches = xrealloc((*r)->branches, ((*r)->nbranches+1)*sizeof((*r)->branches[0]));
|
877 |
|
|
(*r)->branches[(*r)->nbranches] = rcs->branches[rcs->nbranches];
|
878 |
|
|
(*r)->nbranches++;
|
879 |
|
|
rcs->nbranches++;
|
880 |
|
|
/* Resort the branches */
|
881 |
|
|
qsort(rcs->branches, rcs->nbranches, sizeof(rcs->branches[0]), sort_branch);
|
882 |
|
|
goto add_btag;
|
883 |
|
|
}
|
884 |
|
|
}
|
885 |
|
|
else
|
886 |
|
|
{
|
887 |
|
|
branch_t *bb = *b;
|
888 |
|
|
bb->tags = xrealloc(bb->tags, (bb->ntags+1)*sizeof(bb->tags[0]));
|
889 |
|
|
bb->tags[bb->ntags] = t;
|
890 |
|
|
bb->ntags++;
|
891 |
|
|
}
|
892 |
|
|
}
|
893 |
|
|
else
|
894 |
|
|
{
|
895 |
|
|
revision_t **r = bsearch(t->rev, rcs->srev, rcs->nsrev, sizeof(rcs->srev[0]), search_revision);
|
896 |
|
|
if(!r)
|
897 |
bertho |
1.12 |
{
|
898 |
|
|
if(!quiet)
|
899 |
|
|
fprintf(stderr, "No revision found for tag '%s:%s'\n", t->tag, t->rev->rev);
|
900 |
|
|
}
|
901 |
bertho |
1.7 |
else
|
902 |
|
|
{
|
903 |
|
|
revision_t *rr = *r;
|
904 |
bertho |
1.30 |
t->logrev = rr;
|
905 |
bertho |
1.28 |
if(!conf.rev_maxtags || rr->ntags <= conf.rev_maxtags)
|
906 |
|
|
{
|
907 |
|
|
rr->tags = xrealloc(rr->tags, (rr->ntags+1)*sizeof(rr->tags[0]));
|
908 |
|
|
if(conf.rev_maxtags && rr->ntags == conf.rev_maxtags)
|
909 |
|
|
{
|
910 |
|
|
rr->tags[rr->ntags] = xmalloc(sizeof(tag_t));
|
911 |
|
|
rr->tags[rr->ntags]->tag = xstrdup("...");
|
912 |
|
|
rr->tags[rr->ntags]->rev = t->rev;
|
913 |
|
|
}
|
914 |
|
|
else
|
915 |
|
|
rr->tags[rr->ntags] = t;
|
916 |
|
|
rr->ntags++;
|
917 |
|
|
}
|
918 |
bertho |
1.7 |
}
|
919 |
bertho |
1.40 |
|
920 |
|
|
/* Mark the tag ignored if it matches the configuration */
|
921 |
|
|
if(regextag && !regexec(regextag, t->tag, 0, NULL, 0))
|
922 |
|
|
t->ignore++;
|
923 |
bertho |
1.7 |
}
|
924 |
|
|
}
|
925 |
|
|
|
926 |
|
|
/* We need to reset the first in the list of branches to the
|
927 |
|
|
* active branch to ensure the drawing of all
|
928 |
|
|
*/
|
929 |
|
|
if(rcs->active != rcs->branches[0])
|
930 |
bertho |
1.1 |
{
|
931 |
bertho |
1.7 |
branch_t **b = bsearch(rcs->active->branch, rcs->branches, rcs->nbranches, sizeof(rcs->branches[0]), search_branch);
|
932 |
|
|
branch_t *t;
|
933 |
|
|
assert(b != NULL);
|
934 |
|
|
t = *b;
|
935 |
|
|
*b = rcs->branches[0];
|
936 |
|
|
rcs->branches[0] = t;
|
937 |
bertho |
1.1 |
}
|
938 |
bertho |
1.40 |
|
939 |
|
|
if(regextag)
|
940 |
|
|
{
|
941 |
|
|
regfree(regextag);
|
942 |
|
|
xfree(regextag);
|
943 |
|
|
}
|
944 |
bertho |
1.1 |
}
|
945 |
|
|
|
946 |
|
|
/*
|
947 |
|
|
**************************************************************************
|
948 |
bertho |
1.8 |
* String expansion
|
949 |
|
|
**************************************************************************
|
950 |
|
|
*/
|
951 |
|
|
static char *_string;
|
952 |
|
|
static int _nstring;
|
953 |
|
|
static int _nastring;
|
954 |
|
|
|
955 |
bertho |
1.30 |
static void zap_string(void)
|
956 |
|
|
{
|
957 |
|
|
_nstring = 0;
|
958 |
|
|
if(_string)
|
959 |
|
|
_string[0] = '\0';
|
960 |
|
|
}
|
961 |
|
|
|
962 |
|
|
static char *dup_string(void)
|
963 |
|
|
{
|
964 |
|
|
if(_string)
|
965 |
|
|
return xstrdup(_string);
|
966 |
|
|
else
|
967 |
|
|
return "";
|
968 |
|
|
}
|
969 |
|
|
|
970 |
bertho |
1.19 |
static void add_string_str(const char *s)
|
971 |
bertho |
1.8 |
{
|
972 |
|
|
int l = strlen(s) + 1;
|
973 |
|
|
if(_nstring + l > _nastring)
|
974 |
|
|
{
|
975 |
bertho |
1.24 |
_nastring += MAX(128, l);
|
976 |
bertho |
1.8 |
_string = xrealloc(_string, _nastring * sizeof(_string[0]));
|
977 |
|
|
}
|
978 |
|
|
memcpy(_string+_nstring, s, l);
|
979 |
|
|
_nstring += l-1;
|
980 |
|
|
}
|
981 |
|
|
|
982 |
bertho |
1.19 |
static void add_string_ch(int ch)
|
983 |
bertho |
1.8 |
{
|
984 |
|
|
char buf[2];
|
985 |
|
|
buf[0] = ch;
|
986 |
|
|
buf[1] = '\0';
|
987 |
|
|
add_string_str(buf);
|
988 |
|
|
}
|
989 |
|
|
|
990 |
bertho |
1.19 |
static void add_string_date(const char *d)
|
991 |
bertho |
1.9 |
{
|
992 |
|
|
struct tm tm, *tmp;
|
993 |
|
|
int n;
|
994 |
|
|
time_t t;
|
995 |
|
|
char *buf;
|
996 |
|
|
int nbuf;
|
997 |
|
|
|
998 |
|
|
memset(&tm, 0, sizeof(tm));
|
999 |
|
|
n = sscanf(d, "%d.%d.%d.%d.%d.%d",
|
1000 |
|
|
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
|
1001 |
|
|
&tm.tm_hour, &tm.tm_min, &tm.tm_sec);
|
1002 |
|
|
tm.tm_mon--;
|
1003 |
|
|
if(tm.tm_year > 1900)
|
1004 |
|
|
tm.tm_year -= 1900;
|
1005 |
bertho |
1.38 |
t = mktime(&tm) - timezone;
|
1006 |
bertho |
1.9 |
if(n != 6 || t == (time_t)(-1))
|
1007 |
|
|
{
|
1008 |
|
|
add_string_str("<invalid date>");
|
1009 |
|
|
return;
|
1010 |
|
|
}
|
1011 |
|
|
|
1012 |
|
|
tmp = localtime(&t);
|
1013 |
|
|
nbuf = strlen(conf.date_format) * 16; /* Should be enough to hold all types of expansions */
|
1014 |
|
|
buf = xmalloc(nbuf);
|
1015 |
|
|
strftime(buf, nbuf, conf.date_format, tmp);
|
1016 |
|
|
add_string_str(buf);
|
1017 |
|
|
xfree(buf);
|
1018 |
|
|
}
|
1019 |
|
|
|
1020 |
bertho |
1.22 |
static void add_string_str_html(const char *s, int maxlen)
|
1021 |
|
|
{
|
1022 |
|
|
int l = 0;
|
1023 |
|
|
char *str = xmalloc(6 * strlen(s) + 1); /* Should hold all char entity-expand */
|
1024 |
|
|
char *cptr = str;
|
1025 |
|
|
for(; *s; s++)
|
1026 |
|
|
{
|
1027 |
|
|
if(maxlen && l > abs(maxlen))
|
1028 |
|
|
{
|
1029 |
|
|
cptr += sprintf(cptr, "...");
|
1030 |
|
|
break;
|
1031 |
|
|
}
|
1032 |
|
|
if(*s < 0x20)
|
1033 |
|
|
{
|
1034 |
|
|
if(*s == '\n')
|
1035 |
|
|
{
|
1036 |
|
|
if(maxlen < 0)
|
1037 |
|
|
*cptr++ = ' ';
|
1038 |
|
|
else
|
1039 |
bertho |
1.37 |
cptr += sprintf(cptr, "<br%s>", conf.html_level == HTMLLEVEL_X ? " /" : "");
|
1040 |
bertho |
1.22 |
}
|
1041 |
|
|
}
|
1042 |
bertho |
1.30 |
else if(*s >= 0x7f || *s == '"')
|
1043 |
bertho |
1.22 |
cptr += sprintf(cptr, "&#%d;", (int)(unsigned char)*s);
|
1044 |
|
|
else if(*s == '<')
|
1045 |
|
|
cptr += sprintf(cptr, "<");
|
1046 |
|
|
else if(*s == '>')
|
1047 |
|
|
cptr += sprintf(cptr, ">");
|
1048 |
bertho |
1.37 |
else if(*s == '&')
|
1049 |
|
|
cptr += sprintf(cptr, "&");
|
1050 |
|
|
else if(*s == '"')
|
1051 |
|
|
cptr += sprintf(cptr, """);
|
1052 |
bertho |
1.22 |
else
|
1053 |
|
|
*cptr++ = *s;
|
1054 |
|
|
l++;
|
1055 |
|
|
}
|
1056 |
|
|
*cptr = '\0';
|
1057 |
|
|
add_string_str(str);
|
1058 |
|
|
xfree(str);
|
1059 |
|
|
}
|
1060 |
|
|
|
1061 |
|
|
static void add_string_str_len(const char *s, int maxlen)
|
1062 |
|
|
{
|
1063 |
|
|
int l = strlen(s);
|
1064 |
|
|
char *str = xmalloc(l + 1 + 3);
|
1065 |
|
|
strcpy(str, s);
|
1066 |
|
|
if(maxlen < l)
|
1067 |
|
|
sprintf(&str[maxlen], "...");
|
1068 |
|
|
add_string_str(str);
|
1069 |
|
|
xfree(str);
|
1070 |
|
|
}
|
1071 |
|
|
|
1072 |
bertho |
1.9 |
char *expand_string(const char *s, rcsfile_t *rcs, revision_t *r, rev_t *rev, rev_t *prev, tag_t *tag)
|
1073 |
bertho |
1.8 |
{
|
1074 |
|
|
char nb[32];
|
1075 |
|
|
char nr[32];
|
1076 |
|
|
char *base;
|
1077 |
bertho |
1.30 |
char *exp;
|
1078 |
bertho |
1.22 |
int l;
|
1079 |
|
|
char ch;
|
1080 |
bertho |
1.8 |
|
1081 |
|
|
if(!s)
|
1082 |
|
|
return xstrdup("");
|
1083 |
|
|
|
1084 |
bertho |
1.30 |
zap_string();
|
1085 |
bertho |
1.8 |
|
1086 |
|
|
sprintf(nb, "%d", rcs->nbranches);
|
1087 |
|
|
sprintf(nr, "%d", rcs->nsrev);
|
1088 |
|
|
for(; *s; s++)
|
1089 |
|
|
{
|
1090 |
|
|
if(*s == '%')
|
1091 |
|
|
{
|
1092 |
|
|
switch(*++s)
|
1093 |
|
|
{
|
1094 |
bertho |
1.12 |
case 'c':
|
1095 |
|
|
case 'C':
|
1096 |
|
|
add_string_str(conf.cvsroot);
|
1097 |
|
|
if(*s == 'C' && conf.cvsroot[0] && conf.cvsroot[strlen(conf.cvsroot)-1] == '/')
|
1098 |
|
|
{
|
1099 |
|
|
/* Strip the trailing '/' */
|
1100 |
|
|
_nstring--;
|
1101 |
|
|
_string[_nstring] = '\0';
|
1102 |
|
|
}
|
1103 |
|
|
break;
|
1104 |
bertho |
1.8 |
case 'f':
|
1105 |
|
|
case 'F':
|
1106 |
|
|
base = strrchr(rcs->file, '/');
|
1107 |
|
|
if(!base)
|
1108 |
|
|
add_string_str(rcs->file);
|
1109 |
|
|
else
|
1110 |
|
|
add_string_str(base+1);
|
1111 |
|
|
if(*s == 'F' && _string[_nstring-1] == 'v' && _string[_nstring-2] == ',')
|
1112 |
|
|
{
|
1113 |
|
|
_nstring -= 2;
|
1114 |
|
|
_string[_nstring] = '\0';
|
1115 |
|
|
}
|
1116 |
|
|
break;
|
1117 |
|
|
case 'p':
|
1118 |
|
|
base = strrchr(rcs->file, '/');
|
1119 |
|
|
if(base)
|
1120 |
|
|
{
|
1121 |
|
|
char *c = xstrdup(rcs->file);
|
1122 |
|
|
base = strrchr(c, '/');
|
1123 |
|
|
assert(base != NULL);
|
1124 |
|
|
base[1] = '\0';
|
1125 |
|
|
add_string_str(c);
|
1126 |
|
|
xfree(c);
|
1127 |
|
|
}
|
1128 |
bertho |
1.9 |
/*
|
1129 |
|
|
* We should not add anything here because we can encounter
|
1130 |
|
|
* a completely empty path, in which case we do not want
|
1131 |
bertho |
1.17 |
* to add any slash. This prevents an inadvertent root redirect.
|
1132 |
bertho |
1.9 |
*
|
1133 |
|
|
* else
|
1134 |
|
|
* add_string_str("/");
|
1135 |
|
|
*/
|
1136 |
bertho |
1.8 |
break;
|
1137 |
bertho |
1.12 |
case 'm':
|
1138 |
|
|
case 'M':
|
1139 |
|
|
add_string_str(conf.cvsmodule);
|
1140 |
|
|
if(*s == 'M' && conf.cvsmodule[0] && conf.cvsmodule[strlen(conf.cvsmodule)-1] == '/')
|
1141 |
|
|
{
|
1142 |
|
|
/* Strip the trailing '/' */
|
1143 |
|
|
_nstring--;
|
1144 |
|
|
_string[_nstring] = '\0';
|
1145 |
|
|
}
|
1146 |
|
|
break;
|
1147 |
bertho |
1.8 |
case 'r': add_string_str(nr); break;
|
1148 |
|
|
case 'b': add_string_str(nb); break;
|
1149 |
|
|
case '%': add_string_ch('%'); break;
|
1150 |
|
|
case '0': if(conf.expand[0]) add_string_str(conf.expand[0]); break;
|
1151 |
|
|
case '1': if(conf.expand[1]) add_string_str(conf.expand[1]); break;
|
1152 |
|
|
case '2': if(conf.expand[2]) add_string_str(conf.expand[2]); break;
|
1153 |
|
|
case '3': if(conf.expand[3]) add_string_str(conf.expand[3]); break;
|
1154 |
|
|
case '4': if(conf.expand[4]) add_string_str(conf.expand[4]); break;
|
1155 |
|
|
case '5': if(conf.expand[5]) add_string_str(conf.expand[5]); break;
|
1156 |
|
|
case '6': if(conf.expand[6]) add_string_str(conf.expand[6]); break;
|
1157 |
|
|
case '7': if(conf.expand[7]) add_string_str(conf.expand[7]); break;
|
1158 |
|
|
case '8': if(conf.expand[8]) add_string_str(conf.expand[8]); break;
|
1159 |
|
|
case '9': if(conf.expand[9]) add_string_str(conf.expand[9]); break;
|
1160 |
|
|
case 'R': if(rev && rev->rev) add_string_str(rev->rev); break;
|
1161 |
bertho |
1.9 |
case 'P': if(prev && prev->rev) add_string_str(prev->rev); break;
|
1162 |
bertho |
1.8 |
case 'B': if(rev && rev->branch) add_string_str(rev->branch); break;
|
1163 |
|
|
case 't': if(tag && tag->tag) add_string_str(tag->tag); break;
|
1164 |
bertho |
1.9 |
case 'd': if(r && r->delta && r->delta->date) add_string_date(r->delta->date); break;
|
1165 |
|
|
case 's': if(r && r->delta && r->delta->state) add_string_str(r->delta->state); break;
|
1166 |
|
|
case 'a': if(r && r->delta && r->delta->author) add_string_str(r->delta->author); break;
|
1167 |
bertho |
1.22 |
case 'L':
|
1168 |
|
|
case 'l':
|
1169 |
|
|
ch = *s;
|
1170 |
|
|
l = 0;
|
1171 |
|
|
if(s[1] == '[')
|
1172 |
|
|
{
|
1173 |
|
|
char *cptr = strchr(s, ']');
|
1174 |
|
|
char *eptr;
|
1175 |
|
|
if(cptr)
|
1176 |
|
|
{
|
1177 |
|
|
l = strtol(&s[2], &eptr, 10);
|
1178 |
|
|
if(eptr != cptr)
|
1179 |
|
|
l = 0;
|
1180 |
|
|
else
|
1181 |
|
|
s = cptr;
|
1182 |
|
|
}
|
1183 |
|
|
}
|
1184 |
|
|
if(!conf.parse_logs)
|
1185 |
|
|
add_string_str("N/A");
|
1186 |
|
|
else if(r && r->dtext && r->dtext->log)
|
1187 |
|
|
{
|
1188 |
|
|
if(ch == 'l')
|
1189 |
|
|
add_string_str_html(r->dtext->log, l);
|
1190 |
|
|
else
|
1191 |
|
|
add_string_str_len(r->dtext->log, abs(l));
|
1192 |
|
|
}
|
1193 |
|
|
break;
|
1194 |
bertho |
1.30 |
case '(':
|
1195 |
|
|
base = dup_string();
|
1196 |
|
|
exp = expand_string(s+1, rcs, r, rev, prev, tag);
|
1197 |
|
|
zap_string();
|
1198 |
|
|
add_string_str(base);
|
1199 |
|
|
add_string_str_html(exp, 0);
|
1200 |
|
|
xfree(base);
|
1201 |
|
|
xfree(exp);
|
1202 |
|
|
/* Find the %) in this recursion level */
|
1203 |
|
|
for(; *s; s++)
|
1204 |
|
|
{
|
1205 |
|
|
if(*s == '%' && s[1] == ')')
|
1206 |
bertho |
1.34 |
{
|
1207 |
|
|
s++;
|
1208 |
bertho |
1.30 |
break;
|
1209 |
bertho |
1.34 |
}
|
1210 |
bertho |
1.30 |
}
|
1211 |
|
|
if(!*s)
|
1212 |
|
|
{
|
1213 |
|
|
s--; /* To end outer loop */
|
1214 |
|
|
if(!quiet)
|
1215 |
|
|
fprintf(stderr, "string expand: Missing %%) in expansion\n");
|
1216 |
|
|
}
|
1217 |
|
|
break;
|
1218 |
|
|
case ')':
|
1219 |
|
|
return dup_string();
|
1220 |
bertho |
1.8 |
default:
|
1221 |
|
|
add_string_ch('%');
|
1222 |
|
|
add_string_ch(*s);
|
1223 |
|
|
break;
|
1224 |
|
|
}
|
1225 |
|
|
}
|
1226 |
|
|
else
|
1227 |
|
|
add_string_ch(*s);
|
1228 |
|
|
}
|
1229 |
bertho |
1.30 |
return dup_string();
|
1230 |
bertho |
1.8 |
}
|
1231 |
|
|
|
1232 |
|
|
/*
|
1233 |
|
|
**************************************************************************
|
1234 |
bertho |
1.1 |
* Drawing routines
|
1235 |
|
|
**************************************************************************
|
1236 |
|
|
*/
|
1237 |
bertho |
1.19 |
static int get_swidth(const char *s, font_t *f)
|
1238 |
bertho |
1.1 |
{
|
1239 |
bertho |
1.9 |
int n;
|
1240 |
|
|
int m;
|
1241 |
|
|
if(!s || !*s)
|
1242 |
bertho |
1.1 |
return 0;
|
1243 |
bertho |
1.19 |
|
1244 |
|
|
#if defined(HAVE_GDIMAGESTRINGFT) || defined(HAVE_GDIMAGESTRINGTTF)
|
1245 |
|
|
if(conf.use_ttf && f->ttfont)
|
1246 |
|
|
{
|
1247 |
|
|
int bb[8];
|
1248 |
|
|
char *e;
|
1249 |
|
|
#ifdef HAVE_GDIMAGESTRINGFT
|
1250 |
|
|
e = gdImageStringFT(NULL, bb, 0, f->ttfont, f->ttsize, 0.0, 0, 0, (char *)s);
|
1251 |
|
|
#else
|
1252 |
|
|
e = gdImageStringTTF(NULL, bb, 0, f->ttfont, f->ttsize, 0.0, 0, 0, (char *)s);
|
1253 |
|
|
#endif
|
1254 |
|
|
if(!e)
|
1255 |
|
|
return bb[2] - bb[6];
|
1256 |
|
|
}
|
1257 |
|
|
#endif
|
1258 |
bertho |
1.9 |
for(n = m = 0; *s; n++, s++)
|
1259 |
|
|
{
|
1260 |
|
|
if(*s == '\n')
|
1261 |
|
|
{
|
1262 |
|
|
if(n > m)
|
1263 |
|
|
m = n;
|
1264 |
|
|
n = 0;
|
1265 |
|
|
}
|
1266 |
|
|
}
|
1267 |
|
|
if(n > m)
|
1268 |
|
|
m = n;
|
1269 |
bertho |
1.22 |
return f->gdfont ? m * f->gdfont->w : m;
|
1270 |
bertho |
1.1 |
}
|
1271 |
|
|
|
1272 |
bertho |
1.19 |
static int get_sheight(const char *s, font_t *f)
|
1273 |
bertho |
1.1 |
{
|
1274 |
|
|
int nl;
|
1275 |
bertho |
1.9 |
if(!s || !*s)
|
1276 |
bertho |
1.1 |
return 0;
|
1277 |
bertho |
1.19 |
|
1278 |
|
|
#if defined(HAVE_GDIMAGESTRINGFT) || defined(HAVE_GDIMAGESTRINGTTF)
|
1279 |
|
|
if(conf.use_ttf && f->ttfont)
|
1280 |
|
|
{
|
1281 |
|
|
int bb[8];
|
1282 |
|
|
char *e;
|
1283 |
|
|
#ifdef HAVE_GDIMAGESTRINGFT
|
1284 |
|
|
e = gdImageStringFT(NULL, bb, 0, f->ttfont, f->ttsize, 0.0, 0, 0, (char *)s);
|
1285 |
|
|
#else
|
1286 |
|
|
e = gdImageStringTTF(NULL, bb, 0, f->ttfont, f->ttsize, 0.0, 0, 0, (char *)s);
|
1287 |
|
|
#endif
|
1288 |
|
|
if(!e)
|
1289 |
|
|
return bb[3] - bb[7] + 4;
|
1290 |
|
|
}
|
1291 |
|
|
#endif
|
1292 |
bertho |
1.1 |
for(nl = 1; *s; s++)
|
1293 |
|
|
{
|
1294 |
|
|
if(*s == '\n' && s[1])
|
1295 |
|
|
nl++;
|
1296 |
|
|
}
|
1297 |
bertho |
1.19 |
return nl * f->gdfont->h;
|
1298 |
bertho |
1.1 |
}
|
1299 |
|
|
|
1300 |
bertho |
1.19 |
static void draw_rbox(gdImagePtr im, int x1, int y1, int x2, int y2, int r, color_t *color, color_t *bgcolor)
|
1301 |
bertho |
1.1 |
{
|
1302 |
|
|
int r2 = 2*r;
|
1303 |
|
|
gdImageLine(im, x1+r, y1, x2-r, y1, color->id);
|
1304 |
|
|
gdImageLine(im, x1+r, y2, x2-r, y2, color->id);
|
1305 |
|
|
gdImageLine(im, x1, y1+r, x1, y2-r, color->id);
|
1306 |
|
|
gdImageLine(im, x2, y1+r, x2, y2-r, color->id);
|
1307 |
bertho |
1.9 |
if(conf.box_shadow)
|
1308 |
|
|
{
|
1309 |
|
|
gdImageLine(im, x1+r+1, y2+1, x2-r, y2+1, black_color.id);
|
1310 |
|
|
gdImageLine(im, x2+1, y1+r+1, x2+1, y2-r, black_color.id);
|
1311 |
|
|
}
|
1312 |
bertho |
1.1 |
if(r)
|
1313 |
|
|
{
|
1314 |
bertho |
1.18 |
/* FIXME: Pixelization is not perfect */
|
1315 |
bertho |
1.1 |
gdImageArc(im, x1+r, y1+r, r2, r2, 180, 270, color->id);
|
1316 |
|
|
gdImageArc(im, x2-r, y1+r, r2, r2, 270, 360, color->id);
|
1317 |
|
|
gdImageArc(im, x1+r, y2-r, r2, r2, 90, 180, color->id);
|
1318 |
bertho |
1.9 |
if(conf.box_shadow)
|
1319 |
|
|
{
|
1320 |
|
|
gdImageArc(im, x2-r+1, y2-r+1, r2, r2, 0, 90, black_color.id);
|
1321 |
bertho |
1.18 |
gdImageArc(im, x2-r+1, y2-r, r2, r2, 0, 90, black_color.id);
|
1322 |
|
|
gdImageArc(im, x2-r, y2-r+1, r2, r2, 0, 90, black_color.id);
|
1323 |
bertho |
1.9 |
}
|
1324 |
bertho |
1.18 |
gdImageArc(im, x2-r, y2-r, r2, r2, 0, 90, color->id);
|
1325 |
bertho |
1.1 |
}
|
1326 |
bertho |
1.19 |
#ifndef NOGDFILL
|
1327 |
bertho |
1.9 |
gdImageFillToBorder(im, (x1+x2)/2, (y1+y2)/2, color->id, bgcolor->id);
|
1328 |
bertho |
1.19 |
#endif
|
1329 |
bertho |
1.1 |
}
|
1330 |
|
|
|
1331 |
bertho |
1.19 |
static void draw_string(gdImagePtr im, char *s, font_t *f, int x, int y, int align, color_t *c)
|
1332 |
bertho |
1.1 |
{
|
1333 |
bertho |
1.19 |
int h = get_sheight(s, f);
|
1334 |
bertho |
1.1 |
int xx, yy;
|
1335 |
|
|
switch(align & ALIGN_HX)
|
1336 |
|
|
{
|
1337 |
|
|
default:
|
1338 |
|
|
case ALIGN_HL: xx = 0; break;
|
1339 |
|
|
case ALIGN_HC: xx = -get_swidth(s, f)/2; break;
|
1340 |
|
|
case ALIGN_HR: xx = -get_swidth(s, f); break;
|
1341 |
|
|
}
|
1342 |
|
|
switch(align & ALIGN_VX)
|
1343 |
|
|
{
|
1344 |
|
|
default:
|
1345 |
|
|
case ALIGN_VT: yy = 0; break;
|
1346 |
bertho |
1.19 |
case ALIGN_VC: yy = h/2; break;
|
1347 |
|
|
case ALIGN_VB: yy = h; break;
|
1348 |
bertho |
1.1 |
}
|
1349 |
bertho |
1.19 |
#if defined(HAVE_GDIMAGESTRINGFT) || defined(HAVE_GDIMAGESTRINGTTF)
|
1350 |
|
|
if(conf.use_ttf && f->ttfont)
|
1351 |
|
|
{
|
1352 |
|
|
int bb[8];
|
1353 |
|
|
char *e;
|
1354 |
|
|
int cid = conf.anti_alias ? c->id : -c->id;
|
1355 |
|
|
#ifdef HAVE_GDIMAGESTRINGFT
|
1356 |
|
|
e = gdImageStringFT(im, bb, cid, f->ttfont, f->ttsize, 0.0, x+xx, y+yy+h-2, (char *)s);
|
1357 |
|
|
#else
|
1358 |
|
|
e = gdImageStringTTF(im, bb, cid, f->ttfont, f->ttsize, 0.0, x+xx, y+yy+h-2, (char *)s);
|
1359 |
|
|
#endif
|
1360 |
|
|
if(!e)
|
1361 |
|
|
return;
|
1362 |
|
|
}
|
1363 |
|
|
#endif
|
1364 |
|
|
yy = -yy;
|
1365 |
|
|
gdImageString(im, f->gdfont, x+xx+1, y+yy, s, c->id);
|
1366 |
bertho |
1.1 |
}
|
1367 |
|
|
|
1368 |
bertho |
1.19 |
static void draw_stringnl(gdImagePtr im, char *s, font_t *f, int x, int y, int align, color_t *c)
|
1369 |
bertho |
1.9 |
{
|
1370 |
|
|
char *t;
|
1371 |
|
|
char *d;
|
1372 |
|
|
d = s = xstrdup(s);
|
1373 |
|
|
do
|
1374 |
|
|
{
|
1375 |
|
|
t = strchr(s, '\n');
|
1376 |
|
|
if(t)
|
1377 |
|
|
*t = '\0';
|
1378 |
|
|
draw_string(im, s, f, x, y, align, c);
|
1379 |
|
|
y += get_sheight(s, f);
|
1380 |
|
|
s = t+1;
|
1381 |
|
|
} while(t);
|
1382 |
|
|
xfree(d);
|
1383 |
|
|
}
|
1384 |
|
|
|
1385 |
bertho |
1.19 |
static void draw_rev(gdImagePtr im, revision_t *r)
|
1386 |
bertho |
1.1 |
{
|
1387 |
bertho |
1.25 |
int lx;
|
1388 |
|
|
int rx;
|
1389 |
|
|
int x2;
|
1390 |
bertho |
1.1 |
int i;
|
1391 |
bertho |
1.25 |
int ty;
|
1392 |
|
|
|
1393 |
|
|
if(conf.left_right)
|
1394 |
|
|
{
|
1395 |
|
|
lx = r->cx;
|
1396 |
|
|
rx = r->cx + r->w;
|
1397 |
|
|
ty = r->y - r->h/2;
|
1398 |
|
|
x2 = r->cx + r->w/2;
|
1399 |
|
|
}
|
1400 |
|
|
else
|
1401 |
|
|
{
|
1402 |
|
|
lx = r->cx - r->w/2;
|
1403 |
|
|
rx = lx + r->w;
|
1404 |
|
|
ty = r->y;
|
1405 |
|
|
x2 = r->cx;
|
1406 |
|
|
}
|
1407 |
bertho |
1.9 |
draw_rbox(im, lx, ty, rx, ty+r->h, 0, &conf.rev_color, &conf.rev_bgcolor);
|
1408 |
bertho |
1.1 |
ty += conf.rev_tspace;
|
1409 |
bertho |
1.25 |
draw_string(im, r->rev->rev, &conf.rev_font, x2, ty, ALIGN_HC, &conf.rev_color);
|
1410 |
bertho |
1.1 |
ty += get_sheight(r->rev->rev, &conf.rev_font);
|
1411 |
bertho |
1.25 |
draw_stringnl(im, r->revtext, &conf.rev_text_font, x2, ty, ALIGN_HC, &conf.rev_text_color);
|
1412 |
bertho |
1.9 |
ty += get_sheight(r->revtext, &conf.rev_text_font);
|
1413 |
bertho |
1.1 |
for(i = 0; i < r->ntags; i++)
|
1414 |
|
|
{
|
1415 |
bertho |
1.25 |
draw_string(im, r->tags[i]->tag, &conf.tag_font, x2, ty, ALIGN_HC, &conf.tag_color);
|
1416 |
bertho |
1.19 |
ty += get_sheight(r->tags[i]->tag, &conf.tag_font) + conf.rev_separator;
|
1417 |
bertho |
1.1 |
}
|
1418 |
|
|
}
|
1419 |
|
|
|
1420 |
bertho |
1.26 |
static void draw_branch_box(gdImagePtr im, branch_t *b, int xp, int yp)
|
1421 |
bertho |
1.1 |
{
|
1422 |
bertho |
1.25 |
int lx;
|
1423 |
|
|
int rx;
|
1424 |
bertho |
1.16 |
int i;
|
1425 |
bertho |
1.1 |
int yy;
|
1426 |
bertho |
1.25 |
int x2;
|
1427 |
bertho |
1.16 |
|
1428 |
bertho |
1.25 |
if(conf.left_right)
|
1429 |
|
|
{
|
1430 |
|
|
lx = b->cx;
|
1431 |
|
|
rx = lx + b->w;
|
1432 |
|
|
x2 = b->cx + b->w/2;
|
1433 |
|
|
}
|
1434 |
|
|
else
|
1435 |
|
|
{
|
1436 |
|
|
lx = b->cx - b->w/2;
|
1437 |
|
|
rx = lx + b->w;
|
1438 |
|
|
x2 = b->cx;
|
1439 |
|
|
}
|
1440 |
bertho |
1.26 |
draw_rbox(im, lx+xp, yp, rx+xp, yp+b->h, 5, &conf.branch_color, &conf.branch_bgcolor);
|
1441 |
bertho |
1.1 |
yy = conf.branch_tspace;
|
1442 |
bertho |
1.32 |
if(!b->nfolds)
|
1443 |
bertho |
1.1 |
{
|
1444 |
bertho |
1.32 |
draw_string(im, b->branch->branch, &conf.branch_font, x2+xp, yp+yy, ALIGN_HC, &conf.branch_color);
|
1445 |
|
|
yy += get_sheight(b->branch->branch, &conf.branch_font);
|
1446 |
|
|
for(i = 0; i < b->ntags; i++)
|
1447 |
|
|
{
|
1448 |
|
|
draw_string(im, b->tags[i]->tag, &conf.branch_tag_font, x2+xp, yp+yy, ALIGN_HC, &conf.branch_tag_color);
|
1449 |
bertho |
1.34 |
yy += get_sheight(b->tags[i]->tag, &conf.branch_tag_font);
|
1450 |
bertho |
1.32 |
}
|
1451 |
|
|
}
|
1452 |
|
|
else
|
1453 |
|
|
{
|
1454 |
|
|
int y1, y2;
|
1455 |
|
|
int tx = lx + b->fw + conf.branch_lspace;
|
1456 |
|
|
int nx = tx - get_swidth(" ", &conf.branch_font);
|
1457 |
|
|
draw_string(im, b->branch->branch, &conf.branch_font, nx+xp, yp+yy, ALIGN_HR, &conf.branch_color);
|
1458 |
|
|
y1 = get_sheight(b->branch->branch, &conf.branch_font);
|
1459 |
|
|
draw_string(im, b->tags[0]->tag, &conf.branch_tag_font, tx+xp, yp+yy, ALIGN_HL, &conf.branch_tag_color);
|
1460 |
|
|
y2 = get_sheight(b->tags[0]->tag, &conf.branch_font);
|
1461 |
|
|
yy += MAX(y1, y2);
|
1462 |
|
|
for(i = 0; i < b->nfolds; i++)
|
1463 |
|
|
{
|
1464 |
|
|
draw_string(im, b->folds[i]->branch->branch, &conf.branch_font, nx+xp, yp+yy, ALIGN_HR, &conf.branch_color);
|
1465 |
|
|
y1 = get_sheight(b->folds[i]->branch->branch, &conf.branch_font);
|
1466 |
|
|
draw_string(im, b->folds[i]->tags[0]->tag, &conf.branch_tag_font, tx+xp, yp+yy, ALIGN_HL, &conf.branch_tag_color);
|
1467 |
bertho |
1.34 |
y2 = get_sheight(b->folds[i]->tags[0]->tag, &conf.branch_tag_font);
|
1468 |
bertho |
1.32 |
yy += MAX(y1, y2);
|
1469 |
|
|
}
|
1470 |
bertho |
1.1 |
}
|
1471 |
bertho |
1.16 |
}
|
1472 |
|
|
|
1473 |
bertho |
1.19 |
static void draw_branch(gdImagePtr im, branch_t *b)
|
1474 |
bertho |
1.16 |
{
|
1475 |
bertho |
1.25 |
int yy, xx;
|
1476 |
bertho |
1.16 |
int i;
|
1477 |
bertho |
1.17 |
int line[4];
|
1478 |
bertho |
1.20 |
int l;
|
1479 |
|
|
int sign;
|
1480 |
bertho |
1.17 |
|
1481 |
|
|
line[0] = conf.rev_color.id;
|
1482 |
|
|
line[1] = gdTransparent;
|
1483 |
|
|
line[1] = gdTransparent;
|
1484 |
|
|
line[3] = conf.rev_color.id;
|
1485 |
|
|
|
1486 |
bertho |
1.26 |
draw_branch_box(im, b, 0, conf.left_right ? b->y - b->h/2 : b->y);
|
1487 |
bertho |
1.1 |
|
1488 |
bertho |
1.25 |
if(conf.left_right)
|
1489 |
bertho |
1.16 |
{
|
1490 |
bertho |
1.25 |
if(conf.upside_down)
|
1491 |
bertho |
1.16 |
{
|
1492 |
bertho |
1.25 |
xx = b->cx;
|
1493 |
|
|
for(i = 0; i < b->nrevs; i++)
|
1494 |
bertho |
1.20 |
{
|
1495 |
bertho |
1.25 |
revision_t *r = b->revs[i];
|
1496 |
|
|
gdImageSetStyle(im, line, r->stripped ? 4 : 1);
|
1497 |
|
|
gdImageLine(im, xx, r->y, r->cx+r->w, r->y, gdStyled);
|
1498 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1499 |
|
|
{
|
1500 |
|
|
int pp = (l+1)/2*sign;
|
1501 |
|
|
gdImageLine(im, xx, r->y+pp, r->cx+r->w, r->y+pp, gdStyled);
|
1502 |
|
|
sign *= -1;
|
1503 |
|
|
}
|
1504 |
|
|
draw_rev(im, r);
|
1505 |
|
|
xx = r->cx;
|
1506 |
|
|
}
|
1507 |
bertho |
1.32 |
if(conf.branch_dupbox && b->nrevs)
|
1508 |
bertho |
1.25 |
{
|
1509 |
|
|
i = b->cx - b->tw + b->w;
|
1510 |
bertho |
1.26 |
gdImageLine(im, xx, b->y, i+b->w, b->y, conf.rev_color.id);
|
1511 |
bertho |
1.25 |
for(sign = l = 1; l < conf.thick_lines; l++)
|
1512 |
|
|
{
|
1513 |
|
|
int pp = (l+1)/2*sign;
|
1514 |
bertho |
1.26 |
gdImageLine(im, xx, b->y+pp, i+b->w, b->y+pp, conf.rev_color.id);
|
1515 |
bertho |
1.25 |
sign *= -1;
|
1516 |
|
|
}
|
1517 |
bertho |
1.26 |
draw_branch_box(im, b, i - b->cx, b->y - b->h/2);
|
1518 |
bertho |
1.20 |
}
|
1519 |
bertho |
1.16 |
}
|
1520 |
bertho |
1.25 |
else
|
1521 |
bertho |
1.16 |
{
|
1522 |
bertho |
1.25 |
xx = b->cx + b->w;
|
1523 |
|
|
for(i = 0; i < b->nrevs; i++)
|
1524 |
|
|
{
|
1525 |
|
|
revision_t *r = b->revs[i];
|
1526 |
|
|
gdImageSetStyle(im, line, r->stripped ? 4 : 1);
|
1527 |
|
|
gdImageLine(im, xx, r->y, r->cx, r->y, gdStyled);
|
1528 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1529 |
|
|
{
|
1530 |
|
|
int pp = (l+1)/2*sign;
|
1531 |
|
|
gdImageLine(im, xx, r->y+pp, r->cx, r->y+pp, gdStyled);
|
1532 |
|
|
sign *= -1;
|
1533 |
|
|
}
|
1534 |
|
|
draw_rev(im, r);
|
1535 |
|
|
xx = r->cx + r->w;
|
1536 |
|
|
}
|
1537 |
bertho |
1.32 |
if(conf.branch_dupbox && b->nrevs)
|
1538 |
bertho |
1.20 |
{
|
1539 |
bertho |
1.25 |
i = b->cx + b->tw - b->w;
|
1540 |
|
|
gdImageLine(im, xx, b->y, i, b->y, conf.rev_color.id);
|
1541 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1542 |
|
|
{
|
1543 |
|
|
int pp = (l+1)/2*sign;
|
1544 |
|
|
gdImageLine(im, xx, b->y+pp, i, b->y+pp, conf.rev_color.id);
|
1545 |
|
|
sign *= -1;
|
1546 |
|
|
}
|
1547 |
bertho |
1.26 |
draw_branch_box(im, b, i - b->cx, b->y - b->h/2);
|
1548 |
bertho |
1.20 |
}
|
1549 |
bertho |
1.16 |
}
|
1550 |
|
|
}
|
1551 |
|
|
else
|
1552 |
bertho |
1.1 |
{
|
1553 |
bertho |
1.25 |
if(conf.upside_down)
|
1554 |
bertho |
1.16 |
{
|
1555 |
bertho |
1.25 |
yy = b->y;
|
1556 |
|
|
for(i = 0; i < b->nrevs; i++)
|
1557 |
bertho |
1.20 |
{
|
1558 |
bertho |
1.25 |
revision_t *r = b->revs[i];
|
1559 |
|
|
gdImageSetStyle(im, line, r->stripped ? 4 : 1);
|
1560 |
|
|
gdImageLine(im, r->cx, yy, r->cx, r->y+r->h, gdStyled);
|
1561 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1562 |
|
|
{
|
1563 |
|
|
int pp = (l+1)/2*sign;
|
1564 |
|
|
gdImageLine(im, r->cx+pp, yy, r->cx+pp, r->y+r->h, gdStyled);
|
1565 |
|
|
sign *= -1;
|
1566 |
|
|
}
|
1567 |
|
|
draw_rev(im, r);
|
1568 |
|
|
yy = r->y;
|
1569 |
|
|
}
|
1570 |
bertho |
1.32 |
if(conf.branch_dupbox && b->nrevs)
|
1571 |
bertho |
1.25 |
{
|
1572 |
|
|
i = b->y - b->th + b->h;
|
1573 |
|
|
gdImageLine(im, b->cx, yy, b->cx, i, conf.rev_color.id);
|
1574 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1575 |
|
|
{
|
1576 |
|
|
int pp = (l+1)/2*sign;
|
1577 |
|
|
gdImageLine(im, b->cx+pp, yy, b->cx+pp, i, conf.rev_color.id);
|
1578 |
|
|
sign *= -1;
|
1579 |
|
|
}
|
1580 |
bertho |
1.26 |
draw_branch_box(im, b, 0, i);
|
1581 |
bertho |
1.20 |
}
|
1582 |
bertho |
1.16 |
}
|
1583 |
bertho |
1.25 |
else
|
1584 |
bertho |
1.16 |
{
|
1585 |
bertho |
1.25 |
yy = b->y + b->h;
|
1586 |
|
|
for(i = 0; i < b->nrevs; i++)
|
1587 |
|
|
{
|
1588 |
|
|
revision_t *r = b->revs[i];
|
1589 |
|
|
gdImageSetStyle(im, line, r->stripped ? 4 : 1);
|
1590 |
|
|
gdImageLine(im, r->cx, yy, r->cx, r->y, gdStyled);
|
1591 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1592 |
|
|
{
|
1593 |
|
|
int pp = (l+1)/2*sign;
|
1594 |
|
|
gdImageLine(im, r->cx+pp, yy, r->cx+pp, r->y, gdStyled);
|
1595 |
|
|
sign *= -1;
|
1596 |
|
|
}
|
1597 |
|
|
draw_rev(im, r);
|
1598 |
|
|
yy = r->y + r->h;
|
1599 |
|
|
}
|
1600 |
bertho |
1.32 |
if(conf.branch_dupbox && b->nrevs)
|
1601 |
bertho |
1.20 |
{
|
1602 |
bertho |
1.25 |
i = b->y + b->th - b->h;
|
1603 |
|
|
gdImageLine(im, b->cx, yy, b->cx, i, conf.rev_color.id);
|
1604 |
|
|
for(sign = l = 1; l < conf.thick_lines; l++)
|
1605 |
|
|
{
|
1606 |
|
|
int pp = (l+1)/2*sign;
|
1607 |
|
|
gdImageLine(im, b->cx+pp, yy, b->cx+pp, i, conf.rev_color.id);
|
1608 |
|
|
sign *= -1;
|
1609 |
|
|
}
|
1610 |
bertho |
1.26 |
draw_branch_box(im, b, 0, i);
|
1611 |
bertho |
1.20 |
}
|
1612 |
bertho |
1.16 |
}
|
1613 |
bertho |
1.1 |
}
|
1614 |
|
|
}
|
1615 |
|
|
|
1616 |
bertho |
1.19 |
static void draw_connector(gdImagePtr im, branch_t *b)
|
1617 |
bertho |
1.1 |
{
|
1618 |
bertho |
1.20 |
int l;
|
1619 |
|
|
int sign;
|
1620 |
bertho |
1.1 |
revision_t *r = b->branchpoint;
|
1621 |
bertho |
1.7 |
int x1 = r->cx + r->w/2 + 2;
|
1622 |
bertho |
1.1 |
int y1 = r->y + r->h/2;
|
1623 |
bertho |
1.7 |
int x2 = b->cx;
|
1624 |
bertho |
1.1 |
int y2 = b->y;
|
1625 |
bertho |
1.25 |
|
1626 |
|
|
if(conf.left_right)
|
1627 |
|
|
{
|
1628 |
|
|
x2 = r->cx + r->w/2;
|
1629 |
bertho |
1.26 |
y2 = r->y + r->h/2 + 3;
|
1630 |
bertho |
1.25 |
x1 = b->cx;
|
1631 |
|
|
y1 = b->y;
|
1632 |
|
|
if(conf.upside_down)
|
1633 |
|
|
x1 += b->w;
|
1634 |
|
|
}
|
1635 |
|
|
else
|
1636 |
|
|
{
|
1637 |
|
|
x1 = r->cx + r->w/2 + 2;
|
1638 |
|
|
y1 = r->y + r->h/2;
|
1639 |
|
|
x2 = b->cx;
|
1640 |
|
|
y2 = b->y;
|
1641 |
|
|
if(conf.upside_down)
|
1642 |
|
|
y2 += b->h;
|
1643 |
|
|
}
|
1644 |
bertho |
1.1 |
gdImageLine(im, x1, y1, x2, y1, conf.branch_color.id);
|
1645 |
|
|
gdImageLine(im, x2, y1, x2, y2, conf.branch_color.id);
|
1646 |
bertho |
1.20 |
for(sign = l = 1; l < conf.thick_lines; l++)
|
1647 |
|
|
{
|
1648 |
|
|
int pp = (l+1)/2*sign;
|
1649 |
bertho |
1.26 |
gdImageLine(im, x1, y1+pp, x2, y1+pp, conf.branch_color.id);
|
1650 |
|
|
gdImageLine(im, x2+pp, y1, x2+pp, y2, conf.branch_color.id);
|
1651 |
bertho |
1.20 |
sign *= -1;
|
1652 |
|
|
}
|
1653 |
bertho |
1.1 |
}
|
1654 |
|
|
|
1655 |
bertho |
1.31 |
static void draw_merges(gdImagePtr im, rcsfile_t *rcs, int dot)
|
1656 |
bertho |
1.30 |
{
|
1657 |
|
|
int i;
|
1658 |
|
|
for(i = 0; i < rcs->nmerges; i++)
|
1659 |
|
|
{
|
1660 |
|
|
revision_t *fr = rcs->merges[i].from->logrev;
|
1661 |
|
|
revision_t *tr = rcs->merges[i].to->logrev;
|
1662 |
|
|
int x1, x2, y1, y2;
|
1663 |
bertho |
1.31 |
if(!fr || !tr || fr == tr)
|
1664 |
|
|
continue; /* This can happen with detached tags and self-references */
|
1665 |
bertho |
1.30 |
if(conf.left_right)
|
1666 |
|
|
{
|
1667 |
bertho |
1.32 |
if(fr->branch == tr->branch)
|
1668 |
bertho |
1.30 |
{
|
1669 |
bertho |
1.32 |
y1 = fr->y - fr->h/2;
|
1670 |
bertho |
1.30 |
y2 = tr->y - tr->h/2;
|
1671 |
|
|
}
|
1672 |
|
|
else
|
1673 |
|
|
{
|
1674 |
bertho |
1.32 |
if(fr->y < tr->y)
|
1675 |
|
|
{
|
1676 |
|
|
y1 = fr->y + fr->h/2;
|
1677 |
|
|
y2 = tr->y - tr->h/2;
|
1678 |
|
|
}
|
1679 |
|
|
else
|
1680 |
|
|
{
|
1681 |
|
|
y1 = fr->y - fr->h/2;
|
1682 |
|
|
y2 = tr->y + tr->h/2;
|
1683 |
|
|
}
|
1684 |
bertho |
1.30 |
}
|
1685 |
|
|
x1 = fr->cx + fr->w/2;
|
1686 |
|
|
x2 = tr->cx + tr->w/2;
|
1687 |
|
|
}
|
1688 |
|
|
else
|
1689 |
|
|
{
|
1690 |
bertho |
1.32 |
if(fr->branch == tr->branch)
|
1691 |
bertho |
1.30 |
{
|
1692 |
bertho |
1.32 |
x1 = fr->cx - fr->w/2;
|
1693 |
bertho |
1.30 |
x2 = tr->cx - tr->w/2;
|
1694 |
|
|
}
|
1695 |
|
|
else
|
1696 |
|
|
{
|
1697 |
bertho |
1.32 |
if(fr->cx < tr->cx)
|
1698 |
|
|
{
|
1699 |
|
|
x1 = fr->cx + fr->w/2;
|
1700 |
|
|
x2 = tr->cx - tr->w/2;
|
1701 |
|
|
}
|
1702 |
|
|
else
|
1703 |
|
|
{
|
1704 |
|
|
x1 = fr->cx - fr->w/2;
|
1705 |
|
|
x2 = tr->cx + tr->w/2;
|
1706 |
|
|
}
|
1707 |
bertho |
1.30 |
}
|
1708 |
bertho |
1.31 |
y1 = fr->y + rcs->merges[i].from->yofs;
|
1709 |
|
|
y2 = tr->y + rcs->merges[i].to->yofs;
|
1710 |
bertho |
1.30 |
}
|
1711 |
bertho |
1.35 |
if(dot && !conf.merge_arrows)
|
1712 |
bertho |
1.30 |
{
|
1713 |
bertho |
1.31 |
int o = conf.left_right ? 1 : 0;
|
1714 |
|
|
gdImageArc(im, x2, y2+o, 8, 8, 0, 360, conf.merge_color.id);
|
1715 |
|
|
gdImageFillToBorder(im, x2+1, y2+o+1, conf.merge_color.id, conf.merge_color.id);
|
1716 |
bertho |
1.30 |
}
|
1717 |
bertho |
1.35 |
else if(dot && conf.merge_arrows)
|
1718 |
|
|
{
|
1719 |
|
|
/*
|
1720 |
|
|
* Arrow patch from Haroon Rafique <haroon.rafique@utoronto.ca>
|
1721 |
|
|
* Slightly adapted to be more configurable.
|
1722 |
|
|
*/
|
1723 |
|
|
int sx, sy; /* start point coordinates */
|
1724 |
|
|
int ex, ey; /* end point coordinates */
|
1725 |
|
|
double theta;
|
1726 |
|
|
double u1, v1, u2, v2;
|
1727 |
|
|
gdPoint p[3];
|
1728 |
|
|
|
1729 |
|
|
sx = x1; sy = y1;
|
1730 |
|
|
ex = x2; ey = y2;
|
1731 |
|
|
if(conf.left_right)
|
1732 |
|
|
{
|
1733 |
|
|
if(fr->branch == tr->branch)
|
1734 |
|
|
{
|
1735 |
|
|
int yy = (y1 < y2 ? y1 : y2) - 5;
|
1736 |
|
|
/* line from (x1,yy) to (x2,yy) */
|
1737 |
|
|
sy = ey = yy;
|
1738 |
|
|
}
|
1739 |
|
|
else
|
1740 |
|
|
{
|
1741 |
|
|
if(y1 > y2)
|
1742 |
|
|
{
|
1743 |
|
|
/* line from (x1,y1-3) to (x2,y2+3+1) */
|
1744 |
|
|
sy = y1-3;
|
1745 |
|
|
ey = y2+3+1;
|
1746 |
|
|
}
|
1747 |
|
|
else
|
1748 |
|
|
{
|
1749 |
|
|
/* line from (x1,y1+3+1) to (x2,y2-3) */
|
1750 |
|
|
sy = y1+3+1;
|
1751 |
|
|
ey = y2-3;
|
1752 |
|
|
}
|
1753 |
|
|
}
|
1754 |
|
|
}
|
1755 |
|
|
else
|
1756 |
|
|
{
|
1757 |
|
|
if(fr->branch == tr->branch)
|
1758 |
|
|
{
|
1759 |
|
|
int xx = (x1 < x2 ? x1 : x2) - 5;
|
1760 |
|
|
/* line from (xx,y1) to (xx,y2) */
|
1761 |
|
|
sx = ex = xx;
|
1762 |
|
|
}
|
1763 |
|
|
else
|
1764 |
|
|
{
|
1765 |
|
|
if(x1 > x2)
|
1766 |
|
|
{
|
1767 |
|
|
/* line from (x1-3,y1) to (x2+3,y2) */
|
1768 |
|
|
sx = x1-3;
|
1769 |
|
|
ex = x2+3;
|
1770 |
|
|
}
|
1771 |
|
|
else
|
1772 |
|
|
{
|
1773 |
|
|
/* line from (x1+3,y1) to (x2-3,y2) */
|
1774 |
|
|
sx = x1+3;
|
1775 |
|
|
ex = x2-3;
|
1776 |
|
|
}
|
1777 |
|
|
}
|
1778 |
|
|
}
|
1779 |
|
|
/*
|
1780 |
|
|
* inspiration for arrow code comes from arrows.c in the
|
1781 |
|
|
* graphviz package. Thank you, AT&T
|
1782 |
|
|
*/
|
1783 |
|
|
/* theta in radians */
|
1784 |
|
|
theta = atan2((double)(sy-ey), (double)(sx-ex));
|
1785 |
|
|
u1 = (double)conf.arrow_length * cos(theta);
|
1786 |
|
|
v1 = (double)conf.arrow_length * sin(theta);
|
1787 |
|
|
u2 = (double)conf.arrow_width * cos(theta + M_PI/2.0);
|
1788 |
|
|
v2 = (double)conf.arrow_width * sin(theta + M_PI/2.0);
|
1789 |
|
|
/* points of polygon (triangle) */
|
1790 |
|
|
p[0].x = ROUND(ex + u1 - u2);
|
1791 |
|
|
p[0].y = ROUND(ey + v1 - v2);
|
1792 |
|
|
p[1].x = ex;
|
1793 |
|
|
p[1].y = ey;
|
1794 |
|
|
p[2].x = ROUND(ex + u1 + u2);
|
1795 |
|
|
p[2].y = ROUND(ey + v1 + v2);
|
1796 |
|
|
/* draw the polygon (triangle) */
|
1797 |
|
|
gdImageFilledPolygon(im, p, 3, conf.merge_color.id);
|
1798 |
|
|
}
|
1799 |
bertho |
1.30 |
else
|
1800 |
|
|
{
|
1801 |
bertho |
1.31 |
if(conf.left_right)
|
1802 |
bertho |
1.30 |
{
|
1803 |
bertho |
1.32 |
if(fr->branch == tr->branch)
|
1804 |
bertho |
1.31 |
{
|
1805 |
bertho |
1.32 |
int yy = (y1 < y2 ? y1 : y2) - 5;
|
1806 |
|
|
gdImageLine(im, x1, y1, x1, yy, conf.merge_color.id);
|
1807 |
|
|
gdImageLine(im, x2, y2, x2, yy, conf.merge_color.id);
|
1808 |
|
|
gdImageLine(im, x1, yy, x2, yy, conf.merge_color.id);
|
1809 |
bertho |
1.31 |
}
|
1810 |
|
|
else
|
1811 |
|
|
{
|
1812 |
bertho |
1.32 |
if(y1 > y2)
|
1813 |
|
|
{
|
1814 |
|
|
gdImageLine(im, x1, y1, x1, y1-3, conf.merge_color.id);
|
1815 |
|
|
gdImageLine(im, x2, y2+1, x2, y2+3+1, conf.merge_color.id);
|
1816 |
|
|
gdImageLine(im, x1, y1-3, x2, y2+3+1, conf.merge_color.id);
|
1817 |
|
|
}
|
1818 |
|
|
else
|
1819 |
|
|
{
|
1820 |
|
|
gdImageLine(im, x1, y1+1, x1, y1+3+1, conf.merge_color.id);
|
1821 |
|
|
gdImageLine(im, x2, y2, x2, y2-3, conf.merge_color.id);
|
1822 |
|
|
gdImageLine(im, x1, y1+3+1, x2, y2-3, conf.merge_color.id);
|
1823 |
|
|
}
|
1824 |
bertho |
1.31 |
}
|
1825 |
bertho |
1.30 |
}
|
1826 |
|
|
else
|
1827 |
|
|
{
|
1828 |
bertho |
1.32 |
if(fr->branch == tr->branch)
|
1829 |
bertho |
1.31 |
{
|
1830 |
bertho |
1.32 |
int xx = (x1 < x2 ? x1 : x2) - 5;
|
1831 |
|
|
gdImageLine(im, xx, y1, x1, y1, conf.merge_color.id);
|
1832 |
|
|
gdImageLine(im, xx, y2, x2, y2, conf.merge_color.id);
|
1833 |
|
|
gdImageLine(im, xx, y1, xx, y2, conf.merge_color.id);
|
1834 |
bertho |
1.31 |
}
|
1835 |
|
|
else
|
1836 |
|
|
{
|
1837 |
bertho |
1.32 |
if(x1 > x2)
|
1838 |
|
|
{
|
1839 |
|
|
gdImageLine(im, x1, y1, x1-3, y1, conf.merge_color.id);
|
1840 |
|
|
gdImageLine(im, x2, y2, x2+3, y2, conf.merge_color.id);
|
1841 |
|
|
gdImageLine(im, x1-3, y1, x2+3, y2, conf.merge_color.id);
|
1842 |
|
|
}
|
1843 |
|
|
else
|
1844 |
|
|
{
|
1845 |
|
|
gdImageLine(im, x1, y1, x1+3, y1, conf.merge_color.id);
|
1846 |
|
|
gdImageLine(im, x2, y2, x2-3, y2, conf.merge_color.id);
|
1847 |
|
|
gdImageLine(im, x1+3, y1, x2-3, y2, conf.merge_color.id);
|
1848 |
|
|
}
|
1849 |
bertho |
1.31 |
}
|
1850 |
bertho |
1.30 |
}
|
1851 |
|
|
}
|
1852 |
|
|
}
|
1853 |
|
|
}
|
1854 |
|
|
|
1855 |
bertho |
1.19 |
static void alloc_color(gdImagePtr im, color_t *c)
|
1856 |
bertho |
1.9 |
{
|
1857 |
|
|
c->id = gdImageColorAllocate(im, c->r, c->g, c->b);
|
1858 |
|
|
}
|
1859 |
|
|
|
1860 |
bertho |
1.7 |
gdImagePtr make_image(rcsfile_t *rcs)
|
1861 |
bertho |
1.1 |
{
|
1862 |
|
|
gdImagePtr im;
|
1863 |
|
|
int i;
|
1864 |
bertho |
1.8 |
char *cptr;
|
1865 |
bertho |
1.1 |
|
1866 |
bertho |
1.15 |
cptr = expand_string(conf.title, rcs, NULL, NULL, NULL, NULL);
|
1867 |
|
|
i = get_swidth(cptr, &conf.title_font);
|
1868 |
|
|
if(rcs->tw+conf.margin_left+conf.margin_right > i)
|
1869 |
|
|
i = rcs->tw+conf.margin_left+conf.margin_right;
|
1870 |
|
|
im = gdImageCreate(i, rcs->th+conf.margin_top+conf.margin_bottom);
|
1871 |
bertho |
1.9 |
alloc_color(im, &conf.color_bg);
|
1872 |
|
|
alloc_color(im, &conf.tag_color);
|
1873 |
|
|
alloc_color(im, &conf.rev_color);
|
1874 |
|
|
alloc_color(im, &conf.rev_bgcolor);
|
1875 |
|
|
alloc_color(im, &conf.rev_text_color);
|
1876 |
|
|
alloc_color(im, &conf.branch_color);
|
1877 |
bertho |
1.19 |
alloc_color(im, &conf.branch_tag_color);
|
1878 |
bertho |
1.9 |
alloc_color(im, &conf.branch_bgcolor);
|
1879 |
|
|
alloc_color(im, &conf.title_color);
|
1880 |
bertho |
1.30 |
alloc_color(im, &conf.merge_color);
|
1881 |
bertho |
1.9 |
alloc_color(im, &black_color);
|
1882 |
|
|
alloc_color(im, &white_color);
|
1883 |
bertho |
1.1 |
|
1884 |
bertho |
1.19 |
if(conf.transparent_bg)
|
1885 |
|
|
gdImageColorTransparent(im, conf.color_bg.id);
|
1886 |
|
|
|
1887 |
bertho |
1.30 |
if(!conf.merge_front)
|
1888 |
bertho |
1.31 |
draw_merges(im, rcs, 0);
|
1889 |
bertho |
1.30 |
|
1890 |
bertho |
1.1 |
for(i = 0; i < rcs->nbranches; i++)
|
1891 |
bertho |
1.32 |
{
|
1892 |
|
|
if(!rcs->branches[i]->folded)
|
1893 |
|
|
draw_branch(im, rcs->branches[i]);
|
1894 |
|
|
}
|
1895 |
bertho |
1.31 |
|
1896 |
|
|
draw_merges(im, rcs, 1); /* The dots of the merge dest */
|
1897 |
|
|
|
1898 |
bertho |
1.1 |
for(i = 0; i < rcs->nbranches; i++)
|
1899 |
|
|
{
|
1900 |
|
|
if(rcs->branches[i]->branchpoint)
|
1901 |
|
|
draw_connector(im, rcs->branches[i]);
|
1902 |
|
|
}
|
1903 |
bertho |
1.9 |
draw_stringnl(im, cptr, &conf.title_font, conf.title_x, conf.title_y, conf.title_align, &conf.title_color);
|
1904 |
bertho |
1.8 |
xfree(cptr);
|
1905 |
bertho |
1.1 |
|
1906 |
bertho |
1.30 |
if(conf.merge_front)
|
1907 |
bertho |
1.31 |
draw_merges(im, rcs, 0);
|
1908 |
bertho |
1.30 |
|
1909 |
bertho |
1.1 |
return im;
|
1910 |
|
|
}
|
1911 |
|
|
|
1912 |
bertho |
1.7 |
/*
|
1913 |
|
|
**************************************************************************
|
1914 |
|
|
* Layout routines
|
1915 |
bertho |
1.19 |
*
|
1916 |
|
|
* Branch BBox:
|
1917 |
|
|
* left = center_x - total_width / 2 (cx-tw)/2
|
1918 |
|
|
* right = center_x + total_width / 2 (cx+tw)/2
|
1919 |
|
|
* top = y_pos (y)
|
1920 |
|
|
* bottom = y_pos + total_height (y+th)
|
1921 |
|
|
*
|
1922 |
|
|
* Margins of branches:
|
1923 |
|
|
*
|
1924 |
|
|
* . .
|
1925 |
|
|
* . .
|
1926 |
|
|
* +--------------+
|
1927 |
|
|
* ^
|
1928 |
|
|
* | branch_margin .
|
1929 |
|
|
* v .
|
1930 |
|
|
* ----------------+ .
|
1931 |
|
|
* | ^ |
|
1932 |
|
|
* | | branch_connect |
|
1933 |
|
|
* | v |
|
1934 |
|
|
*..-+ +t-----+------+ +------+------+
|
1935 |
|
|
* | l | | |
|
1936 |
|
|
* | <--> | branch bbox | <--> | branch bbox |
|
1937 |
|
|
* | | | r | | |
|
1938 |
|
|
*..-+ | +------------b+ | +-------------+
|
1939 |
|
|
* | ^ branch_margin
|
1940 |
|
|
* | | branch_margin
|
1941 |
|
|
* | v
|
1942 |
|
|
* | +-------------+
|
1943 |
|
|
* | . .
|
1944 |
|
|
* | . .
|
1945 |
|
|
* |
|
1946 |
|
|
* branch_margin
|
1947 |
|
|
*
|
1948 |
|
|
* FIXME: There are probable som +/-1 errors in the code...
|
1949 |
|
|
* (notably shadows are not calculated in the margins)
|
1950 |
bertho |
1.7 |
**************************************************************************
|
1951 |
|
|
*/
|
1952 |
bertho |
1.19 |
static void move_branch(branch_t *b, int x, int y)
|
1953 |
bertho |
1.1 |
{
|
1954 |
|
|
int i;
|
1955 |
bertho |
1.7 |
b->cx += x;
|
1956 |
bertho |
1.1 |
b->y += y;
|
1957 |
|
|
for(i = 0; i < b->nrevs; i++)
|
1958 |
|
|
{
|
1959 |
bertho |
1.7 |
b->revs[i]->cx += x;
|
1960 |
bertho |
1.1 |
b->revs[i]->y += y;
|
1961 |
|
|
}
|
1962 |
|
|
}
|
1963 |
|
|
|
1964 |
bertho |
1.19 |
static void initial_reposition_branch(revision_t *r, int *x, int *w)
|
1965 |
bertho |
1.6 |
{
|
1966 |
|
|
int i, j;
|
1967 |
|
|
for(j = 0; j < r->nbranches; j++)
|
1968 |
|
|
{
|
1969 |
|
|
branch_t *b = r->branches[j];
|
1970 |
bertho |
1.7 |
*x += *w + conf.rev_minline + b->tw/2 - b->cx;
|
1971 |
bertho |
1.6 |
*w = b->tw/2;
|
1972 |
bertho |
1.7 |
move_branch(b, *x, r->y + r->h/2 + conf.branch_connect);
|
1973 |
|
|
*x = b->cx;
|
1974 |
bertho |
1.6 |
/* Recurse to move branches of branched revisions */
|
1975 |
|
|
for(i = b->nrevs-1; i >= 0; i--)
|
1976 |
|
|
{
|
1977 |
bertho |
1.18 |
initial_reposition_branch(b->revs[i], x, w);
|
1978 |
bertho |
1.6 |
}
|
1979 |
|
|
}
|
1980 |
|
|
}
|
1981 |
|
|
|
1982 |
bertho |
1.25 |
static void initial_reposition_branch_lr(revision_t *r, int *y, int *h)
|
1983 |
|
|
{
|
1984 |
|
|
int i, j;
|
1985 |
|
|
for(j = 0; j < r->nbranches; j++)
|
1986 |
|
|
{
|
1987 |
|
|
branch_t *b = r->branches[j];
|
1988 |
|
|
*y += *h + conf.rev_minline + b->th/2 - b->y;
|
1989 |
|
|
*h = b->th/2;
|
1990 |
|
|
move_branch(b, r->cx + r->w/2 + conf.branch_connect, *y);
|
1991 |
|
|
*y = b->y;
|
1992 |
|
|
/* Recurse to move branches of branched revisions */
|
1993 |
|
|
for(i = b->nrevs-1; i >= 0; i--)
|
1994 |
|
|
{
|
1995 |
bertho |
1.32 |
initial_reposition_branch_lr(b->revs[i], y, h);
|
1996 |
bertho |
1.25 |
}
|
1997 |
|
|
}
|
1998 |
|
|
}
|
1999 |
|
|
|
2000 |
bertho |
1.19 |
static void rect_union(int *x, int *y, int *w, int *h, branch_t *b)
|
2001 |
bertho |
1.1 |
{
|
2002 |
|
|
int x1 = *x;
|
2003 |
|
|
int x2 = x1 + *w;
|
2004 |
|
|
int y1 = *y;
|
2005 |
|
|
int y2 = y1 + *h;
|
2006 |
bertho |
1.25 |
int xx1;
|
2007 |
|
|
int xx2;
|
2008 |
|
|
int yy1;
|
2009 |
|
|
int yy2;
|
2010 |
|
|
|
2011 |
|
|
if(conf.left_right)
|
2012 |
|
|
{
|
2013 |
|
|
xx1 = b->cx;
|
2014 |
|
|
yy1 = b->y - b->th/2;
|
2015 |
|
|
}
|
2016 |
|
|
else
|
2017 |
|
|
{
|
2018 |
|
|
xx1 = b->cx - b->tw/2;
|
2019 |
|
|
yy1 = b->y;
|
2020 |
|
|
}
|
2021 |
|
|
xx2 = xx1 + b->tw;
|
2022 |
|
|
yy2 = yy1 + b->th;
|
2023 |
|
|
|
2024 |
bertho |
1.1 |
x1 = MIN(x1, xx1);
|
2025 |
|
|
x2 = MAX(x2, xx2);
|
2026 |
|
|
y1 = MIN(y1, yy1);
|
2027 |
|
|
y2 = MAX(y2, yy2);
|
2028 |
|
|
*x = x1;
|
2029 |
|
|
*y = y1;
|
2030 |
|
|
*w = x2 - x1;
|
2031 |
|
|
*h = y2 - y1;
|
2032 |
|
|
}
|
2033 |
|
|
|
2034 |
bertho |
1.19 |
static int branch_intersects(int top, int bottom, int left, branch_t *b)
|
2035 |
bertho |
1.7 |
{
|
2036 |
|
|
int br = b->cx + b->tw/2;
|
2037 |
|
|
int bt = b->y - conf.branch_connect - conf.branch_margin/2;
|
2038 |
|
|
int bb = b->y + b->th + conf.branch_margin/2;
|
2039 |
|
|
return !(bt > bottom || bb < top || br >= left);
|
2040 |
|
|
}
|
2041 |
|
|
|
2042 |
bertho |
1.25 |
static int branch_intersects_lr(int left, int right, int top, branch_t *b)
|
2043 |
|
|
{
|
2044 |
|
|
int bt = b->y + b->th/2;
|
2045 |
|
|
int bl = b->cx - conf.branch_connect - conf.branch_margin/2;
|
2046 |
|
|
int br = b->cx + b->tw + conf.branch_margin/2;
|
2047 |
|
|
return !(bl > right || br < left || bt >= top);
|
2048 |
|
|
}
|
2049 |
|
|
|
2050 |
bertho |
1.19 |
static int kern_branch(rcsfile_t *rcs, branch_t *b)
|
2051 |
bertho |
1.7 |
{
|
2052 |
|
|
int left = b->cx - b->tw/2;
|
2053 |
|
|
int top = b->y - conf.branch_connect - conf.branch_margin/2;
|
2054 |
|
|
int bottom = b->y + b->th + conf.branch_margin/2;
|
2055 |
|
|
int i;
|
2056 |
|
|
int xpos = 0;
|
2057 |
|
|
|
2058 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2059 |
|
|
{
|
2060 |
|
|
branch_t *bp = rcs->branches[i];
|
2061 |
|
|
if(bp == b)
|
2062 |
|
|
continue;
|
2063 |
|
|
if(branch_intersects(top, bottom, left, bp))
|
2064 |
|
|
{
|
2065 |
|
|
int m = bp->cx + bp->tw/2 + conf.branch_margin;
|
2066 |
|
|
if(m > xpos)
|
2067 |
|
|
xpos = m;
|
2068 |
|
|
}
|
2069 |
|
|
}
|
2070 |
|
|
if(xpos && (b->cx - b->tw/2) - xpos > 0)
|
2071 |
|
|
{
|
2072 |
|
|
move_branch(b, xpos - (b->cx - b->tw/2), 0);
|
2073 |
|
|
return 1;
|
2074 |
|
|
}
|
2075 |
|
|
return 0;
|
2076 |
|
|
}
|
2077 |
|
|
|
2078 |
bertho |
1.25 |
static int kern_branch_lr(rcsfile_t *rcs, branch_t *b)
|
2079 |
|
|
{
|
2080 |
|
|
int top = b->y - b->th/2;
|
2081 |
|
|
int left = b->cx - conf.branch_connect - conf.branch_margin/2;
|
2082 |
|
|
int right = b->cx + b->tw + conf.branch_margin/2;
|
2083 |
|
|
int i;
|
2084 |
|
|
int ypos = 0;
|
2085 |
|
|
|
2086 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2087 |
|
|
{
|
2088 |
|
|
branch_t *bp = rcs->branches[i];
|
2089 |
|
|
if(bp == b)
|
2090 |
|
|
continue;
|
2091 |
|
|
if(branch_intersects_lr(left, right, top, bp))
|
2092 |
|
|
{
|
2093 |
|
|
int m = bp->y + bp->th/2 + conf.branch_margin;
|
2094 |
|
|
if(m > ypos)
|
2095 |
|
|
ypos = m;
|
2096 |
|
|
}
|
2097 |
|
|
}
|
2098 |
|
|
if(ypos && (b->y - b->th/2) - ypos > 0)
|
2099 |
|
|
{
|
2100 |
|
|
move_branch(b, 0, ypos - (b->y - b->th/2));
|
2101 |
|
|
return 1;
|
2102 |
|
|
}
|
2103 |
|
|
return 0;
|
2104 |
|
|
}
|
2105 |
|
|
|
2106 |
bertho |
1.19 |
static int kern_tree(rcsfile_t *rcs)
|
2107 |
bertho |
1.18 |
{
|
2108 |
|
|
int i;
|
2109 |
|
|
int moved;
|
2110 |
bertho |
1.19 |
int safeguard;
|
2111 |
|
|
int totalmoved = 0;
|
2112 |
|
|
for(moved = 1, safeguard = LOOPSAFEGUARD; moved && safeguard; safeguard--)
|
2113 |
bertho |
1.18 |
{
|
2114 |
|
|
moved = 0;
|
2115 |
|
|
for(i = 1; i < rcs->nbranches; i++)
|
2116 |
|
|
{
|
2117 |
bertho |
1.25 |
if(conf.left_right)
|
2118 |
|
|
moved += kern_branch_lr(rcs, rcs->branches[i]);
|
2119 |
|
|
else
|
2120 |
|
|
moved += kern_branch(rcs, rcs->branches[i]);
|
2121 |
bertho |
1.18 |
}
|
2122 |
bertho |
1.19 |
totalmoved += moved;
|
2123 |
bertho |
1.18 |
#ifdef DEBUG
|
2124 |
|
|
fprintf(stderr, "kern_tree: moved=%d\n", moved);
|
2125 |
|
|
#endif
|
2126 |
|
|
}
|
2127 |
bertho |
1.19 |
if(!quiet && !safeguard)
|
2128 |
|
|
fprintf(stderr, "kern_tree: safeguard terminated possible infinite loop; please report.\n");
|
2129 |
|
|
return totalmoved;
|
2130 |
|
|
}
|
2131 |
|
|
|
2132 |
|
|
static int index_of_revision(revision_t *r)
|
2133 |
|
|
{
|
2134 |
|
|
branch_t *b = r->branch;
|
2135 |
|
|
int i;
|
2136 |
|
|
for(i = 0; i < b->nrevs; i++)
|
2137 |
|
|
{
|
2138 |
|
|
if(r == b->revs[i])
|
2139 |
|
|
return i;
|
2140 |
|
|
}
|
2141 |
|
|
fprintf(stderr, "index_of_revision: Cannot find revision in branch\n");
|
2142 |
|
|
return 0;
|
2143 |
bertho |
1.18 |
}
|
2144 |
|
|
|
2145 |
bertho |
1.19 |
static void branch_bbox(branch_t *br, int *l, int *r, int *t, int *b)
|
2146 |
|
|
{
|
2147 |
|
|
if(l) *l = br->cx - br->tw/2;
|
2148 |
|
|
if(r) *r = br->cx + br->tw/2;
|
2149 |
|
|
if(t) *t = br->y;
|
2150 |
bertho |
1.32 |
if(b) *b = br->y + br->th + ((conf.branch_dupbox && br->nrevs) ? conf.rev_minline + br->h : 0);
|
2151 |
bertho |
1.19 |
}
|
2152 |
|
|
|
2153 |
|
|
static void branch_ext_bbox(branch_t *br, int *l, int *r, int *t, int *b)
|
2154 |
|
|
{
|
2155 |
|
|
int extra = conf.branch_margin & 1; /* Correct +/-1 error on div 2 */
|
2156 |
|
|
branch_bbox(br, l, r, t, b);
|
2157 |
|
|
if(l) *l -= conf.branch_margin/2;
|
2158 |
|
|
if(r) *r += conf.branch_margin/2 + extra;
|
2159 |
|
|
if(t) *t -= conf.branch_connect + conf.branch_margin/2;
|
2160 |
|
|
if(b) *b += conf.branch_margin/2 + extra;
|
2161 |
|
|
}
|
2162 |
|
|
|
2163 |
|
|
static int branch_distance(branch_t *br1, branch_t *br2)
|
2164 |
|
|
{
|
2165 |
|
|
int l1, r1, t1, b1;
|
2166 |
|
|
int l2, r2, t2, b2;
|
2167 |
|
|
assert(br1 != NULL);
|
2168 |
|
|
assert(br2 != NULL);
|
2169 |
|
|
branch_bbox(br1, &l1, &r1, NULL, NULL);
|
2170 |
|
|
branch_bbox(br2, &l2, &r2, NULL, NULL);
|
2171 |
|
|
branch_ext_bbox(br1, NULL, NULL, &t1, &b1);
|
2172 |
|
|
branch_ext_bbox(br2, NULL, NULL, &t2, &b2);
|
2173 |
|
|
/* Return:
|
2174 |
|
|
* - 0 if branches have no horizontal overlap
|
2175 |
|
|
* - positive if b1 is left of b2
|
2176 |
|
|
* - negative if b2 is left of b1
|
2177 |
|
|
*/
|
2178 |
|
|
if((t1 > t2 && t1 < b2) || (b1 > t2 && b1 < b2))
|
2179 |
|
|
return l1 < l2 ? l2 - r1 : -(l1 - r2);
|
2180 |
|
|
else
|
2181 |
|
|
return 0;
|
2182 |
|
|
}
|
2183 |
|
|
|
2184 |
|
|
static int space_needed(branch_t *br1, branch_t *br2)
|
2185 |
|
|
{
|
2186 |
|
|
int t1, b1;
|
2187 |
|
|
int t2, b2;
|
2188 |
|
|
assert(br1 != NULL);
|
2189 |
|
|
assert(br2 != NULL);
|
2190 |
|
|
assert(br1->cx < br2->cx); /* br1 must be left of br2 */
|
2191 |
|
|
branch_ext_bbox(br1, NULL, NULL, &t1, &b1);
|
2192 |
|
|
branch_ext_bbox(br2, NULL, NULL, &t2, &b2);
|
2193 |
|
|
/* Return:
|
2194 |
|
|
* - positive if top br1 is located lower than br2
|
2195 |
|
|
* - negatve is top br2 is located lower than br1
|
2196 |
|
|
*/
|
2197 |
|
|
if(t1 > t2)
|
2198 |
|
|
return -(t1 - b2);
|
2199 |
|
|
else
|
2200 |
|
|
return t2 - b1;
|
2201 |
|
|
}
|
2202 |
|
|
|
2203 |
|
|
static void move_yr_branch(branch_t *b, int dy)
|
2204 |
bertho |
1.18 |
{
|
2205 |
|
|
int i, j;
|
2206 |
|
|
#ifdef DEBUG
|
2207 |
bertho |
1.23 |
/* fprintf(stderr, "move_yr_branch: b=%s, dy=%d\n", b->branch->branch, dy);*/
|
2208 |
bertho |
1.18 |
#endif
|
2209 |
bertho |
1.19 |
b->y += dy;
|
2210 |
|
|
for(i = 0; i < b->nrevs; i++)
|
2211 |
bertho |
1.18 |
{
|
2212 |
bertho |
1.19 |
b->revs[i]->y += dy;
|
2213 |
|
|
for(j = 0; j < b->revs[i]->nbranches; j++)
|
2214 |
bertho |
1.18 |
{
|
2215 |
bertho |
1.19 |
#ifdef DEBUG
|
2216 |
bertho |
1.23 |
/* fprintf(stderr, ".");*/
|
2217 |
bertho |
1.19 |
#endif
|
2218 |
|
|
move_yr_branch(b->revs[i]->branches[j], dy);
|
2219 |
bertho |
1.18 |
}
|
2220 |
|
|
}
|
2221 |
|
|
}
|
2222 |
|
|
|
2223 |
bertho |
1.19 |
static void move_trunk(revision_t *r, int dy)
|
2224 |
bertho |
1.18 |
{
|
2225 |
bertho |
1.19 |
int i, j;
|
2226 |
bertho |
1.18 |
branch_t *b = r->branch;
|
2227 |
bertho |
1.19 |
b->th += dy;
|
2228 |
|
|
for(i = index_of_revision(r); i < b->nrevs; i++)
|
2229 |
bertho |
1.18 |
{
|
2230 |
bertho |
1.19 |
#ifdef DEBUG
|
2231 |
|
|
fprintf(stderr, "move_trunk: start %s, moving %s by %d (b's %d)\n", r->rev->rev, b->revs[i]->rev->rev, dy, b->revs[i]->nbranches);
|
2232 |
|
|
#endif
|
2233 |
|
|
b->revs[i]->y += dy;
|
2234 |
|
|
for(j = 0; j < b->revs[i]->nbranches; j++)
|
2235 |
|
|
{
|
2236 |
|
|
move_yr_branch(b->revs[i]->branches[j], dy);
|
2237 |
|
|
}
|
2238 |
bertho |
1.18 |
}
|
2239 |
|
|
}
|
2240 |
|
|
|
2241 |
bertho |
1.19 |
static int space_below(rcsfile_t *rcs, revision_t *r)
|
2242 |
bertho |
1.18 |
{
|
2243 |
bertho |
1.19 |
int i, j;
|
2244 |
|
|
int bl, br, bb;
|
2245 |
bertho |
1.18 |
int space = INT_MAX;
|
2246 |
bertho |
1.19 |
branch_t *b = r->branch;
|
2247 |
|
|
branch_t *minb = NULL;
|
2248 |
|
|
|
2249 |
|
|
branch_ext_bbox(b, &bl, &br, NULL, &bb);
|
2250 |
bertho |
1.18 |
for(i = 0; i < rcs->nbranches; i++)
|
2251 |
|
|
{
|
2252 |
bertho |
1.19 |
int tbl, tbr, tbt;
|
2253 |
bertho |
1.18 |
branch_t *tb = rcs->branches[i];
|
2254 |
bertho |
1.19 |
branch_ext_bbox(tb, &tbl, &tbr, &tbt, NULL);
|
2255 |
bertho |
1.18 |
if(tb == b)
|
2256 |
|
|
continue;
|
2257 |
bertho |
1.19 |
if(tbt > bb) /* Must be below our branch */
|
2258 |
bertho |
1.18 |
{
|
2259 |
bertho |
1.19 |
if(tb->branchpoint) /* Take account for the horiz connector */
|
2260 |
|
|
tbl = tb->branchpoint->cx + tb->branchpoint->branch->tw/2;
|
2261 |
|
|
if((bl >= tbl && bl <= tbr) || (br <= tbr && br >= tbl))
|
2262 |
bertho |
1.18 |
{
|
2263 |
bertho |
1.19 |
int s = tbt - bb - conf.branch_connect;
|
2264 |
|
|
if(s < space)
|
2265 |
bertho |
1.18 |
{
|
2266 |
bertho |
1.19 |
space = s;
|
2267 |
|
|
minb = tb;
|
2268 |
bertho |
1.18 |
}
|
2269 |
|
|
}
|
2270 |
|
|
}
|
2271 |
|
|
}
|
2272 |
bertho |
1.19 |
if(b->branchpoint)
|
2273 |
|
|
{
|
2274 |
|
|
for(i = index_of_revision(r); i < b->nrevs; i++)
|
2275 |
|
|
{
|
2276 |
|
|
for(j = 0; j < b->revs[i]->nbranches; j++)
|
2277 |
|
|
{
|
2278 |
|
|
int s = space_below(rcs, b->revs[i]->branches[j]->revs[0]);
|
2279 |
|
|
if(s < space)
|
2280 |
|
|
space = s;
|
2281 |
|
|
}
|
2282 |
|
|
}
|
2283 |
|
|
}
|
2284 |
|
|
#ifdef DEBUG
|
2285 |
|
|
fprintf(stderr, "space_below: from %s have %d to %s\n", b->branch->branch, space, minb ? minb->branch->branch : "<recursed>");
|
2286 |
|
|
#endif
|
2287 |
bertho |
1.18 |
return space;
|
2288 |
|
|
}
|
2289 |
|
|
|
2290 |
bertho |
1.19 |
static int space_available(rcsfile_t *rcs, branch_t *colbr, branch_t *tagbr, int *nl, revision_t **bpcommon)
|
2291 |
bertho |
1.18 |
{
|
2292 |
bertho |
1.19 |
int i;
|
2293 |
|
|
int space = 0;
|
2294 |
|
|
int nlinks = 0;
|
2295 |
|
|
revision_t *r;
|
2296 |
|
|
branch_t *b;
|
2297 |
|
|
branch_t *ancestor;
|
2298 |
|
|
revision_t *branchpoint;
|
2299 |
|
|
|
2300 |
|
|
if(!tagbr->branchpoint || !colbr->branchpoint)
|
2301 |
bertho |
1.18 |
{
|
2302 |
bertho |
1.19 |
if(!quiet)
|
2303 |
|
|
fprintf(stderr, "space_available: Trying to stretch the top?\n");
|
2304 |
|
|
return 0;
|
2305 |
bertho |
1.18 |
}
|
2306 |
bertho |
1.19 |
|
2307 |
|
|
r = colbr->branchpoint;
|
2308 |
|
|
b = r->branch;
|
2309 |
|
|
branchpoint = tagbr->branchpoint;
|
2310 |
|
|
ancestor = branchpoint->branch;
|
2311 |
|
|
assert(b != NULL);
|
2312 |
|
|
assert(ancestor != NULL);
|
2313 |
|
|
|
2314 |
|
|
while(1)
|
2315 |
bertho |
1.18 |
{
|
2316 |
bertho |
1.19 |
int s;
|
2317 |
|
|
int rtag = b == ancestor ? index_of_revision(branchpoint)+1 : 0;
|
2318 |
|
|
for(i = index_of_revision(r); i >= rtag; i--)
|
2319 |
bertho |
1.18 |
{
|
2320 |
bertho |
1.19 |
if(i > 0)
|
2321 |
|
|
s = b->revs[i]->y - (b->revs[i-1]->y + b->revs[i-1]->h);
|
2322 |
|
|
else
|
2323 |
|
|
s = b->revs[i]->y - (b->y + b->h);
|
2324 |
|
|
if(s < conf.rev_maxline)
|
2325 |
|
|
{
|
2326 |
|
|
space += conf.rev_maxline - s;
|
2327 |
|
|
nlinks++;
|
2328 |
|
|
}
|
2329 |
bertho |
1.18 |
}
|
2330 |
bertho |
1.19 |
s = space_below(rcs, r);
|
2331 |
|
|
if(s < space)
|
2332 |
|
|
space = s;
|
2333 |
|
|
#ifdef DEBUG
|
2334 |
|
|
if(space < 0)
|
2335 |
|
|
return -1;
|
2336 |
|
|
#endif
|
2337 |
|
|
if(b == ancestor)
|
2338 |
|
|
break;
|
2339 |
|
|
r = b->branchpoint;
|
2340 |
|
|
if(!r)
|
2341 |
|
|
{
|
2342 |
|
|
/* Not a common ancestor */
|
2343 |
|
|
r = colbr->branchpoint;
|
2344 |
|
|
b = r->branch;
|
2345 |
|
|
branchpoint = ancestor->branchpoint;
|
2346 |
|
|
if(!branchpoint)
|
2347 |
|
|
{
|
2348 |
|
|
if(!quiet)
|
2349 |
|
|
fprintf(stderr, "space_available: No common ancestor?\n");
|
2350 |
|
|
return 0;
|
2351 |
|
|
}
|
2352 |
|
|
ancestor = branchpoint->branch;
|
2353 |
|
|
assert(ancestor != NULL);
|
2354 |
|
|
nlinks = 0;
|
2355 |
|
|
space = 0;
|
2356 |
|
|
continue; /* Restart with a new ancestor */
|
2357 |
|
|
}
|
2358 |
|
|
b = r->branch;
|
2359 |
|
|
}
|
2360 |
|
|
if(nl)
|
2361 |
|
|
*nl = nlinks; /* Return the number of links that can stretch */
|
2362 |
|
|
if(bpcommon)
|
2363 |
|
|
*bpcommon = branchpoint; /* Return the ancestral branchpoint on the common branch */
|
2364 |
|
|
return space;
|
2365 |
bertho |
1.18 |
}
|
2366 |
|
|
|
2367 |
bertho |
1.19 |
static int stretch_branches(rcsfile_t *rcs, branch_t *br1, branch_t *br2, int totalstretch)
|
2368 |
bertho |
1.18 |
{
|
2369 |
bertho |
1.19 |
revision_t *r;
|
2370 |
|
|
revision_t *bpcommon = NULL;
|
2371 |
|
|
branch_t *ancestor = NULL;
|
2372 |
|
|
branch_t *b;
|
2373 |
bertho |
1.18 |
int i;
|
2374 |
bertho |
1.19 |
int space;
|
2375 |
|
|
int nlinks;
|
2376 |
|
|
int dy;
|
2377 |
|
|
int rest;
|
2378 |
|
|
|
2379 |
|
|
space = space_available(rcs, br1, br2, &nlinks, &bpcommon);
|
2380 |
|
|
if(bpcommon)
|
2381 |
|
|
ancestor = bpcommon->branch;
|
2382 |
|
|
|
2383 |
|
|
#ifdef DEBUG
|
2384 |
|
|
if(space == -1)
|
2385 |
|
|
return 0;
|
2386 |
|
|
fprintf(stderr, "stretch_branches: space available %d over %d links common %s\n", space, nlinks, ancestor->branch->branch);
|
2387 |
|
|
#endif
|
2388 |
|
|
if(space < totalstretch)
|
2389 |
|
|
return 0;
|
2390 |
|
|
|
2391 |
|
|
dy = totalstretch / nlinks;
|
2392 |
|
|
rest = totalstretch - dy * nlinks;
|
2393 |
|
|
|
2394 |
|
|
r = br1->branchpoint;
|
2395 |
|
|
b = r->branch;
|
2396 |
|
|
while(1)
|
2397 |
bertho |
1.18 |
{
|
2398 |
bertho |
1.19 |
int rtag = b == ancestor ? index_of_revision(bpcommon)+1 : 0;
|
2399 |
|
|
for(i = index_of_revision(r); i >= rtag; i--)
|
2400 |
|
|
{
|
2401 |
|
|
int s, q;
|
2402 |
|
|
if(i > 0)
|
2403 |
|
|
s = b->revs[i]->y - (b->revs[i-1]->y + b->revs[i-1]->h);
|
2404 |
|
|
else
|
2405 |
|
|
s = b->revs[i]->y - (b->y + b->h);
|
2406 |
|
|
q = conf.rev_maxline - s;
|
2407 |
|
|
if(q > 0)
|
2408 |
|
|
{
|
2409 |
|
|
int d = rest ? rest/nlinks+1 : 0;
|
2410 |
|
|
if(q >= dy+d)
|
2411 |
|
|
{
|
2412 |
|
|
move_trunk(b->revs[i], dy+d);
|
2413 |
|
|
}
|
2414 |
|
|
else
|
2415 |
|
|
{
|
2416 |
|
|
move_trunk(b->revs[i], q);
|
2417 |
|
|
rest += dy+d - q;
|
2418 |
|
|
}
|
2419 |
|
|
rest -= d;
|
2420 |
|
|
nlinks--;
|
2421 |
|
|
}
|
2422 |
|
|
}
|
2423 |
|
|
if(b == ancestor)
|
2424 |
|
|
break;
|
2425 |
|
|
r = b->branchpoint;
|
2426 |
|
|
assert(r != NULL); /* else 'space_available' wouldn't have returned positively */
|
2427 |
|
|
b = r->branch;
|
2428 |
bertho |
1.18 |
}
|
2429 |
bertho |
1.19 |
return 1;
|
2430 |
bertho |
1.18 |
}
|
2431 |
|
|
|
2432 |
bertho |
1.19 |
static branch_t *find_collision_branch(rcsfile_t *rcs, branch_t *b)
|
2433 |
bertho |
1.18 |
{
|
2434 |
|
|
int i;
|
2435 |
bertho |
1.19 |
int dist = INT_MAX;
|
2436 |
|
|
branch_t *col = NULL;
|
2437 |
|
|
|
2438 |
bertho |
1.18 |
for(i = 0; i < rcs->nbranches; i++)
|
2439 |
|
|
{
|
2440 |
bertho |
1.19 |
int t = branch_distance(rcs->branches[i], b);
|
2441 |
|
|
if(t > 0 && t < dist)
|
2442 |
bertho |
1.18 |
{
|
2443 |
bertho |
1.19 |
dist = t;
|
2444 |
|
|
col = rcs->branches[i];
|
2445 |
bertho |
1.18 |
}
|
2446 |
|
|
}
|
2447 |
bertho |
1.19 |
return col;
|
2448 |
bertho |
1.18 |
}
|
2449 |
|
|
|
2450 |
bertho |
1.19 |
void auto_stretch(rcsfile_t *rcs)
|
2451 |
bertho |
1.18 |
{
|
2452 |
bertho |
1.19 |
int i;
|
2453 |
|
|
int safeguard;
|
2454 |
bertho |
1.18 |
|
2455 |
bertho |
1.19 |
for(i = 0, safeguard = LOOPSAFEGUARD; i < rcs->nbranches && safeguard; i++)
|
2456 |
bertho |
1.18 |
{
|
2457 |
bertho |
1.19 |
int bl, pr;
|
2458 |
|
|
branch_t *b = rcs->branches[i];
|
2459 |
|
|
if(!b->branchpoint)
|
2460 |
|
|
continue;
|
2461 |
|
|
branch_bbox(b, &bl, NULL, NULL, NULL);
|
2462 |
|
|
branch_bbox(b->branchpoint->branch, NULL, &pr, NULL, NULL);
|
2463 |
|
|
if(bl - conf.branch_margin - pr > 0)
|
2464 |
bertho |
1.18 |
{
|
2465 |
bertho |
1.19 |
branch_t *col;
|
2466 |
bertho |
1.18 |
int spaceneeded;
|
2467 |
bertho |
1.19 |
/* There is a potential to move branch b further left.
|
2468 |
|
|
* All branches obstructing this one from moving further
|
2469 |
|
|
* left must be originating from revisions below
|
2470 |
|
|
* b->branchpoint until a common ancester.
|
2471 |
|
|
* So, we search all branches for a branch that lies left
|
2472 |
|
|
* of b and is closest to b. This is then the collission
|
2473 |
|
|
* branch that needs to be moved.
|
2474 |
|
|
*/
|
2475 |
|
|
col = find_collision_branch(rcs, b);
|
2476 |
|
|
if(!col)
|
2477 |
bertho |
1.18 |
continue;
|
2478 |
bertho |
1.19 |
spaceneeded = space_needed(col, b);
|
2479 |
|
|
if(spaceneeded < 0)
|
2480 |
|
|
continue;
|
2481 |
|
|
#ifdef DEBUG
|
2482 |
|
|
fprintf(stderr, "auto_stretch: %s collides %s need %d\n", b->branch->branch, col->branch->branch, spaceneeded);
|
2483 |
|
|
#endif
|
2484 |
|
|
/* Trace the collision branch back to find the common ancester
|
2485 |
|
|
* of both col and b. All revisions encountered while traversing
|
2486 |
|
|
* backwards must be stretched, including all revisions on the
|
2487 |
|
|
* common ancester from where the branches sprout.
|
2488 |
|
|
*/
|
2489 |
|
|
if(stretch_branches(rcs, col, b, spaceneeded))
|
2490 |
bertho |
1.18 |
{
|
2491 |
bertho |
1.19 |
if(kern_tree(rcs))
|
2492 |
|
|
{
|
2493 |
|
|
/* Restart the process because movement can
|
2494 |
|
|
* cause more movement.
|
2495 |
|
|
*/
|
2496 |
|
|
i = 0 - 1; /* -1 for the i++ of the loop */
|
2497 |
|
|
safeguard--; /* Prevent infinite loop, just in case */
|
2498 |
|
|
}
|
2499 |
bertho |
1.23 |
/*return;*/
|
2500 |
bertho |
1.18 |
}
|
2501 |
|
|
}
|
2502 |
|
|
}
|
2503 |
bertho |
1.19 |
if(!quiet && !safeguard)
|
2504 |
|
|
fprintf(stderr, "auto_stretch: safeguard terminated possible infinite loop; please report.\n");
|
2505 |
bertho |
1.18 |
}
|
2506 |
|
|
|
2507 |
bertho |
1.32 |
static void fold_branch(rcsfile_t *rcs, revision_t *r)
|
2508 |
|
|
{
|
2509 |
|
|
int i, j;
|
2510 |
|
|
branch_t *btag = NULL;
|
2511 |
|
|
|
2512 |
|
|
if(r->nbranches < 2)
|
2513 |
|
|
return; /* Should not happen... */
|
2514 |
|
|
|
2515 |
|
|
for(i = 0; i < r->nbranches; i++)
|
2516 |
|
|
{
|
2517 |
|
|
branch_t *b = r->branches[i];
|
2518 |
|
|
if(!b->nrevs && b->ntags < 2)
|
2519 |
|
|
{
|
2520 |
|
|
/* No commits in this branch and no duplicate tags */
|
2521 |
|
|
if(!btag)
|
2522 |
|
|
btag = b;
|
2523 |
|
|
else
|
2524 |
|
|
{
|
2525 |
|
|
/* We have consecutive empty branches, fold */
|
2526 |
|
|
b->folded = 1;
|
2527 |
|
|
for(j = 0; j < rcs->nbranches; j++)
|
2528 |
|
|
{
|
2529 |
|
|
if(b == rcs->branches[j])
|
2530 |
|
|
{
|
2531 |
|
|
/* Zap the branch from the admin */
|
2532 |
|
|
memmove(&rcs->branches[j],
|
2533 |
|
|
&rcs->branches[j+1],
|
2534 |
|
|
(rcs->nbranches - j - 1)*sizeof(rcs->branches[0]));
|
2535 |
|
|
rcs->nbranches--;
|
2536 |
|
|
break;
|
2537 |
|
|
}
|
2538 |
|
|
|
2539 |
|
|
}
|
2540 |
|
|
memmove(&r->branches[i], &r->branches[i+1], (r->nbranches - i - 1)*sizeof(r->branches[0]));
|
2541 |
|
|
r->nbranches--;
|
2542 |
|
|
i--; /* We have one less now */
|
2543 |
|
|
|
2544 |
|
|
/* Add to the fold-list */
|
2545 |
|
|
btag->folds = xrealloc(btag->folds, (btag->nfolds+1) * sizeof(btag->folds[0]));
|
2546 |
|
|
btag->folds[btag->nfolds] = b;
|
2547 |
|
|
btag->nfolds++;
|
2548 |
|
|
}
|
2549 |
|
|
}
|
2550 |
|
|
else
|
2551 |
|
|
{
|
2552 |
bertho |
1.33 |
if(!conf.branch_foldall)
|
2553 |
|
|
btag = NULL; /* Start a new box */
|
2554 |
bertho |
1.32 |
/* Recursively fold sub-branches */
|
2555 |
|
|
for(j = 0; j < b->nrevs; j++)
|
2556 |
|
|
fold_branch(rcs, b->revs[j]);
|
2557 |
|
|
}
|
2558 |
|
|
}
|
2559 |
|
|
}
|
2560 |
|
|
|
2561 |
bertho |
1.7 |
void make_layout(rcsfile_t *rcs)
|
2562 |
bertho |
1.1 |
{
|
2563 |
|
|
int i, j;
|
2564 |
|
|
int x, y;
|
2565 |
|
|
int w, h;
|
2566 |
|
|
int w2;
|
2567 |
|
|
|
2568 |
bertho |
1.16 |
/* Remove all unwanted revisions */
|
2569 |
|
|
if(conf.strip_untagged)
|
2570 |
|
|
{
|
2571 |
bertho |
1.21 |
int fr = conf.strip_first_rev ? 0 : 1;
|
2572 |
bertho |
1.16 |
for(i = 0; i < rcs->nbranches; i++)
|
2573 |
|
|
{
|
2574 |
|
|
branch_t *bp = rcs->branches[i];
|
2575 |
bertho |
1.18 |
for(j = fr; j < bp->nrevs-1; j++)
|
2576 |
bertho |
1.16 |
{
|
2577 |
|
|
if(!bp->revs[j]->ntags && !bp->revs[j]->nbranches)
|
2578 |
|
|
{
|
2579 |
|
|
memmove(&bp->revs[j], &bp->revs[j+1], (bp->nrevs-j-1) * sizeof(bp->revs[0]));
|
2580 |
|
|
bp->nrevs--;
|
2581 |
bertho |
1.17 |
bp->revs[j]->stripped = 1;
|
2582 |
bertho |
1.16 |
j--;
|
2583 |
|
|
}
|
2584 |
|
|
}
|
2585 |
|
|
}
|
2586 |
|
|
}
|
2587 |
|
|
|
2588 |
bertho |
1.32 |
/* Fold all empty branched in one box on the same branchpoint */
|
2589 |
|
|
if(conf.branch_fold)
|
2590 |
|
|
{
|
2591 |
|
|
for(i = 0; i < rcs->branches[0]->nrevs; i++)
|
2592 |
|
|
{
|
2593 |
|
|
if(rcs->branches[0]->revs[i]->nbranches > 1)
|
2594 |
|
|
fold_branch(rcs, rcs->branches[0]->revs[i]);
|
2595 |
bertho |
1.40 |
}
|
2596 |
|
|
}
|
2597 |
|
|
|
2598 |
|
|
/* Remove all unwanted tags */
|
2599 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2600 |
|
|
{
|
2601 |
|
|
branch_t *bp = rcs->branches[i];
|
2602 |
|
|
for(j = 0; j < bp->nrevs; j++)
|
2603 |
|
|
{
|
2604 |
|
|
revision_t *r = bp->revs[j];
|
2605 |
|
|
int k;
|
2606 |
|
|
for(k = 0; k < r->ntags; k++)
|
2607 |
|
|
{
|
2608 |
|
|
if(r->tags[k]->ignore)
|
2609 |
|
|
{
|
2610 |
|
|
memmove(&r->tags[k], &r->tags[k+1], (r->ntags-k-1) * sizeof(r->tags[0]));
|
2611 |
|
|
r->ntags--;
|
2612 |
|
|
k--;
|
2613 |
|
|
}
|
2614 |
|
|
}
|
2615 |
bertho |
1.32 |
}
|
2616 |
|
|
}
|
2617 |
|
|
|
2618 |
bertho |
1.1 |
/* Calculate the box-sizes of the revisions */
|
2619 |
bertho |
1.7 |
for(i = 0; i < rcs->nsrev; i++)
|
2620 |
bertho |
1.1 |
{
|
2621 |
|
|
revision_t *rp;
|
2622 |
|
|
int w;
|
2623 |
|
|
int h;
|
2624 |
bertho |
1.7 |
rp = rcs->srev[i];
|
2625 |
bertho |
1.9 |
rp->revtext = expand_string(conf.rev_text, rcs, rp, rp->rev, NULL, rp->ntags ? rp->tags[0] : NULL);
|
2626 |
|
|
w = get_swidth(rp->revtext, &conf.rev_text_font);
|
2627 |
|
|
j = get_swidth(rp->rev->rev, &conf.rev_font);
|
2628 |
|
|
if(j > w)
|
2629 |
|
|
w = j;
|
2630 |
|
|
h = get_sheight(rp->revtext, &conf.rev_text_font) + get_sheight(rp->rev->rev, &conf.rev_font);
|
2631 |
bertho |
1.1 |
for(j = 0; j < rp->ntags; j++)
|
2632 |
|
|
{
|
2633 |
|
|
int ww = get_swidth(rp->tags[j]->tag, &conf.tag_font);
|
2634 |
bertho |
1.31 |
int th;
|
2635 |
bertho |
1.1 |
if(ww > w) w = ww;
|
2636 |
bertho |
1.31 |
th = get_sheight(rp->tags[j]->tag, &conf.tag_font) + conf.rev_separator;
|
2637 |
|
|
rp->tags[j]->yofs = h + th/2 + conf.rev_tspace;
|
2638 |
|
|
h += th;
|
2639 |
bertho |
1.1 |
}
|
2640 |
|
|
rp->w = w + conf.rev_lspace + conf.rev_rspace;
|
2641 |
|
|
rp->h = h + conf.rev_tspace + conf.rev_bspace;
|
2642 |
|
|
}
|
2643 |
|
|
|
2644 |
|
|
/* Calculate the box-sizes of the branches */
|
2645 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2646 |
|
|
{
|
2647 |
|
|
branch_t *bp = rcs->branches[i];
|
2648 |
|
|
int w;
|
2649 |
|
|
int h;
|
2650 |
bertho |
1.32 |
if(!bp->nfolds)
|
2651 |
|
|
{
|
2652 |
|
|
w = get_swidth(bp->branch->branch, &conf.branch_font);
|
2653 |
|
|
h = get_sheight(bp->branch->branch, &conf.branch_font);
|
2654 |
|
|
for(j = 0; j < bp->ntags; j++)
|
2655 |
|
|
{
|
2656 |
|
|
int ww = get_swidth(bp->tags[j]->tag, &conf.branch_tag_font);
|
2657 |
|
|
if(ww > w) w = ww;
|
2658 |
|
|
h += get_sheight(bp->tags[j]->tag, &conf.branch_tag_font);
|
2659 |
|
|
}
|
2660 |
|
|
}
|
2661 |
|
|
else
|
2662 |
bertho |
1.1 |
{
|
2663 |
bertho |
1.32 |
int h1, h2;
|
2664 |
|
|
int w1, w2;
|
2665 |
|
|
int fw;
|
2666 |
|
|
w1 = get_swidth(bp->branch->branch, &conf.branch_font);
|
2667 |
|
|
w1 += get_swidth(" ", &conf.branch_font);
|
2668 |
|
|
w2 = get_swidth(bp->tags[0]->tag, &conf.branch_tag_font);
|
2669 |
|
|
fw = w1;
|
2670 |
|
|
w = w1 + w2;
|
2671 |
|
|
h1 = get_sheight(bp->branch->branch, &conf.branch_font);
|
2672 |
|
|
h2 = get_sheight(bp->tags[0]->tag, &conf.branch_tag_font);
|
2673 |
|
|
h = MAX(h1, h2);
|
2674 |
|
|
for(j = 0; j < bp->nfolds; j++)
|
2675 |
|
|
{
|
2676 |
|
|
w1 = get_swidth(bp->folds[j]->branch->branch, &conf.branch_font);
|
2677 |
|
|
w1 += get_swidth(" ", &conf.branch_font);
|
2678 |
|
|
w2 = get_swidth(bp->folds[j]->tags[0]->tag, &conf.branch_tag_font);
|
2679 |
|
|
if(w1 > fw)
|
2680 |
|
|
fw = w1;
|
2681 |
|
|
if(w1 + w2 > w)
|
2682 |
|
|
w = w1 + w2;
|
2683 |
|
|
h1 = get_sheight(bp->folds[j]->branch->branch, &conf.branch_font);
|
2684 |
|
|
h2 = get_sheight(bp->folds[j]->tags[0]->tag, &conf.branch_tag_font);
|
2685 |
|
|
h += MAX(h1, h2);
|
2686 |
|
|
}
|
2687 |
|
|
bp->fw = fw;
|
2688 |
bertho |
1.1 |
}
|
2689 |
|
|
w += conf.branch_lspace + conf.branch_rspace;
|
2690 |
|
|
h += conf.branch_tspace + conf.branch_bspace;
|
2691 |
|
|
bp->w = w;
|
2692 |
|
|
bp->h = h;
|
2693 |
bertho |
1.25 |
if(conf.left_right)
|
2694 |
|
|
{
|
2695 |
|
|
for(j = 0; j < bp->nrevs; j++)
|
2696 |
|
|
{
|
2697 |
|
|
if(bp->revs[j]->h > h)
|
2698 |
|
|
h = bp->revs[j]->h;
|
2699 |
|
|
w += bp->revs[j]->w + conf.rev_minline;
|
2700 |
|
|
}
|
2701 |
bertho |
1.32 |
if(conf.branch_dupbox && bp->nrevs)
|
2702 |
bertho |
1.25 |
w += bp->w + conf.rev_minline;
|
2703 |
|
|
}
|
2704 |
|
|
else
|
2705 |
bertho |
1.1 |
{
|
2706 |
bertho |
1.25 |
for(j = 0; j < bp->nrevs; j++)
|
2707 |
|
|
{
|
2708 |
|
|
if(bp->revs[j]->w > w)
|
2709 |
|
|
w = bp->revs[j]->w;
|
2710 |
|
|
h += bp->revs[j]->h + conf.rev_minline;
|
2711 |
|
|
}
|
2712 |
bertho |
1.32 |
if(conf.branch_dupbox && bp->nrevs)
|
2713 |
bertho |
1.25 |
h += bp->h + conf.rev_minline;
|
2714 |
bertho |
1.1 |
}
|
2715 |
|
|
bp->th = h;
|
2716 |
|
|
bp->tw = w;
|
2717 |
|
|
}
|
2718 |
|
|
|
2719 |
|
|
/* Calculate the relative positions of revs in a branch */
|
2720 |
bertho |
1.25 |
if(conf.left_right)
|
2721 |
|
|
{
|
2722 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2723 |
|
|
{
|
2724 |
|
|
branch_t *b = rcs->branches[i];
|
2725 |
|
|
y = b->th/2;
|
2726 |
|
|
x = b->w;
|
2727 |
|
|
b->y = y;
|
2728 |
|
|
b->cx = 0;
|
2729 |
|
|
for(j = 0; j < b->nrevs; j++)
|
2730 |
|
|
{
|
2731 |
|
|
x += conf.rev_minline;
|
2732 |
|
|
b->revs[j]->y = y;
|
2733 |
|
|
b->revs[j]->cx = x;
|
2734 |
|
|
x += b->revs[j]->w;
|
2735 |
|
|
}
|
2736 |
|
|
}
|
2737 |
|
|
}
|
2738 |
|
|
else
|
2739 |
bertho |
1.1 |
{
|
2740 |
bertho |
1.25 |
for(i = 0; i < rcs->nbranches; i++)
|
2741 |
|
|
{
|
2742 |
|
|
branch_t *b = rcs->branches[i];
|
2743 |
|
|
x = b->tw/2;
|
2744 |
|
|
y = b->h;
|
2745 |
|
|
b->cx = x;
|
2746 |
|
|
b->y = 0;
|
2747 |
|
|
for(j = 0; j < b->nrevs; j++)
|
2748 |
|
|
{
|
2749 |
|
|
y += conf.rev_minline;
|
2750 |
|
|
b->revs[j]->cx = x;
|
2751 |
|
|
b->revs[j]->y = y;
|
2752 |
|
|
y += b->revs[j]->h;
|
2753 |
|
|
}
|
2754 |
bertho |
1.1 |
}
|
2755 |
|
|
}
|
2756 |
|
|
|
2757 |
bertho |
1.18 |
/* Initially reposition the branches from bottom to top progressively right */
|
2758 |
bertho |
1.25 |
if(conf.left_right)
|
2759 |
|
|
{
|
2760 |
|
|
x = rcs->branches[0]->y;
|
2761 |
|
|
w2 = rcs->branches[0]->th / 2;
|
2762 |
|
|
for(i = rcs->branches[0]->nrevs-1; i >= 0; i--)
|
2763 |
|
|
{
|
2764 |
|
|
initial_reposition_branch_lr(rcs->branches[0]->revs[i], &x, &w2);
|
2765 |
|
|
}
|
2766 |
|
|
}
|
2767 |
|
|
else
|
2768 |
bertho |
1.1 |
{
|
2769 |
bertho |
1.25 |
x = rcs->branches[0]->cx;
|
2770 |
|
|
w2 = rcs->branches[0]->tw / 2;
|
2771 |
|
|
for(i = rcs->branches[0]->nrevs-1; i >= 0; i--)
|
2772 |
|
|
{
|
2773 |
|
|
initial_reposition_branch(rcs->branches[0]->revs[i], &x, &w2);
|
2774 |
|
|
}
|
2775 |
bertho |
1.1 |
}
|
2776 |
|
|
|
2777 |
bertho |
1.19 |
/* Initially move branches left if there is room */
|
2778 |
|
|
kern_tree(rcs);
|
2779 |
|
|
|
2780 |
bertho |
1.18 |
/* Try to kern the branches more by expanding the inter-revision spacing */
|
2781 |
bertho |
1.25 |
if(conf.auto_stretch && !conf.left_right)
|
2782 |
bertho |
1.19 |
auto_stretch(rcs);
|
2783 |
bertho |
1.7 |
|
2784 |
|
|
/* Move everything w.r.t. the top-left margin */
|
2785 |
bertho |
1.1 |
for(i = 0; i < rcs->nbranches; i++)
|
2786 |
|
|
move_branch(rcs->branches[i], conf.margin_left, conf.margin_top);
|
2787 |
|
|
|
2788 |
|
|
/* Calculate overall image size */
|
2789 |
bertho |
1.25 |
if(conf.left_right)
|
2790 |
|
|
{
|
2791 |
|
|
x = rcs->branches[0]->cx;
|
2792 |
|
|
y = rcs->branches[0]->y - rcs->branches[0]->th/2;
|
2793 |
|
|
}
|
2794 |
|
|
else
|
2795 |
|
|
{
|
2796 |
|
|
x = rcs->branches[0]->cx - rcs->branches[0]->tw/2;
|
2797 |
|
|
y = rcs->branches[0]->y;
|
2798 |
|
|
}
|
2799 |
bertho |
1.1 |
w = rcs->branches[0]->tw;
|
2800 |
|
|
h = rcs->branches[0]->th;
|
2801 |
|
|
for(i = 1; i < rcs->nbranches; i++)
|
2802 |
|
|
rect_union(&x, &y, &w, &h, rcs->branches[i]);
|
2803 |
|
|
rcs->tw = w;
|
2804 |
|
|
rcs->th = h;
|
2805 |
bertho |
1.16 |
|
2806 |
|
|
/* Flip the entire tree */
|
2807 |
|
|
if(conf.upside_down)
|
2808 |
|
|
{
|
2809 |
bertho |
1.25 |
if(conf.left_right)
|
2810 |
|
|
{
|
2811 |
|
|
x += rcs->tw;
|
2812 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2813 |
|
|
{
|
2814 |
|
|
branch_t *b = rcs->branches[i];
|
2815 |
|
|
for(j = 0; j < b->nrevs; j++)
|
2816 |
|
|
{
|
2817 |
|
|
revision_t *r = b->revs[j];
|
2818 |
bertho |
1.26 |
r->cx = x - r->cx - r->w + conf.margin_left;
|
2819 |
bertho |
1.25 |
}
|
2820 |
bertho |
1.26 |
b->cx = x - b->cx - b->w + conf.margin_left;
|
2821 |
bertho |
1.25 |
}
|
2822 |
|
|
}
|
2823 |
|
|
else
|
2824 |
bertho |
1.16 |
{
|
2825 |
bertho |
1.25 |
y += rcs->th;
|
2826 |
|
|
for(i = 0; i < rcs->nbranches; i++)
|
2827 |
bertho |
1.16 |
{
|
2828 |
bertho |
1.25 |
branch_t *b = rcs->branches[i];
|
2829 |
|
|
for(j = 0; j < b->nrevs; j++)
|
2830 |
|
|
{
|
2831 |
|
|
revision_t *r = b->revs[j];
|
2832 |
|
|
r->y = y - r->y - r->h + conf.margin_top;
|
2833 |
|
|
}
|
2834 |
|
|
b->y = y - b->y - b->h + conf.margin_top;
|
2835 |
bertho |
1.16 |
}
|
2836 |
|
|
}
|
2837 |
|
|
}
|
2838 |
bertho |
1.1 |
}
|
2839 |
|
|
|
2840 |
|
|
/*
|
2841 |
|
|
**************************************************************************
|
2842 |
bertho |
1.6 |
* Imagemap functions
|
2843 |
|
|
**************************************************************************
|
2844 |
|
|
*/
|
2845 |
bertho |
1.26 |
void make_imagemap(rcsfile_t *rcs, FILE *fp, gdImagePtr im)
|
2846 |
bertho |
1.6 |
{
|
2847 |
|
|
int i, j;
|
2848 |
bertho |
1.29 |
const char *htp = conf.html_level == HTMLLEVEL_X ? " /" : "";
|
2849 |
|
|
|
2850 |
|
|
switch(conf.html_level)
|
2851 |
|
|
{
|
2852 |
|
|
case HTMLLEVEL_4:
|
2853 |
|
|
fprintf(fp, "<map name=\"%s\" id=\"%s\">\n", conf.map_name, conf.map_name);
|
2854 |
|
|
break;
|
2855 |
|
|
case HTMLLEVEL_X:
|
2856 |
|
|
fprintf(fp, "<map id=\"%s\">\n", conf.map_name);
|
2857 |
|
|
break;
|
2858 |
|
|
default:
|
2859 |
|
|
fprintf(fp, "<map name=\"%s\">\n", conf.map_name);
|
2860 |
|
|
}
|
2861 |
|
|
|
2862 |
bertho |
1.6 |
for(i = 0; i < rcs->nbranches; i++)
|
2863 |
|
|
{
|
2864 |
|
|
branch_t *b = rcs->branches[i];
|
2865 |
bertho |
1.8 |
tag_t *tag = b->ntags ? b->tags[0] : NULL;
|
2866 |
bertho |
1.16 |
char *bhref = expand_string(conf.map_branch_href, rcs, NULL, b->branch, NULL, tag);
|
2867 |
|
|
char *balt = expand_string(conf.map_branch_alt, rcs, NULL, b->branch, NULL, tag);
|
2868 |
bertho |
1.26 |
int x1;
|
2869 |
|
|
int x2;
|
2870 |
|
|
int y1;
|
2871 |
|
|
int y2;
|
2872 |
|
|
|
2873 |
bertho |
1.34 |
if(!b->nfolds)
|
2874 |
bertho |
1.26 |
{
|
2875 |
bertho |
1.34 |
if(conf.left_right)
|
2876 |
|
|
{
|
2877 |
|
|
x1 = b->cx;
|
2878 |
|
|
y1 = b->y - b->h/2;
|
2879 |
|
|
x2 = b->cx + b->w;
|
2880 |
|
|
y2 = b->y + b->h/2;
|
2881 |
|
|
}
|
2882 |
|
|
else
|
2883 |
|
|
{
|
2884 |
|
|
x1 = b->cx - b->w/2;
|
2885 |
|
|
y1 = b->y;
|
2886 |
|
|
x2 = b->cx + b->w/2;
|
2887 |
|
|
y2 = b->y + b->h;
|
2888 |
|
|
}
|
2889 |
|
|
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
2890 |
|
|
bhref, x1, y1, x2, y2, balt, htp);
|
2891 |
|
|
if(im)
|
2892 |
|
|
{
|
2893 |
|
|
gdImageFilledRectangle(im, x1-2, y1-2, x1+2, y1+2, conf.title_color.id);
|
2894 |
|
|
gdImageFilledRectangle(im, x2-2, y2-2, x2+2, y2+2, conf.tag_color.id);
|
2895 |
|
|
gdImageLine(im, x1, y1, x2, y2, conf.title_color.id);
|
2896 |
|
|
}
|
2897 |
bertho |
1.26 |
}
|
2898 |
|
|
else
|
2899 |
|
|
{
|
2900 |
bertho |
1.34 |
int yy1, yy2, yy;
|
2901 |
|
|
if(conf.left_right)
|
2902 |
|
|
{
|
2903 |
|
|
x1 = b->cx + conf.branch_lspace;
|
2904 |
|
|
y1 = b->y - b->h/2 + conf.branch_tspace;
|
2905 |
|
|
}
|
2906 |
|
|
else
|
2907 |
|
|
{
|
2908 |
|
|
x1 = b->cx - b->w/2 + conf.branch_lspace;
|
2909 |
|
|
y1 = b->y + conf.branch_tspace;
|
2910 |
|
|
}
|
2911 |
|
|
x2 = x1 + b->w - conf.branch_rspace;
|
2912 |
|
|
|
2913 |
|
|
yy1 = get_sheight(b->branch->branch, &conf.branch_font);
|
2914 |
|
|
yy2 = get_sheight(b->tags[0]->tag, &conf.branch_tag_font);
|
2915 |
|
|
yy = MAX(yy1, yy2);
|
2916 |
|
|
y2 = y1 + yy;
|
2917 |
|
|
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
2918 |
|
|
bhref, x1, y1, x2, y2, balt, htp);
|
2919 |
|
|
|
2920 |
|
|
y1 += yy;
|
2921 |
|
|
y2 += yy;
|
2922 |
|
|
for(j = 0; j < b->nfolds; j++)
|
2923 |
|
|
{
|
2924 |
|
|
branch_t *fb = b->folds[j];
|
2925 |
|
|
tag_t *t = fb->tags[0];
|
2926 |
|
|
xfree(bhref);
|
2927 |
|
|
xfree(balt);
|
2928 |
|
|
bhref = expand_string(conf.map_branch_href, rcs, NULL, fb->branch, NULL, t);
|
2929 |
|
|
balt = expand_string(conf.map_branch_alt, rcs, NULL, fb->branch, NULL, t);
|
2930 |
|
|
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
2931 |
|
|
bhref, x1, y1, x2, y2, balt, htp);
|
2932 |
|
|
yy1 = get_sheight(fb->branch->branch, &conf.branch_font);
|
2933 |
|
|
yy2 = get_sheight(fb->tags[0]->tag, &conf.branch_tag_font);
|
2934 |
|
|
yy = MAX(yy1, yy2);
|
2935 |
|
|
y1 += yy;
|
2936 |
|
|
y2 += yy;
|
2937 |
|
|
}
|
2938 |
bertho |
1.26 |
}
|
2939 |
bertho |
1.34 |
|
2940 |
bertho |
1.6 |
for(j = 0; j < b->nrevs; j++)
|
2941 |
|
|
{
|
2942 |
|
|
revision_t *r = b->revs[j];
|
2943 |
bertho |
1.13 |
revision_t* r1;
|
2944 |
bertho |
1.26 |
int xoff = 1;
|
2945 |
|
|
int yoff = 1;
|
2946 |
bertho |
1.16 |
char *href;
|
2947 |
|
|
char *alt;
|
2948 |
bertho |
1.13 |
|
2949 |
bertho |
1.8 |
tag = r->ntags ? r->tags[0] : NULL;
|
2950 |
bertho |
1.9 |
href = expand_string(conf.map_rev_href, rcs, r, r->rev, NULL, tag);
|
2951 |
|
|
alt = expand_string(conf.map_rev_alt, rcs, r, r->rev, NULL, tag);
|
2952 |
bertho |
1.26 |
if(conf.left_right)
|
2953 |
|
|
{
|
2954 |
|
|
x1 = r->cx;
|
2955 |
|
|
y1 = r->y - r->h/2;
|
2956 |
|
|
x2 = r->cx + r->w;
|
2957 |
|
|
y2 = r->y + r->h/2;
|
2958 |
|
|
}
|
2959 |
|
|
else
|
2960 |
|
|
{
|
2961 |
|
|
x1 = r->cx - r->w/2;
|
2962 |
|
|
y1 = r->y;
|
2963 |
|
|
x2 = r->cx + r->w/2;
|
2964 |
|
|
y2 = r->y + r->h;
|
2965 |
|
|
}
|
2966 |
bertho |
1.29 |
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
2967 |
|
|
href, x1, y1, x2, y2, alt, htp);
|
2968 |
bertho |
1.26 |
if(im)
|
2969 |
|
|
{
|
2970 |
|
|
gdImageFilledRectangle(im, x1-2, y1-2, x1+2, y1+2, conf.title_color.id);
|
2971 |
|
|
gdImageFilledRectangle(im, x2-2, y2-2, x2+2, y2+2, conf.tag_color.id);
|
2972 |
|
|
gdImageLine(im, x1, y1, x2, y2, conf.title_color.id);
|
2973 |
|
|
}
|
2974 |
bertho |
1.8 |
xfree(href);
|
2975 |
|
|
xfree(alt);
|
2976 |
bertho |
1.16 |
if(j > 0 || b->branchpoint)
|
2977 |
bertho |
1.9 |
{
|
2978 |
bertho |
1.16 |
if(j > 0)
|
2979 |
|
|
{
|
2980 |
|
|
r1 = b->revs[j-1];
|
2981 |
bertho |
1.26 |
if(conf.left_right)
|
2982 |
|
|
{
|
2983 |
|
|
yoff = MIN(r->h, r1->h)/4;
|
2984 |
|
|
x1 = conf.upside_down ? r1->cx : r1->cx + r1->w;
|
2985 |
|
|
}
|
2986 |
|
|
else
|
2987 |
|
|
{
|
2988 |
|
|
xoff = MIN(r->w, r1->w)/4;
|
2989 |
|
|
y1 = conf.upside_down ? r1->y : r1->y + r1->h;
|
2990 |
|
|
}
|
2991 |
bertho |
1.16 |
}
|
2992 |
|
|
else
|
2993 |
|
|
{
|
2994 |
|
|
r1 = b->branchpoint;
|
2995 |
bertho |
1.26 |
if(conf.left_right)
|
2996 |
|
|
{
|
2997 |
|
|
yoff = MIN(r->h, b->h)/4;
|
2998 |
|
|
x1 = conf.upside_down ? b->cx : b->cx + b->w;
|
2999 |
|
|
}
|
3000 |
|
|
else
|
3001 |
|
|
{
|
3002 |
|
|
xoff = MIN(r->w, b->w)/4;
|
3003 |
|
|
y1 = conf.upside_down ? b->y : b->y + b->h;
|
3004 |
|
|
}
|
3005 |
|
|
}
|
3006 |
|
|
if(conf.left_right)
|
3007 |
|
|
{
|
3008 |
|
|
y1 = r->y - yoff;
|
3009 |
|
|
y2 = r->y + yoff;
|
3010 |
|
|
x2 = conf.upside_down ? r->cx + r->w : r->cx;
|
3011 |
|
|
yoff = 0;
|
3012 |
|
|
}
|
3013 |
|
|
else
|
3014 |
|
|
{
|
3015 |
|
|
x1 = r->cx - xoff;
|
3016 |
|
|
x2 = r->cx + xoff;
|
3017 |
|
|
y2 = conf.upside_down ? r->y + r->h : r->y;
|
3018 |
|
|
xoff = 0;
|
3019 |
|
|
}
|
3020 |
|
|
if(x1 > x2)
|
3021 |
|
|
{
|
3022 |
|
|
int tt = x1;
|
3023 |
|
|
x1 = x2;
|
3024 |
|
|
x2 = tt;
|
3025 |
|
|
}
|
3026 |
|
|
if(y1 > y2)
|
3027 |
|
|
{
|
3028 |
|
|
int tt = y1;
|
3029 |
|
|
y1 = y2;
|
3030 |
|
|
y2 = tt;
|
3031 |
bertho |
1.16 |
}
|
3032 |
|
|
href = expand_string(conf.map_diff_href, rcs, r, r->rev, r1->rev, tag);
|
3033 |
|
|
alt = expand_string(conf.map_diff_alt, rcs, r, r->rev, r1->rev, tag);
|
3034 |
bertho |
1.29 |
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
3035 |
bertho |
1.16 |
href,
|
3036 |
bertho |
1.26 |
x1+xoff, y1+yoff, x2-xoff, y2-yoff,
|
3037 |
bertho |
1.29 |
alt, htp);
|
3038 |
bertho |
1.26 |
if(im)
|
3039 |
|
|
{
|
3040 |
|
|
gdImageFilledRectangle(im, x1-2, y1-2, x1+2, y1+2, conf.title_color.id);
|
3041 |
|
|
gdImageFilledRectangle(im, x2-2, y2-2, x2+2, y2+2, conf.tag_color.id);
|
3042 |
|
|
gdImageLine(im, x1, y1, x2, y2, conf.title_color.id);
|
3043 |
|
|
}
|
3044 |
bertho |
1.16 |
xfree(href);
|
3045 |
|
|
xfree(alt);
|
3046 |
bertho |
1.9 |
}
|
3047 |
bertho |
1.6 |
}
|
3048 |
bertho |
1.32 |
if(conf.branch_dupbox && b->nrevs)
|
3049 |
bertho |
1.16 |
{
|
3050 |
bertho |
1.26 |
if(conf.left_right)
|
3051 |
|
|
{
|
3052 |
|
|
x1 = conf.upside_down ? b->cx + b->w - b->tw : b->cx - b->w + b->tw;
|
3053 |
|
|
y1 = b->y - b->h/2;
|
3054 |
|
|
x2 = x1 + b->w;
|
3055 |
|
|
y2 = b->y + b->h/2;
|
3056 |
|
|
}
|
3057 |
bertho |
1.16 |
else
|
3058 |
bertho |
1.26 |
{
|
3059 |
|
|
x1 = b->cx - b->w/2;
|
3060 |
|
|
y1 = conf.upside_down ? b->y + b->h - b->th : b->y - b->h + b->th;
|
3061 |
|
|
x2 = b->cx + b->w/2;
|
3062 |
|
|
y2 = y1 + b->h;
|
3063 |
|
|
}
|
3064 |
bertho |
1.29 |
fprintf(fp, "\t<area shape=\"rect\" %s coords=\"%d,%d,%d,%d\" %s%s>\n",
|
3065 |
|
|
bhref, x1, y1, x2, y2, balt, htp);
|
3066 |
bertho |
1.26 |
if(im)
|
3067 |
|
|
{
|
3068 |
|
|
gdImageFilledRectangle(im, x1-2, y1-2, x1+2, y1+2, conf.title_color.id);
|
3069 |
|
|
gdImageFilledRectangle(im, x2-2, y2-2, x2+2, y2+2, conf.tag_color.id);
|
3070 |
|
|
gdImageLine(im, x1, y1, x2, y2, conf.title_color.id);
|
3071 |
|
|
}
|
3072 |
bertho |
1.16 |
}
|
3073 |
|
|
xfree(bhref);
|
3074 |
|
|
xfree(balt);
|
3075 |
bertho |
1.6 |
}
|
3076 |
|
|
fprintf(fp, "</map>\n");
|
3077 |
|
|
}
|
3078 |
|
|
|
3079 |
|
|
/*
|
3080 |
|
|
**************************************************************************
|
3081 |
bertho |
1.1 |
* Program entry
|
3082 |
|
|
**************************************************************************
|
3083 |
|
|
*/
|
3084 |
|
|
static const char usage_str[] =
|
3085 |
|
|
"Usage: cvsgraph [options] <file>\n"
|
3086 |
bertho |
1.16 |
" -b Add a branch box at both sides of the trunk (config value is negated)\n"
|
3087 |
bertho |
1.8 |
" -c <file> Read alternative config from <file>\n"
|
3088 |
|
|
" -d <level> Enable debug mode at <level>\n"
|
3089 |
|
|
" -h This message\n"
|
3090 |
|
|
" -i Generate an imagemap instead of image\n"
|
3091 |
bertho |
1.18 |
" -I <file> Also write the imagemap to <file>\n"
|
3092 |
bertho |
1.19 |
" -k Auto stretch the tree (config value is negated)\n"
|
3093 |
bertho |
1.8 |
" -M <name> Use <name> as imagemap name\n"
|
3094 |
|
|
" -m <mod> Use <mod> as cvs module\n"
|
3095 |
|
|
" -o <file> Output to <file>\n"
|
3096 |
bertho |
1.18 |
" -O <opt=val> Set option opt to value val\n"
|
3097 |
bertho |
1.8 |
" -q Be quiet (i.e. no warnings)\n"
|
3098 |
|
|
" -r <path> Use <path> as cvsroot path\n"
|
3099 |
bertho |
1.16 |
" -s Strip untagged revisions (config value is negated)\n"
|
3100 |
bertho |
1.18 |
" -S Also strip the first revision (config value is negated)\n"
|
3101 |
bertho |
1.16 |
" -u Upside down image (mirror vertically; config value is negated)\n"
|
3102 |
bertho |
1.8 |
" -V Print version and exit\n"
|
3103 |
bertho |
1.29 |
" -x [34x] Specify level of HTML 3.2 (default), 4.0 or XHTML\n"
|
3104 |
bertho |
1.8 |
" -[0-9] <txt> Use <txt> for expansion\n"
|
3105 |
bertho |
1.1 |
;
|
3106 |
|
|
|
3107 |
bertho |
1.41 |
#define VERSION_STR "1.4.2"
|
3108 |
|
|
#define NOTICE_STR "Copyright (c) 2001,2002,2003,2004 B.Stultiens"
|
3109 |
bertho |
1.1 |
|
3110 |
bertho |
1.19 |
static void append_slash(char **path)
|
3111 |
bertho |
1.9 |
{
|
3112 |
|
|
int l;
|
3113 |
|
|
assert(path != NULL);
|
3114 |
|
|
assert(*path != NULL);
|
3115 |
|
|
l = strlen(*path);
|
3116 |
|
|
if(!l || (*path)[l-1] == '/')
|
3117 |
|
|
return;
|
3118 |
|
|
*path = xrealloc(*path, l+2);
|
3119 |
|
|
strcat(*path, "/");
|
3120 |
|
|
}
|
3121 |
|
|
|
3122 |
bertho |
1.1 |
int main(int argc, char *argv[])
|
3123 |
|
|
{
|
3124 |
bertho |
1.7 |
extern int rcs_flex_debug;
|
3125 |
|
|
extern int rcsdebug;
|
3126 |
bertho |
1.1 |
int optc;
|
3127 |
|
|
char *confpath = NULL;
|
3128 |
|
|
char *outfile = NULL;
|
3129 |
|
|
char *cvsroot = NULL;
|
3130 |
|
|
char *cvsmodule = NULL;
|
3131 |
bertho |
1.7 |
int imagemap = 0;
|
3132 |
bertho |
1.16 |
int upsidedown = 0;
|
3133 |
bertho |
1.17 |
int bdupbox = 0;
|
3134 |
bertho |
1.16 |
int stripuntag = 0;
|
3135 |
bertho |
1.18 |
int stripfirst = 0;
|
3136 |
bertho |
1.19 |
int autostretch = 0;
|
3137 |
bertho |
1.29 |
int htmllevel = 0;
|
3138 |
bertho |
1.7 |
char *imgmapname = NULL;
|
3139 |
bertho |
1.18 |
char *imgmapfile = NULL;
|
3140 |
bertho |
1.1 |
int lose = 0;
|
3141 |
|
|
FILE *fp;
|
3142 |
bertho |
1.18 |
char *rcsfilename;
|
3143 |
bertho |
1.7 |
rcsfile_t *rcs;
|
3144 |
bertho |
1.1 |
gdImagePtr im;
|
3145 |
|
|
|
3146 |
bertho |
1.29 |
while((optc = getopt(argc, argv, "0:1:2:3:4:5:6:7:8:9:bc:d:hI:ikM:m:O:o:qr:SsuVx:")) != EOF)
|
3147 |
bertho |
1.1 |
{
|
3148 |
|
|
switch(optc)
|
3149 |
|
|
{
|
3150 |
bertho |
1.16 |
case 'b':
|
3151 |
bertho |
1.17 |
bdupbox = 1;
|
3152 |
bertho |
1.16 |
break;
|
3153 |
bertho |
1.1 |
case 'c':
|
3154 |
|
|
confpath = xstrdup(optarg);
|
3155 |
|
|
break;
|
3156 |
bertho |
1.7 |
case 'd':
|
3157 |
|
|
debuglevel = strtol(optarg, NULL, 0);
|
3158 |
|
|
break;
|
3159 |
bertho |
1.18 |
case 'I':
|
3160 |
|
|
imgmapfile = xstrdup(optarg);
|
3161 |
|
|
break;
|
3162 |
bertho |
1.6 |
case 'i':
|
3163 |
bertho |
1.7 |
imagemap = 1;
|
3164 |
|
|
break;
|
3165 |
bertho |
1.18 |
case 'k':
|
3166 |
bertho |
1.19 |
autostretch = 1;
|
3167 |
bertho |
1.18 |
break;
|
3168 |
bertho |
1.7 |
case 'M':
|
3169 |
|
|
imgmapname = xstrdup(optarg);
|
3170 |
bertho |
1.6 |
break;
|
3171 |
bertho |
1.1 |
case 'm':
|
3172 |
|
|
cvsmodule = xstrdup(optarg);
|
3173 |
|
|
break;
|
3174 |
bertho |
1.18 |
case 'O':
|
3175 |
|
|
stack_option(optarg);
|
3176 |
|
|
break;
|
3177 |
bertho |
1.1 |
case 'o':
|
3178 |
|
|
outfile = xstrdup(optarg);
|
3179 |
|
|
break;
|
3180 |
bertho |
1.7 |
case 'q':
|
3181 |
|
|
quiet = 1;
|
3182 |
|
|
break;
|
3183 |
bertho |
1.1 |
case 'r':
|
3184 |
|
|
cvsroot = xstrdup(optarg);
|
3185 |
|
|
break;
|
3186 |
bertho |
1.18 |
case 'S':
|
3187 |
|
|
stripfirst = 1;
|
3188 |
|
|
break;
|
3189 |
bertho |
1.16 |
case 's':
|
3190 |
|
|
stripuntag = 1;
|
3191 |
|
|
break;
|
3192 |
|
|
case 'u':
|
3193 |
|
|
upsidedown = 1;
|
3194 |
|
|
break;
|
3195 |
bertho |
1.1 |
case 'V':
|
3196 |
|
|
fprintf(stdout, "cvsgraph v%s, %s\n", VERSION_STR, NOTICE_STR);
|
3197 |
|
|
return 0;
|
3198 |
bertho |
1.29 |
case 'x':
|
3199 |
|
|
switch(optarg[0])
|
3200 |
|
|
{
|
3201 |
|
|
case '3':
|
3202 |
|
|
htmllevel = HTMLLEVEL_3;
|
3203 |
|
|
break;
|
3204 |
|
|
case '4':
|
3205 |
|
|
htmllevel = HTMLLEVEL_4;
|
3206 |
|
|
break;
|
3207 |
|
|
case 'x':
|
3208 |
|
|
htmllevel = HTMLLEVEL_X;
|
3209 |
|
|
break;
|
3210 |
|
|
default:
|
3211 |
|
|
fprintf(stderr, "Invalid HTML level in -x\n");
|
3212 |
|
|
lose++;
|
3213 |
|
|
}
|
3214 |
|
|
break;
|
3215 |
bertho |
1.1 |
case 'h':
|
3216 |
|
|
fprintf(stdout, "%s", usage_str);
|
3217 |
|
|
return 0;
|
3218 |
|
|
default:
|
3219 |
bertho |
1.8 |
if(isdigit(optc))
|
3220 |
|
|
{
|
3221 |
|
|
conf.expand[optc-'0'] = xstrdup(optarg);
|
3222 |
|
|
}
|
3223 |
|
|
else
|
3224 |
|
|
lose++;
|
3225 |
bertho |
1.1 |
}
|
3226 |
|
|
}
|
3227 |
|
|
|
3228 |
|
|
if(lose)
|
3229 |
|
|
{
|
3230 |
|
|
fprintf(stderr, "%s", usage_str);
|
3231 |
|
|
return 1;
|
3232 |
|
|
}
|
3233 |
|
|
|
3234 |
bertho |
1.7 |
if(debuglevel)
|
3235 |
|
|
{
|
3236 |
|
|
setvbuf(stdout, NULL, 0, _IONBF);
|
3237 |
|
|
setvbuf(stderr, NULL, 0, _IONBF);
|
3238 |
|
|
}
|
3239 |
|
|
rcs_flex_debug = (debuglevel & DEBUG_RCS_LEX) != 0;
|
3240 |
|
|
rcsdebug = (debuglevel & DEBUG_RCS_YACC) != 0;
|
3241 |
|
|
|
3242 |
bertho |
1.1 |
/* Set defaults */
|
3243 |
bertho |
1.21 |
conf.tag_font.gdfont = gdFontTiny;
|
3244 |
|
|
conf.rev_font.gdfont = gdFontTiny;
|
3245 |
|
|
conf.branch_font.gdfont = gdFontTiny;
|
3246 |
|
|
conf.branch_tag_font.gdfont = gdFontTiny;
|
3247 |
|
|
conf.title_font.gdfont = gdFontTiny;
|
3248 |
|
|
conf.rev_text_font.gdfont = gdFontTiny;
|
3249 |
|
|
|
3250 |
bertho |
1.19 |
conf.anti_alias = 1;
|
3251 |
bertho |
1.20 |
conf.thick_lines = 1;
|
3252 |
bertho |
1.32 |
conf.branch_fold = 1;
|
3253 |
bertho |
1.9 |
|
3254 |
|
|
conf.cvsroot = xstrdup("");
|
3255 |
|
|
conf.cvsmodule = xstrdup("");
|
3256 |
|
|
conf.date_format = xstrdup("%d-%b-%Y %H:%M:%S");
|
3257 |
|
|
conf.title = xstrdup("");
|
3258 |
|
|
conf.map_name = xstrdup("CvsGraphImageMap");
|
3259 |
|
|
conf.map_branch_href = xstrdup("href=\"unset: conf.map_branch_href\"");
|
3260 |
|
|
conf.map_branch_alt = xstrdup("alt=\"%B\"");
|
3261 |
|
|
conf.map_rev_href = xstrdup("href=\"unset: conf.map_rev_href\"");
|
3262 |
|
|
conf.map_rev_alt = xstrdup("alt=\"%R\"");
|
3263 |
|
|
conf.map_diff_href = xstrdup("href=\"unset: conf.map_diff_href\"");
|
3264 |
bertho |
1.12 |
conf.map_diff_alt = xstrdup("alt=\"%P <-> %R\"");
|
3265 |
bertho |
1.10 |
conf.rev_text = xstrdup("%d");
|
3266 |
bertho |
1.30 |
conf.merge_from = xstrdup("");
|
3267 |
|
|
conf.merge_to = xstrdup("");
|
3268 |
bertho |
1.35 |
conf.merge_arrows = 1;
|
3269 |
|
|
conf.arrow_width = ARROW_WIDTH;
|
3270 |
|
|
conf.arrow_length = ARROW_LENGTH;
|
3271 |
bertho |
1.9 |
|
3272 |
|
|
conf.color_bg = white_color;
|
3273 |
|
|
conf.branch_bgcolor = white_color;
|
3274 |
|
|
conf.branch_color = black_color;
|
3275 |
bertho |
1.19 |
conf.branch_tag_color = black_color;
|
3276 |
bertho |
1.9 |
conf.rev_color = black_color;
|
3277 |
|
|
conf.rev_bgcolor = white_color;
|
3278 |
bertho |
1.30 |
conf.merge_color = black_color;
|
3279 |
bertho |
1.9 |
conf.tag_color = black_color;
|
3280 |
|
|
conf.title_color = black_color;
|
3281 |
|
|
conf.rev_text_color = black_color;
|
3282 |
bertho |
1.10 |
|
3283 |
|
|
conf.image_quality = 100;
|
3284 |
bertho |
1.18 |
conf.rev_maxline = -1; /* Checked later to set to default */
|
3285 |
|
|
|
3286 |
|
|
read_config(confpath);
|
3287 |
bertho |
1.1 |
|
3288 |
bertho |
1.18 |
if(conf.rev_maxline == -1) conf.rev_maxline = 5 * conf.rev_minline;
|
3289 |
bertho |
1.1 |
|
3290 |
|
|
/* Set overrides */
|
3291 |
bertho |
1.7 |
if(cvsroot) conf.cvsroot = cvsroot;
|
3292 |
|
|
if(cvsmodule) conf.cvsmodule = cvsmodule;
|
3293 |
|
|
if(imgmapname) conf.map_name = imgmapname;
|
3294 |
bertho |
1.16 |
if(upsidedown) conf.upside_down = !conf.upside_down;
|
3295 |
bertho |
1.17 |
if(bdupbox) conf.branch_dupbox = !conf.branch_dupbox;
|
3296 |
bertho |
1.16 |
if(stripuntag) conf.strip_untagged = !conf.strip_untagged;
|
3297 |
bertho |
1.18 |
if(stripfirst) conf.strip_first_rev = !conf.strip_first_rev;
|
3298 |
bertho |
1.19 |
if(autostretch) conf.auto_stretch = !conf.auto_stretch;
|
3299 |
bertho |
1.29 |
if(htmllevel) conf.html_level = htmllevel;
|
3300 |
bertho |
1.18 |
|
3301 |
|
|
if(conf.rev_minline >= conf.rev_maxline)
|
3302 |
|
|
{
|
3303 |
bertho |
1.19 |
if(conf.auto_stretch && !quiet)
|
3304 |
|
|
fprintf(stderr, "Auto stretch is only possible if rev_minline < rev_maxline\n");
|
3305 |
|
|
conf.auto_stretch = 0;
|
3306 |
bertho |
1.18 |
}
|
3307 |
bertho |
1.20 |
|
3308 |
|
|
if(conf.thick_lines < 1)
|
3309 |
|
|
conf.thick_lines = 1;
|
3310 |
|
|
if(conf.thick_lines > 11)
|
3311 |
|
|
conf.thick_lines = 11;
|
3312 |
bertho |
1.1 |
|
3313 |
bertho |
1.9 |
append_slash(&conf.cvsroot);
|
3314 |
|
|
append_slash(&conf.cvsmodule);
|
3315 |
|
|
|
3316 |
bertho |
1.18 |
if(optind >= argc)
|
3317 |
|
|
{
|
3318 |
|
|
#ifdef __WIN32__
|
3319 |
|
|
/* Bad hack for DOS/Windows */
|
3320 |
|
|
if(setmode(fileno(stdin), O_BINARY) == -1)
|
3321 |
|
|
{
|
3322 |
|
|
perror("Set binary mode for stdin");
|
3323 |
|
|
return 1;
|
3324 |
|
|
}
|
3325 |
|
|
#endif
|
3326 |
|
|
rcsfilename = NULL;
|
3327 |
|
|
}
|
3328 |
|
|
else
|
3329 |
|
|
rcsfilename = argv[optind];
|
3330 |
|
|
|
3331 |
|
|
rcs = get_rcsfile(conf.cvsroot, conf.cvsmodule, rcsfilename);
|
3332 |
bertho |
1.1 |
if(!rcs)
|
3333 |
|
|
return 1;
|
3334 |
|
|
|
3335 |
bertho |
1.7 |
if(debuglevel & DEBUG_RCS_FILE)
|
3336 |
|
|
dump_rcsfile(rcs);
|
3337 |
bertho |
1.1 |
|
3338 |
bertho |
1.7 |
if(!reorganise_branches(rcs))
|
3339 |
|
|
return 1;
|
3340 |
bertho |
1.1 |
|
3341 |
bertho |
1.31 |
assign_tags(rcs);
|
3342 |
|
|
find_merges(rcs);
|
3343 |
bertho |
1.1 |
|
3344 |
|
|
if(outfile)
|
3345 |
|
|
{
|
3346 |
bertho |
1.15 |
if((fp = fopen(outfile, "wb")) == NULL)
|
3347 |
bertho |
1.1 |
{
|
3348 |
|
|
perror(outfile);
|
3349 |
|
|
return 1;
|
3350 |
|
|
}
|
3351 |
|
|
}
|
3352 |
|
|
else
|
3353 |
bertho |
1.15 |
{
|
3354 |
bertho |
1.1 |
fp = stdout;
|
3355 |
bertho |
1.15 |
#ifdef __WIN32__
|
3356 |
|
|
/* Bad hack for DOS/Windows */
|
3357 |
|
|
if(setmode(fileno(fp), O_BINARY) == -1)
|
3358 |
|
|
{
|
3359 |
|
|
perror("Set binary mode for stdout");
|
3360 |
|
|
return 1;
|
3361 |
|
|
}
|
3362 |
|
|
#endif
|
3363 |
|
|
}
|
3364 |
bertho |
1.5 |
|
3365 |
bertho |
1.7 |
make_layout(rcs);
|
3366 |
|
|
|
3367 |
|
|
if(!imagemap)
|
3368 |
bertho |
1.5 |
{
|
3369 |
bertho |
1.7 |
/* Create an image */
|
3370 |
|
|
im = make_image(rcs);
|
3371 |
bertho |
1.26 |
#ifdef DEBUG_IMAGEMAP
|
3372 |
|
|
{
|
3373 |
|
|
FILE *nulfile = fopen("/dev/null", "w");
|
3374 |
|
|
make_imagemap(rcs, nulfile, im);
|
3375 |
|
|
fclose(nulfile);
|
3376 |
|
|
}
|
3377 |
|
|
#endif
|
3378 |
bertho |
1.7 |
switch(conf.image_type)
|
3379 |
|
|
{
|
3380 |
bertho |
1.5 |
#ifdef HAVE_IMAGE_GIF
|
3381 |
bertho |
1.7 |
# ifndef HAVE_IMAGE_PNG
|
3382 |
|
|
default:
|
3383 |
|
|
# endif
|
3384 |
|
|
case IMAGE_GIF:
|
3385 |
|
|
gdImageGif(im, fp);
|
3386 |
|
|
break;
|
3387 |
bertho |
1.5 |
#endif
|
3388 |
|
|
#ifdef HAVE_IMAGE_PNG
|
3389 |
bertho |
1.7 |
default:
|
3390 |
|
|
case IMAGE_PNG:
|
3391 |
|
|
gdImagePng(im, fp);
|
3392 |
|
|
break;
|
3393 |
bertho |
1.5 |
#endif
|
3394 |
|
|
#ifdef HAVE_IMAGE_JPEG
|
3395 |
|
|
# if !defined(HAVE_IMAGE_GIF) && !defined(HAVE_IMAGE_PNG)
|
3396 |
bertho |
1.7 |
default:
|
3397 |
bertho |
1.5 |
# endif
|
3398 |
bertho |
1.7 |
case IMAGE_JPEG:
|
3399 |
|
|
gdImageJpeg(im, fp, conf.image_quality);
|
3400 |
|
|
break;
|
3401 |
bertho |
1.5 |
#endif
|
3402 |
bertho |
1.7 |
}
|
3403 |
|
|
|
3404 |
|
|
gdImageDestroy(im);
|
3405 |
|
|
}
|
3406 |
|
|
else
|
3407 |
|
|
{
|
3408 |
|
|
/* Create an imagemap */
|
3409 |
bertho |
1.26 |
make_imagemap(rcs, fp, NULL);
|
3410 |
bertho |
1.18 |
}
|
3411 |
|
|
|
3412 |
|
|
/* Also create imagemap to file if requested */
|
3413 |
|
|
if(imgmapfile)
|
3414 |
|
|
{
|
3415 |
|
|
FILE *ifp = fopen(imgmapfile, "wb");
|
3416 |
|
|
if(!ifp)
|
3417 |
|
|
{
|
3418 |
|
|
perror(imgmapfile);
|
3419 |
|
|
return 1;
|
3420 |
|
|
}
|
3421 |
bertho |
1.26 |
make_imagemap(rcs, ifp, NULL);
|
3422 |
bertho |
1.18 |
fclose(ifp);
|
3423 |
bertho |
1.5 |
}
|
3424 |
|
|
|
3425 |
bertho |
1.1 |
if(outfile)
|
3426 |
|
|
fclose(fp);
|
3427 |
bertho |
1.6 |
|
3428 |
bertho |
1.1 |
return 0;
|
3429 |
|
|
}
|
3430 |
|
|
|