Fossil SCM

Further changes trying to get execute permissions right for the "update" command. Ticket [baf9b6b11e08].

drh 2011-02-28 02:44 UTC exe-permission-fix
Commit 55bf7a0ff289091c9869fd0c1f2ff49146914a83
1 file changed +20 -10
+20 -10
--- src/update.c
+++ src/update.c
@@ -197,19 +197,21 @@
197197
" idv INTEGER," /* VFILE entry for current version */
198198
" idt INTEGER," /* VFILE entry for target version */
199199
" chnged BOOLEAN," /* True if current version has been edited */
200200
" ridv INTEGER," /* Record ID for current version */
201201
" ridt INTEGER," /* Record ID for target */
202
+ " isexe BOOLEAN," /* Does target have execute permission? */
202203
" fnt TEXT" /* Filename of same file on target version */
203204
");"
204205
);
205206
206207
/* Add files found in the current version
207208
*/
208209
db_multi_exec(
209
- "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,chnged)"
210
- " SELECT pathname, pathname, id, 0, rid, 0, chnged FROM vfile WHERE vid=%d",
210
+ "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
211
+ " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged"
212
+ " FROM vfile WHERE vid=%d",
211213
vid
212214
);
213215
214216
/* Compute file name changes on V->T. Record name changes in files that
215217
** have changed locally.
@@ -229,12 +231,12 @@
229231
230232
/* Add files found in the target version T but missing from the current
231233
** version V.
232234
*/
233235
db_multi_exec(
234
- "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,chnged)"
235
- " SELECT pathname, pathname, 0, 0, 0, 0, 0 FROM vfile"
236
+ "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
237
+ " SELECT pathname, pathname, 0, 0, 0, 0, isexe, 0 FROM vfile"
236238
" WHERE vid=%d"
237239
" AND pathname NOT IN (SELECT fnt FROM fv)",
238240
tid
239241
);
240242
@@ -248,18 +250,19 @@
248250
tid, tid
249251
);
250252
251253
if( debugFlag ){
252254
db_prepare(&q,
253
- "SELECT rowid, fn, fnt, chnged, ridv, ridt FROM fv"
255
+ "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv"
254256
);
255257
while( db_step(&q)==SQLITE_ROW ){
256
- printf("%3d: ridv=%-4d ridt=%-4d chnged=%d\n",
258
+ printf("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
257259
db_column_int(&q, 0),
258260
db_column_int(&q, 4),
259261
db_column_int(&q, 5),
260
- db_column_int(&q, 3));
262
+ db_column_int(&q, 3),
263
+ db_column_int(&q, 6));
261264
printf(" fnv = [%s]\n", db_column_text(&q, 1));
262265
printf(" fnt = [%s]\n", db_column_text(&q, 2));
263266
}
264267
db_finalize(&q);
265268
}
@@ -299,11 +302,11 @@
299302
/*
300303
** Alter the content of the checkout so that it conforms with the
301304
** target
302305
*/
303306
db_prepare(&q,
304
- "SELECT fn, idv, ridv, idt, ridt, chnged, fnt FROM fv ORDER BY 1"
307
+ "SELECT fn, idv, ridv, idt, ridt, chnged, fnt, isexe FROM fv ORDER BY 1"
305308
);
306309
db_prepare(&mtimeXfer,
307310
"UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
308311
" WHERE id=:idt"
309312
);
@@ -316,10 +319,11 @@
316319
int ridv = db_column_int(&q, 2); /* RecordID for current */
317320
int idt = db_column_int(&q, 3); /* VFILE entry for target */
318321
int ridt = db_column_int(&q, 4); /* RecordID for target */
319322
int chnged = db_column_int(&q, 5); /* Current is edited */
320323
const char *zNewName = db_column_text(&q,6);/* New filename */
324
+ int isexe = db_column_int(&q, 6); /* EXE perm for new file */
321325
char *zFullPath; /* Full pathname of the file */
322326
char *zFullNewPath; /* Full pathname of dest */
323327
char nameChng; /* True if the name changed */
324328
325329
zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -374,17 +378,23 @@
374378
undo_save(zName);
375379
content_get(ridt, &t);
376380
content_get(ridv, &v);
377381
rc = merge_3way(&v, zFullPath, &t, &r);
378382
if( rc>=0 ){
379
- if( !nochangeFlag ) blob_write_to_file(&r, zFullNewPath);
383
+ if( !nochangeFlag ){
384
+ blob_write_to_file(&r, zFullNewPath);
385
+ file_setexe(zFullNewPath, isexe);
386
+ }
380387
if( rc>0 ){
381388
printf("***** %d merge conflicts in %s\n", rc, zNewName);
382389
nConflict++;
383390
}
384391
}else{
385
- if( !nochangeFlag ) blob_write_to_file(&t, zFullNewPath);
392
+ if( !nochangeFlag ){
393
+ blob_write_to_file(&t, zFullNewPath);
394
+ file_setexe(zFullNewPath, isexe);
395
+ }
386396
printf("***** Cannot merge binary file %s\n", zNewName);
387397
nConflict++;
388398
}
389399
if( nameChng && !nochangeFlag ) unlink(zFullPath);
390400
blob_reset(&v);
391401
--- src/update.c
+++ src/update.c
@@ -197,19 +197,21 @@
197 " idv INTEGER," /* VFILE entry for current version */
198 " idt INTEGER," /* VFILE entry for target version */
199 " chnged BOOLEAN," /* True if current version has been edited */
200 " ridv INTEGER," /* Record ID for current version */
201 " ridt INTEGER," /* Record ID for target */
 
202 " fnt TEXT" /* Filename of same file on target version */
203 ");"
204 );
205
206 /* Add files found in the current version
207 */
208 db_multi_exec(
209 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,chnged)"
210 " SELECT pathname, pathname, id, 0, rid, 0, chnged FROM vfile WHERE vid=%d",
 
211 vid
212 );
213
214 /* Compute file name changes on V->T. Record name changes in files that
215 ** have changed locally.
@@ -229,12 +231,12 @@
229
230 /* Add files found in the target version T but missing from the current
231 ** version V.
232 */
233 db_multi_exec(
234 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,chnged)"
235 " SELECT pathname, pathname, 0, 0, 0, 0, 0 FROM vfile"
236 " WHERE vid=%d"
237 " AND pathname NOT IN (SELECT fnt FROM fv)",
238 tid
239 );
240
@@ -248,18 +250,19 @@
248 tid, tid
249 );
250
251 if( debugFlag ){
252 db_prepare(&q,
253 "SELECT rowid, fn, fnt, chnged, ridv, ridt FROM fv"
254 );
255 while( db_step(&q)==SQLITE_ROW ){
256 printf("%3d: ridv=%-4d ridt=%-4d chnged=%d\n",
257 db_column_int(&q, 0),
258 db_column_int(&q, 4),
259 db_column_int(&q, 5),
260 db_column_int(&q, 3));
 
261 printf(" fnv = [%s]\n", db_column_text(&q, 1));
262 printf(" fnt = [%s]\n", db_column_text(&q, 2));
263 }
264 db_finalize(&q);
265 }
@@ -299,11 +302,11 @@
299 /*
300 ** Alter the content of the checkout so that it conforms with the
301 ** target
302 */
303 db_prepare(&q,
304 "SELECT fn, idv, ridv, idt, ridt, chnged, fnt FROM fv ORDER BY 1"
305 );
306 db_prepare(&mtimeXfer,
307 "UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
308 " WHERE id=:idt"
309 );
@@ -316,10 +319,11 @@
316 int ridv = db_column_int(&q, 2); /* RecordID for current */
317 int idt = db_column_int(&q, 3); /* VFILE entry for target */
318 int ridt = db_column_int(&q, 4); /* RecordID for target */
319 int chnged = db_column_int(&q, 5); /* Current is edited */
320 const char *zNewName = db_column_text(&q,6);/* New filename */
 
321 char *zFullPath; /* Full pathname of the file */
322 char *zFullNewPath; /* Full pathname of dest */
323 char nameChng; /* True if the name changed */
324
325 zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -374,17 +378,23 @@
374 undo_save(zName);
375 content_get(ridt, &t);
376 content_get(ridv, &v);
377 rc = merge_3way(&v, zFullPath, &t, &r);
378 if( rc>=0 ){
379 if( !nochangeFlag ) blob_write_to_file(&r, zFullNewPath);
 
 
 
380 if( rc>0 ){
381 printf("***** %d merge conflicts in %s\n", rc, zNewName);
382 nConflict++;
383 }
384 }else{
385 if( !nochangeFlag ) blob_write_to_file(&t, zFullNewPath);
 
 
 
386 printf("***** Cannot merge binary file %s\n", zNewName);
387 nConflict++;
388 }
389 if( nameChng && !nochangeFlag ) unlink(zFullPath);
390 blob_reset(&v);
391
--- src/update.c
+++ src/update.c
@@ -197,19 +197,21 @@
197 " idv INTEGER," /* VFILE entry for current version */
198 " idt INTEGER," /* VFILE entry for target version */
199 " chnged BOOLEAN," /* True if current version has been edited */
200 " ridv INTEGER," /* Record ID for current version */
201 " ridt INTEGER," /* Record ID for target */
202 " isexe BOOLEAN," /* Does target have execute permission? */
203 " fnt TEXT" /* Filename of same file on target version */
204 ");"
205 );
206
207 /* Add files found in the current version
208 */
209 db_multi_exec(
210 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
211 " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged"
212 " FROM vfile WHERE vid=%d",
213 vid
214 );
215
216 /* Compute file name changes on V->T. Record name changes in files that
217 ** have changed locally.
@@ -229,12 +231,12 @@
231
232 /* Add files found in the target version T but missing from the current
233 ** version V.
234 */
235 db_multi_exec(
236 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
237 " SELECT pathname, pathname, 0, 0, 0, 0, isexe, 0 FROM vfile"
238 " WHERE vid=%d"
239 " AND pathname NOT IN (SELECT fnt FROM fv)",
240 tid
241 );
242
@@ -248,18 +250,19 @@
250 tid, tid
251 );
252
253 if( debugFlag ){
254 db_prepare(&q,
255 "SELECT rowid, fn, fnt, chnged, ridv, ridt, isexe FROM fv"
256 );
257 while( db_step(&q)==SQLITE_ROW ){
258 printf("%3d: ridv=%-4d ridt=%-4d chnged=%d isexe=%d\n",
259 db_column_int(&q, 0),
260 db_column_int(&q, 4),
261 db_column_int(&q, 5),
262 db_column_int(&q, 3),
263 db_column_int(&q, 6));
264 printf(" fnv = [%s]\n", db_column_text(&q, 1));
265 printf(" fnt = [%s]\n", db_column_text(&q, 2));
266 }
267 db_finalize(&q);
268 }
@@ -299,11 +302,11 @@
302 /*
303 ** Alter the content of the checkout so that it conforms with the
304 ** target
305 */
306 db_prepare(&q,
307 "SELECT fn, idv, ridv, idt, ridt, chnged, fnt, isexe FROM fv ORDER BY 1"
308 );
309 db_prepare(&mtimeXfer,
310 "UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
311 " WHERE id=:idt"
312 );
@@ -316,10 +319,11 @@
319 int ridv = db_column_int(&q, 2); /* RecordID for current */
320 int idt = db_column_int(&q, 3); /* VFILE entry for target */
321 int ridt = db_column_int(&q, 4); /* RecordID for target */
322 int chnged = db_column_int(&q, 5); /* Current is edited */
323 const char *zNewName = db_column_text(&q,6);/* New filename */
324 int isexe = db_column_int(&q, 6); /* EXE perm for new file */
325 char *zFullPath; /* Full pathname of the file */
326 char *zFullNewPath; /* Full pathname of dest */
327 char nameChng; /* True if the name changed */
328
329 zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -374,17 +378,23 @@
378 undo_save(zName);
379 content_get(ridt, &t);
380 content_get(ridv, &v);
381 rc = merge_3way(&v, zFullPath, &t, &r);
382 if( rc>=0 ){
383 if( !nochangeFlag ){
384 blob_write_to_file(&r, zFullNewPath);
385 file_setexe(zFullNewPath, isexe);
386 }
387 if( rc>0 ){
388 printf("***** %d merge conflicts in %s\n", rc, zNewName);
389 nConflict++;
390 }
391 }else{
392 if( !nochangeFlag ){
393 blob_write_to_file(&t, zFullNewPath);
394 file_setexe(zFullNewPath, isexe);
395 }
396 printf("***** Cannot merge binary file %s\n", zNewName);
397 nConflict++;
398 }
399 if( nameChng && !nochangeFlag ) unlink(zFullPath);
400 blob_reset(&v);
401

Keyboard Shortcuts

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