Fossil SCM

Added revert command, currently only offering revert to current version. Organized todo.txt a bit, added new bug report

jnc 2007-09-24 17:11 trunk
Commit 255bacf9078d3c4c4b6fdf1cf6ac95e5e038e1d6
2 files changed +54 +28 -10
+54
--- src/update.c
+++ src/update.c
@@ -211,5 +211,59 @@
211211
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
212212
manifest_to_disk(tid);
213213
db_lset_int("checkout", tid);
214214
db_end_transaction(0);
215215
}
216
+
217
+/*
218
+** COMMAND: revert
219
+**
220
+** Usage: %fossil revert ?-yes FILE
221
+**
222
+** Revert to the current repository version of FILE. This
223
+** command will confirm your operation, unless you do so
224
+** at the command line via the -yes option.
225
+**/
226
+void revert_cmd(void){
227
+ const char *zFile;
228
+ Blob fname;
229
+ Blob record;
230
+ Blob ans;
231
+ int rid, yesRevert;
232
+
233
+ yesRevert = find_option("yes","y", 0)!=0;
234
+ verify_all_options();
235
+
236
+ if( g.argc<3 ){
237
+ usage("?OPTIONS FILE");
238
+ }
239
+ db_must_be_within_tree();
240
+
241
+ zFile = g.argv[g.argc-1];
242
+ if( !file_tree_name(zFile, &fname) ){
243
+ fossil_panic("unknown file: %s", zFile);
244
+ }
245
+ rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
246
+
247
+ if( rid==0 ){
248
+ fossil_panic("no history for file: %b", &fname);
249
+ }
250
+
251
+ if( yesRevert==0 ){
252
+ char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ",
253
+ &fname);
254
+ blob_zero(&ans);
255
+ prompt_user(prompt, &ans);
256
+ if( blob_str(&ans)[0]=='y' ){
257
+ yesRevert = 1;
258
+ }
259
+ }
260
+ if( yesRevert==1 ){
261
+ content_get(rid, &record);
262
+ blob_write_to_file(&record, blob_str(&fname));
263
+ printf("%s reverted\n", blob_str(&fname));
264
+ blob_reset(&record);
265
+ blob_reset(&fname);
266
+ }else{
267
+ printf("revert canceled\n");
268
+ }
269
+}
216270
--- src/update.c
+++ src/update.c
@@ -211,5 +211,59 @@
211 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
212 manifest_to_disk(tid);
213 db_lset_int("checkout", tid);
214 db_end_transaction(0);
215 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
--- src/update.c
+++ src/update.c
@@ -211,5 +211,59 @@
211 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
212 manifest_to_disk(tid);
213 db_lset_int("checkout", tid);
214 db_end_transaction(0);
215 }
216
217 /*
218 ** COMMAND: revert
219 **
220 ** Usage: %fossil revert ?-yes FILE
221 **
222 ** Revert to the current repository version of FILE. This
223 ** command will confirm your operation, unless you do so
224 ** at the command line via the -yes option.
225 **/
226 void revert_cmd(void){
227 const char *zFile;
228 Blob fname;
229 Blob record;
230 Blob ans;
231 int rid, yesRevert;
232
233 yesRevert = find_option("yes","y", 0)!=0;
234 verify_all_options();
235
236 if( g.argc<3 ){
237 usage("?OPTIONS FILE");
238 }
239 db_must_be_within_tree();
240
241 zFile = g.argv[g.argc-1];
242 if( !file_tree_name(zFile, &fname) ){
243 fossil_panic("unknown file: %s", zFile);
244 }
245 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
246
247 if( rid==0 ){
248 fossil_panic("no history for file: %b", &fname);
249 }
250
251 if( yesRevert==0 ){
252 char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ",
253 &fname);
254 blob_zero(&ans);
255 prompt_user(prompt, &ans);
256 if( blob_str(&ans)[0]=='y' ){
257 yesRevert = 1;
258 }
259 }
260 if( yesRevert==1 ){
261 content_get(rid, &record);
262 blob_write_to_file(&record, blob_str(&fname));
263 printf("%s reverted\n", blob_str(&fname));
264 blob_reset(&record);
265 blob_reset(&fname);
266 }else{
267 printf("revert canceled\n");
268 }
269 }
270
+28 -10
--- todo.txt
+++ todo.txt
@@ -1,5 +1,33 @@
1
+Bugs:
2
+
3
+ * When doing an update, if a file is not found that should be there
4
+ then the update aborts, only after it has written several files. It
5
+ does not update your checked out version, thus when doing a fossil
6
+ changes, you see everything that has come over from your update
7
+ command. Steps to reproduce:
8
+
9
+ $ rm src/main.c
10
+ $ fossil update 9b30
11
+ UPDATE ... etc ...
12
+ fossil: no such file: src/main.c
13
+ $ fossil info
14
+ (shows version you were on prior to update)
15
+ $ fossil changes
16
+ EDITED ... many ...
17
+
18
+ * Bug: If the server closes the socket unexpectedly, the
19
+ fwrite() in http.c:103 throws a signal and kills the child
20
+ process. fwrite() is not suppose to do this. Need to figure
21
+ out what is going wrong.
22
+
23
+ * Bug: pull is ending prematurely.
24
+
25
+ * Bug: Make sure merge and other commands (check-out) do not try
26
+ to use a phantom.
27
+
28
+
129
Things to work on:
230
331
* Use the wiki_convert() routine to render comments and other text
432
on web pages.
533
@@ -11,20 +39,10 @@
1139
1240
* If the server returns an error (for example if the outbound /xfer
1341
message exceeds the maximum POST size of the server) the client
1442
does not report this error back to the user as it should.
1543
16
- * Bug: If the server closes the socket unexpectedly, the
17
- fwrite() in http.c:103 throws a signal and kills the child
18
- process. fwrite() is not suppose to do this. Need to figure
19
- out what is going wrong.
20
-
21
- * Bug: pull is ending prematurely.
22
-
23
- * Bug: Make sure merge and other commands (check-out) do not try
24
- to use a phantom.
25
-¿
2644
* The ipaddr field of the rcvfrom table is not being set. This
2745
field should be the IP address from which information is received
2846
for the local repository. So when somebody does a push of new
2947
files we record the ipaddr. Or when we do a pull, we record
3048
the ipaddr.
3149
--- todo.txt
+++ todo.txt
@@ -1,5 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1 Things to work on:
2
3 * Use the wiki_convert() routine to render comments and other text
4 on web pages.
5
@@ -11,20 +39,10 @@
11
12 * If the server returns an error (for example if the outbound /xfer
13 message exceeds the maximum POST size of the server) the client
14 does not report this error back to the user as it should.
15
16 * Bug: If the server closes the socket unexpectedly, the
17 fwrite() in http.c:103 throws a signal and kills the child
18 process. fwrite() is not suppose to do this. Need to figure
19 out what is going wrong.
20
21 * Bug: pull is ending prematurely.
22
23 * Bug: Make sure merge and other commands (check-out) do not try
24 to use a phantom.
25 ¿
26 * The ipaddr field of the rcvfrom table is not being set. This
27 field should be the IP address from which information is received
28 for the local repository. So when somebody does a push of new
29 files we record the ipaddr. Or when we do a pull, we record
30 the ipaddr.
31
--- todo.txt
+++ todo.txt
@@ -1,5 +1,33 @@
1 Bugs:
2
3 * When doing an update, if a file is not found that should be there
4 then the update aborts, only after it has written several files. It
5 does not update your checked out version, thus when doing a fossil
6 changes, you see everything that has come over from your update
7 command. Steps to reproduce:
8
9 $ rm src/main.c
10 $ fossil update 9b30
11 UPDATE ... etc ...
12 fossil: no such file: src/main.c
13 $ fossil info
14 (shows version you were on prior to update)
15 $ fossil changes
16 EDITED ... many ...
17
18 * Bug: If the server closes the socket unexpectedly, the
19 fwrite() in http.c:103 throws a signal and kills the child
20 process. fwrite() is not suppose to do this. Need to figure
21 out what is going wrong.
22
23 * Bug: pull is ending prematurely.
24
25 * Bug: Make sure merge and other commands (check-out) do not try
26 to use a phantom.
27
28
29 Things to work on:
30
31 * Use the wiki_convert() routine to render comments and other text
32 on web pages.
33
@@ -11,20 +39,10 @@
39
40 * If the server returns an error (for example if the outbound /xfer
41 message exceeds the maximum POST size of the server) the client
42 does not report this error back to the user as it should.
43
 
 
 
 
 
 
 
 
 
 
44 * The ipaddr field of the rcvfrom table is not being set. This
45 field should be the IP address from which information is received
46 for the local repository. So when somebody does a push of new
47 files we record the ipaddr. Or when we do a pull, we record
48 the ipaddr.
49

Keyboard Shortcuts

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