Fossil SCM

Try to get the "stash" command using execute permission bits correctly. Continuing work on the "revert" command - but it is still not working quite right. Ticket [baf9b6b11e08c1d0b].

drh 2011-02-28 03:26 UTC exe-permission-fix
Commit ae3409bf49b792daf7bd91c59747c5d049eb3438
3 files changed +3 -2 +4 -2 +7 -3
+3 -2
--- src/add.c
+++ src/add.c
@@ -148,12 +148,13 @@
148148
db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath);
149149
}
150150
#endif
151151
else{
152152
db_multi_exec(
153
- "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)"
154
- "VALUES(%d,0,0,0,%Q)", vid, zPath);
153
+ "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
154
+ "VALUES(%d,0,0,0,%Q,%d)",
155
+ vid, zPath,file_isexe(zName));
155156
}
156157
printf("ADDED %s\n", zPath);
157158
}
158159
blob_reset(&pathname);
159160
}
160161
--- src/add.c
+++ src/add.c
@@ -148,12 +148,13 @@
148 db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath);
149 }
150 #endif
151 else{
152 db_multi_exec(
153 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)"
154 "VALUES(%d,0,0,0,%Q)", vid, zPath);
 
155 }
156 printf("ADDED %s\n", zPath);
157 }
158 blob_reset(&pathname);
159 }
160
--- src/add.c
+++ src/add.c
@@ -148,12 +148,13 @@
148 db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath);
149 }
150 #endif
151 else{
152 db_multi_exec(
153 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)"
154 "VALUES(%d,0,0,0,%Q,%d)",
155 vid, zPath,file_isexe(zName));
156 }
157 printf("ADDED %s\n", zPath);
158 }
159 blob_reset(&pathname);
160 }
161
+4 -2
--- src/stash.c
+++ src/stash.c
@@ -92,13 +92,11 @@
9292
Blob content;
9393
9494
db_bind_int(&ins, ":rid", rid);
9595
db_bind_int(&ins, ":isadd", rid==0);
9696
db_bind_int(&ins, ":isrm", deleted);
97
-#ifdef _WIN32
9897
db_bind_int(&ins, ":isexe", db_column_int(&q, 1));
99
-#endif
10098
db_bind_text(&ins, ":orig", zOrig);
10199
db_bind_text(&ins, ":new", zName);
102100
if( rid==0 ){
103101
/* A new file */
104102
blob_read_from_file(&content, zPath);
@@ -175,10 +173,11 @@
175173
stashid
176174
);
177175
while( db_step(&q)==SQLITE_ROW ){
178176
int rid = db_column_int(&q, 0);
179177
int isRemoved = db_column_int(&q, 1);
178
+ int isExec = db_column_int(&q, 2);
180179
const char *zOrig = db_column_text(&q, 3);
181180
const char *zNew = db_column_text(&q, 4);
182181
char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
183182
char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
184183
Blob delta;
@@ -185,10 +184,11 @@
185184
undo_save(zNew);
186185
blob_zero(&delta);
187186
if( rid==0 ){
188187
db_ephemeral_blob(&q, 5, &delta);
189188
blob_write_to_file(&delta, zNPath);
189
+ file_setexe(zNPath, isExec);
190190
printf("ADD %s\n", zNew);
191191
}else if( isRemoved ){
192192
printf("DELETE %s\n", zOrig);
193193
unlink(zOPath);
194194
}else{
@@ -197,14 +197,16 @@
197197
blob_read_from_file(&disk, zOPath);
198198
content_get(rid, &a);
199199
blob_delta_apply(&a, &delta, &b);
200200
if( blob_compare(&disk, &a)==0 ){
201201
blob_write_to_file(&b, zNPath);
202
+ file_setexe(zNPath, isExec);
202203
printf("UPDATE %s\n", zNew);
203204
}else{
204205
int rc = merge_3way(&a, zOPath, &b, &out);
205206
blob_write_to_file(&out, zNPath);
207
+ file_setexe(zNPath, isExec);
206208
if( rc ){
207209
printf("CONFLICT %s\n", zNew);
208210
nConflict++;
209211
}else{
210212
printf("MERGE %s\n", zNew);
211213
--- src/stash.c
+++ src/stash.c
@@ -92,13 +92,11 @@
92 Blob content;
93
94 db_bind_int(&ins, ":rid", rid);
95 db_bind_int(&ins, ":isadd", rid==0);
96 db_bind_int(&ins, ":isrm", deleted);
97 #ifdef _WIN32
98 db_bind_int(&ins, ":isexe", db_column_int(&q, 1));
99 #endif
100 db_bind_text(&ins, ":orig", zOrig);
101 db_bind_text(&ins, ":new", zName);
102 if( rid==0 ){
103 /* A new file */
104 blob_read_from_file(&content, zPath);
@@ -175,10 +173,11 @@
175 stashid
176 );
177 while( db_step(&q)==SQLITE_ROW ){
178 int rid = db_column_int(&q, 0);
179 int isRemoved = db_column_int(&q, 1);
 
180 const char *zOrig = db_column_text(&q, 3);
181 const char *zNew = db_column_text(&q, 4);
182 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
183 char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
184 Blob delta;
@@ -185,10 +184,11 @@
185 undo_save(zNew);
186 blob_zero(&delta);
187 if( rid==0 ){
188 db_ephemeral_blob(&q, 5, &delta);
189 blob_write_to_file(&delta, zNPath);
 
190 printf("ADD %s\n", zNew);
191 }else if( isRemoved ){
192 printf("DELETE %s\n", zOrig);
193 unlink(zOPath);
194 }else{
@@ -197,14 +197,16 @@
197 blob_read_from_file(&disk, zOPath);
198 content_get(rid, &a);
199 blob_delta_apply(&a, &delta, &b);
200 if( blob_compare(&disk, &a)==0 ){
201 blob_write_to_file(&b, zNPath);
 
202 printf("UPDATE %s\n", zNew);
203 }else{
204 int rc = merge_3way(&a, zOPath, &b, &out);
205 blob_write_to_file(&out, zNPath);
 
206 if( rc ){
207 printf("CONFLICT %s\n", zNew);
208 nConflict++;
209 }else{
210 printf("MERGE %s\n", zNew);
211
--- src/stash.c
+++ src/stash.c
@@ -92,13 +92,11 @@
92 Blob content;
93
94 db_bind_int(&ins, ":rid", rid);
95 db_bind_int(&ins, ":isadd", rid==0);
96 db_bind_int(&ins, ":isrm", deleted);
 
97 db_bind_int(&ins, ":isexe", db_column_int(&q, 1));
 
98 db_bind_text(&ins, ":orig", zOrig);
99 db_bind_text(&ins, ":new", zName);
100 if( rid==0 ){
101 /* A new file */
102 blob_read_from_file(&content, zPath);
@@ -175,10 +173,11 @@
173 stashid
174 );
175 while( db_step(&q)==SQLITE_ROW ){
176 int rid = db_column_int(&q, 0);
177 int isRemoved = db_column_int(&q, 1);
178 int isExec = db_column_int(&q, 2);
179 const char *zOrig = db_column_text(&q, 3);
180 const char *zNew = db_column_text(&q, 4);
181 char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
182 char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
183 Blob delta;
@@ -185,10 +184,11 @@
184 undo_save(zNew);
185 blob_zero(&delta);
186 if( rid==0 ){
187 db_ephemeral_blob(&q, 5, &delta);
188 blob_write_to_file(&delta, zNPath);
189 file_setexe(zNPath, isExec);
190 printf("ADD %s\n", zNew);
191 }else if( isRemoved ){
192 printf("DELETE %s\n", zOrig);
193 unlink(zOPath);
194 }else{
@@ -197,14 +197,16 @@
197 blob_read_from_file(&disk, zOPath);
198 content_get(rid, &a);
199 blob_delta_apply(&a, &delta, &b);
200 if( blob_compare(&disk, &a)==0 ){
201 blob_write_to_file(&b, zNPath);
202 file_setexe(zNPath, isExec);
203 printf("UPDATE %s\n", zNew);
204 }else{
205 int rc = merge_3way(&a, zOPath, &b, &out);
206 blob_write_to_file(&out, zNPath);
207 file_setexe(zNPath, isExec);
208 if( rc ){
209 printf("CONFLICT %s\n", zNew);
210 nConflict++;
211 }else{
212 printf("MERGE %s\n", zNew);
213
+7 -3
--- src/update.c
+++ src/update.c
@@ -564,17 +564,21 @@
564564
int vid = db_lget_int("checkout", 0);
565565
zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
566566
}
567567
while( db_step(&q)==SQLITE_ROW ){
568568
int isExe = 0;
569
+ char *zFull;
569570
zFile = db_column_text(&q, 0);
571
+ zFull = mprintf("%/%/", g.zLocalRoot, zFile);
570572
errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
571573
if( errCode==2 ){
572
- fossil_warning("file not in repository: %s", zFile);
574
+ undo_save(zFile);
575
+ unlink(zFull);
576
+ printf("DELETE: %s\n", zFile);
577
+ db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
573578
}else{
574579
sqlite3_int64 mtime;
575
- char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
576580
undo_save(zFile);
577581
blob_write_to_file(&record, zFull);
578582
file_setexe(zFull, isExe);
579583
printf("REVERTED: %s\n", zFile);
580584
mtime = file_mtime(zFull);
@@ -583,13 +587,13 @@
583587
" SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
584588
" pathname=coalesce(origname,pathname), origname=NULL"
585589
" WHERE pathname=%Q",
586590
mtime, isExe, zFile
587591
);
588
- free(zFull);
589592
}
590593
blob_reset(&record);
594
+ free(zFull);
591595
}
592596
db_finalize(&q);
593597
undo_finish();
594598
db_end_transaction(0);
595599
}
596600
--- src/update.c
+++ src/update.c
@@ -564,17 +564,21 @@
564 int vid = db_lget_int("checkout", 0);
565 zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
566 }
567 while( db_step(&q)==SQLITE_ROW ){
568 int isExe = 0;
 
569 zFile = db_column_text(&q, 0);
 
570 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
571 if( errCode==2 ){
572 fossil_warning("file not in repository: %s", zFile);
 
 
 
573 }else{
574 sqlite3_int64 mtime;
575 char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
576 undo_save(zFile);
577 blob_write_to_file(&record, zFull);
578 file_setexe(zFull, isExe);
579 printf("REVERTED: %s\n", zFile);
580 mtime = file_mtime(zFull);
@@ -583,13 +587,13 @@
583 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
584 " pathname=coalesce(origname,pathname), origname=NULL"
585 " WHERE pathname=%Q",
586 mtime, isExe, zFile
587 );
588 free(zFull);
589 }
590 blob_reset(&record);
 
591 }
592 db_finalize(&q);
593 undo_finish();
594 db_end_transaction(0);
595 }
596
--- src/update.c
+++ src/update.c
@@ -564,17 +564,21 @@
564 int vid = db_lget_int("checkout", 0);
565 zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
566 }
567 while( db_step(&q)==SQLITE_ROW ){
568 int isExe = 0;
569 char *zFull;
570 zFile = db_column_text(&q, 0);
571 zFull = mprintf("%/%/", g.zLocalRoot, zFile);
572 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
573 if( errCode==2 ){
574 undo_save(zFile);
575 unlink(zFull);
576 printf("DELETE: %s\n", zFile);
577 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
578 }else{
579 sqlite3_int64 mtime;
 
580 undo_save(zFile);
581 blob_write_to_file(&record, zFull);
582 file_setexe(zFull, isExe);
583 printf("REVERTED: %s\n", zFile);
584 mtime = file_mtime(zFull);
@@ -583,13 +587,13 @@
587 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
588 " pathname=coalesce(origname,pathname), origname=NULL"
589 " WHERE pathname=%Q",
590 mtime, isExe, zFile
591 );
 
592 }
593 blob_reset(&record);
594 free(zFull);
595 }
596 db_finalize(&q);
597 undo_finish();
598 db_end_transaction(0);
599 }
600

Keyboard Shortcuts

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