Fossil SCM

Fix a bug in timeline graph generation.

drh 2010-02-08 16:58 trunk
Commit 399d1ca0006bf2f51c353a807f5b139bbb676041
1 file changed +10 -4
+10 -4
--- src/graph.c
+++ src/graph.c
@@ -152,12 +152,11 @@
152152
153153
/*
154154
** Return the index of a rail currently not in use for any row between
155155
** top and bottom, inclusive.
156156
*/
157
-static int findFreeRail(GraphContext *p, int top, int btm){
158
- u32 inUseMask = 0;
157
+static int findFreeRail(GraphContext *p, int top, int btm, u32 inUseMask){
159158
GraphRow *pRow;
160159
int i;
161160
for(pRow=p->pFirst; pRow && pRow->idx<top; pRow=pRow->pNext){}
162161
while( pRow && pRow->idx<=btm ){
163162
inUseMask |= pRow->railInUse;
@@ -177,10 +176,11 @@
177176
GraphRow *pRow, *pDesc;
178177
Bag allRids;
179178
int i;
180179
int nRow;
181180
u32 mask;
181
+ u32 inUse;
182182
183183
if( p==0 || p->pFirst==0 || p->nErr ) return;
184184
185185
/* Initialize all rows */
186186
bag_init(&allRids);
@@ -221,10 +221,11 @@
221221
222222
/* Assign rails to all rows that are still unassigned.
223223
** The first primary child of a row goes on the same rail as
224224
** that row.
225225
*/
226
+ inUse = 0;
226227
for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
227228
int parentRid;
228229
if( pRow->iRail>=0 ) continue;
229230
assert( pRow->nParent>0 );
230231
parentRid = pRow->aParent[0];
@@ -232,14 +233,19 @@
232233
for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid; pDesc=pDesc->pNext){}
233234
assert( pDesc!=0 );
234235
if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
235236
pRow->iRail = pDesc->iRail;
236237
}else{
237
- pRow->iRail = findFreeRail(p, 0, pDesc->idx);
238
+ pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse);
238239
}
239240
pDesc->aiRaiser[pRow->iRail] = pRow->idx;
240241
mask = 1<<pRow->iRail;
242
+ if( pRow->isLeaf ){
243
+ inUse &= ~mask;
244
+ }else{
245
+ inUse |= mask;
246
+ }
241247
for(pDesc = pRow; ; pDesc=pDesc->pNext){
242248
assert( pDesc!=0 );
243249
pDesc->railInUse |= mask;
244250
if( pDesc->rid==parentRid ) break;
245251
}
@@ -253,11 +259,11 @@
253259
int parentRid = pRow->aParent[i];
254260
for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid;
255261
pDesc=pDesc->pNext){}
256262
if( pDesc==0 ) continue;
257263
if( pDesc->mergeOut<0 ){
258
- pDesc->mergeOut = findFreeRail(p, pRow->idx, pDesc->idx);
264
+ pDesc->mergeOut = findFreeRail(p, pRow->idx, pDesc->idx, 0);
259265
pDesc->mergeUpto = pRow->idx;
260266
}
261267
pRow->mergeIn |= 1<<pDesc->mergeOut;
262268
}
263269
}
264270
--- src/graph.c
+++ src/graph.c
@@ -152,12 +152,11 @@
152
153 /*
154 ** Return the index of a rail currently not in use for any row between
155 ** top and bottom, inclusive.
156 */
157 static int findFreeRail(GraphContext *p, int top, int btm){
158 u32 inUseMask = 0;
159 GraphRow *pRow;
160 int i;
161 for(pRow=p->pFirst; pRow && pRow->idx<top; pRow=pRow->pNext){}
162 while( pRow && pRow->idx<=btm ){
163 inUseMask |= pRow->railInUse;
@@ -177,10 +176,11 @@
177 GraphRow *pRow, *pDesc;
178 Bag allRids;
179 int i;
180 int nRow;
181 u32 mask;
 
182
183 if( p==0 || p->pFirst==0 || p->nErr ) return;
184
185 /* Initialize all rows */
186 bag_init(&allRids);
@@ -221,10 +221,11 @@
221
222 /* Assign rails to all rows that are still unassigned.
223 ** The first primary child of a row goes on the same rail as
224 ** that row.
225 */
 
226 for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
227 int parentRid;
228 if( pRow->iRail>=0 ) continue;
229 assert( pRow->nParent>0 );
230 parentRid = pRow->aParent[0];
@@ -232,14 +233,19 @@
232 for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid; pDesc=pDesc->pNext){}
233 assert( pDesc!=0 );
234 if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
235 pRow->iRail = pDesc->iRail;
236 }else{
237 pRow->iRail = findFreeRail(p, 0, pDesc->idx);
238 }
239 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
240 mask = 1<<pRow->iRail;
 
 
 
 
 
241 for(pDesc = pRow; ; pDesc=pDesc->pNext){
242 assert( pDesc!=0 );
243 pDesc->railInUse |= mask;
244 if( pDesc->rid==parentRid ) break;
245 }
@@ -253,11 +259,11 @@
253 int parentRid = pRow->aParent[i];
254 for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid;
255 pDesc=pDesc->pNext){}
256 if( pDesc==0 ) continue;
257 if( pDesc->mergeOut<0 ){
258 pDesc->mergeOut = findFreeRail(p, pRow->idx, pDesc->idx);
259 pDesc->mergeUpto = pRow->idx;
260 }
261 pRow->mergeIn |= 1<<pDesc->mergeOut;
262 }
263 }
264
--- src/graph.c
+++ src/graph.c
@@ -152,12 +152,11 @@
152
153 /*
154 ** Return the index of a rail currently not in use for any row between
155 ** top and bottom, inclusive.
156 */
157 static int findFreeRail(GraphContext *p, int top, int btm, u32 inUseMask){
 
158 GraphRow *pRow;
159 int i;
160 for(pRow=p->pFirst; pRow && pRow->idx<top; pRow=pRow->pNext){}
161 while( pRow && pRow->idx<=btm ){
162 inUseMask |= pRow->railInUse;
@@ -177,10 +176,11 @@
176 GraphRow *pRow, *pDesc;
177 Bag allRids;
178 int i;
179 int nRow;
180 u32 mask;
181 u32 inUse;
182
183 if( p==0 || p->pFirst==0 || p->nErr ) return;
184
185 /* Initialize all rows */
186 bag_init(&allRids);
@@ -221,10 +221,11 @@
221
222 /* Assign rails to all rows that are still unassigned.
223 ** The first primary child of a row goes on the same rail as
224 ** that row.
225 */
226 inUse = 0;
227 for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
228 int parentRid;
229 if( pRow->iRail>=0 ) continue;
230 assert( pRow->nParent>0 );
231 parentRid = pRow->aParent[0];
@@ -232,14 +233,19 @@
233 for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid; pDesc=pDesc->pNext){}
234 assert( pDesc!=0 );
235 if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
236 pRow->iRail = pDesc->iRail;
237 }else{
238 pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse);
239 }
240 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
241 mask = 1<<pRow->iRail;
242 if( pRow->isLeaf ){
243 inUse &= ~mask;
244 }else{
245 inUse |= mask;
246 }
247 for(pDesc = pRow; ; pDesc=pDesc->pNext){
248 assert( pDesc!=0 );
249 pDesc->railInUse |= mask;
250 if( pDesc->rid==parentRid ) break;
251 }
@@ -253,11 +259,11 @@
259 int parentRid = pRow->aParent[i];
260 for(pDesc=pRow->pNext; pDesc && pDesc->rid!=parentRid;
261 pDesc=pDesc->pNext){}
262 if( pDesc==0 ) continue;
263 if( pDesc->mergeOut<0 ){
264 pDesc->mergeOut = findFreeRail(p, pRow->idx, pDesc->idx, 0);
265 pDesc->mergeUpto = pRow->idx;
266 }
267 pRow->mergeIn |= 1<<pDesc->mergeOut;
268 }
269 }
270

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button