Fossil SCM

Merge in changes from the venks-emacs branch.

drh 2010-11-08 00:40 trunk merge
Commit c01e3c17945322b895cbb3ef19cfe079211521bc
+1
--- src/doc.c
+++ src/doc.c
@@ -240,10 +240,11 @@
240240
{ "step", 4, "application/STEP" },
241241
{ "stl", 3, "application/SLA" },
242242
{ "stp", 3, "application/STEP" },
243243
{ "sv4cpio", 7, "application/x-sv4cpio" },
244244
{ "sv4crc", 6, "application/x-sv4crc" },
245
+ { "svg", 3, "image/svg+xml" },
245246
{ "swf", 3, "application/x-shockwave-flash" },
246247
{ "t", 1, "application/x-troff" },
247248
{ "tar", 3, "application/x-tar" },
248249
{ "tcl", 3, "application/x-tcl" },
249250
{ "tex", 3, "application/x-tex" },
250251
--- src/doc.c
+++ src/doc.c
@@ -240,10 +240,11 @@
240 { "step", 4, "application/STEP" },
241 { "stl", 3, "application/SLA" },
242 { "stp", 3, "application/STEP" },
243 { "sv4cpio", 7, "application/x-sv4cpio" },
244 { "sv4crc", 6, "application/x-sv4crc" },
 
245 { "swf", 3, "application/x-shockwave-flash" },
246 { "t", 1, "application/x-troff" },
247 { "tar", 3, "application/x-tar" },
248 { "tcl", 3, "application/x-tcl" },
249 { "tex", 3, "application/x-tex" },
250
--- src/doc.c
+++ src/doc.c
@@ -240,10 +240,11 @@
240 { "step", 4, "application/STEP" },
241 { "stl", 3, "application/SLA" },
242 { "stp", 3, "application/STEP" },
243 { "sv4cpio", 7, "application/x-sv4cpio" },
244 { "sv4crc", 6, "application/x-sv4crc" },
245 { "svg", 3, "image/svg+xml" },
246 { "swf", 3, "application/x-shockwave-flash" },
247 { "t", 1, "application/x-troff" },
248 { "tar", 3, "application/x-tar" },
249 { "tcl", 3, "application/x-tcl" },
250 { "tex", 3, "application/x-tex" },
251
+146 -53
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
2121
#include "finfo.h"
2222
2323
/*
2424
** COMMAND: finfo
2525
**
26
-** Usage: %fossil finfo FILENAME
26
+** Usage: %fossil finfo {?-l|--log? / -s|--status / --p|--print} FILENAME
27
+**
28
+** Print the complete change history for a single file going backwards
29
+** in time. The default is -l.
30
+**
31
+** For the -l|--log option: If "-b|--brief" is specified one line per revision
32
+** is printed, otherwise the full comment is printed. The "--limit N"
33
+** and "--offset P" options limits the output to the first N changes
34
+** after skipping P changes.
2735
**
28
-** Print the change history for a single file.
36
+** In the -s form prints the status as <status> <revision>. This is
37
+** a quick status and does not check for up-to-date-ness of the file.
2938
**
30
-** The "--limit N" and "--offset P" options limit the output to the first
31
-** N changes after skipping P changes.
39
+** The -p form, there's an optional flag "-r|--revision REVISION". The
40
+** specified version (or the latest checked out version) is printed to
41
+** stdout.
3242
*/
3343
void finfo_cmd(void){
34
- Stmt q;
3544
int vid;
36
- Blob dest;
37
- const char *zFilename;
38
- const char *zLimit;
39
- const char *zOffset;
40
- int iLimit, iOffset;
4145
4246
db_must_be_within_tree();
4347
vid = db_lget_int("checkout", 0);
4448
if( vid==0 ){
4549
fossil_panic("no checkout to finfo files in");
4650
}
47
- zLimit = find_option("limit",0,1);
48
- iLimit = zLimit ? atoi(zLimit) : -1;
49
- zOffset = find_option("offset",0,1);
50
- iOffset = zOffset ? atoi(zOffset) : 0;
51
- if (g.argc<3) {
52
- usage("FILENAME");
53
- }
54
- file_tree_name(g.argv[2], &dest, 1);
55
- zFilename = blob_str(&dest);
56
- db_prepare(&q,
57
- "SELECT "
58
- " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
59
- " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
60
- " date(event.mtime,'localtime'),"
61
- " coalesce(event.ecomment, event.comment),"
62
- " coalesce(event.euser, event.user)"
63
- " FROM mlink, event"
64
- " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
65
- " AND event.objid=mlink.mid"
66
- " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
67
- zFilename, iLimit, iOffset
68
- );
69
-
70
- printf("History of %s\n", zFilename);
71
- while( db_step(&q)==SQLITE_ROW ){
72
- const char *zFileUuid = db_column_text(&q, 0);
73
- const char *zCiUuid = db_column_text(&q, 1);
74
- const char *zDate = db_column_text(&q, 2);
75
- const char *zCom = db_column_text(&q, 3);
76
- const char *zUser = db_column_text(&q, 4);
77
- char *zOut;
78
- printf("%s ", zDate);
79
- if( zFileUuid==0 ){
80
- zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
81
- zCiUuid, zCom, zUser);
51
+ vfile_check_signature(vid, 1);
52
+ if (find_option("status","s",0)) {
53
+ Stmt q;
54
+ Blob line;
55
+ Blob fname;
56
+
57
+ if( g.argc!=3 ) usage("-s|--status FILENAME");
58
+ file_tree_name(g.argv[2], &fname, 1);
59
+ db_prepare(&q,
60
+ "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
61
+ " FROM vfile WHERE vfile.pathname=%B", &fname);
62
+ blob_zero(&line);
63
+ if ( db_step(&q)==SQLITE_ROW ) {
64
+ Blob uuid;
65
+ int isDeleted = db_column_int(&q, 1);
66
+ int isNew = db_column_int(&q,2) == 0;
67
+ int chnged = db_column_int(&q,3);
68
+ int renamed = db_column_int(&q,4);
69
+
70
+ blob_zero(&uuid);
71
+ db_blob(&uuid,
72
+ "SELECT uuid FROM blob, mlink, vfile WHERE "
73
+ "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
74
+ "vfile.pathname=%B",
75
+ &fname
76
+ );
77
+ if( isNew ){
78
+ blob_appendf(&line, "new");
79
+ }else if( isDeleted ){
80
+ blob_appendf(&line, "deleted");
81
+ }else if( renamed ){
82
+ blob_appendf(&line, "renamed");
83
+ }else if( chnged ){
84
+ blob_appendf(&line, "edited");
85
+ }else{
86
+ blob_appendf(&line, "unchanged");
87
+ }
88
+ blob_appendf(&line, " ");
89
+ blob_appendf(&line, " %10.10s", blob_str(&uuid));
90
+ blob_reset(&uuid);
91
+ }else{
92
+ blob_appendf(&line, "unknown 0000000000");
93
+ }
94
+ db_finalize(&q);
95
+ printf("%s\n", blob_str(&line));
96
+ blob_reset(&fname);
97
+ blob_reset(&line);
98
+ }else if( find_option("print","p",0) ){
99
+ Blob record;
100
+ Blob fname;
101
+ const char *zRevision = find_option("revision", "r", 1);
102
+
103
+ file_tree_name(g.argv[2], &fname, 1);
104
+ if( zRevision ){
105
+ historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
82106
}else{
83
- zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
84
- zCiUuid, zCom, zUser, zFileUuid);
85
- }
86
- comment_print(zOut, 11, 79);
87
- sqlite3_free(zOut);
88
- }
89
- db_finalize(&q);
90
- blob_reset(&dest);
107
+ int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
108
+ if( rid==0 ){
109
+ fossil_fatal("no history for file: %b", &fname);
110
+ }
111
+ content_get(rid, &record);
112
+ }
113
+ blob_write_to_file(&record, "-");
114
+ blob_reset(&record);
115
+ blob_reset(&fname);
116
+ }else{
117
+ Blob line;
118
+ Stmt q;
119
+ Blob fname;
120
+ int rid;
121
+ const char *zFilename;
122
+ const char *zLimit;
123
+ const char *zOffset;
124
+ int iLimit, iOffset, iBrief;
125
+
126
+ if( find_option("log","l",0) ){
127
+ /* this is the default, no-op */
128
+ }
129
+ zLimit = find_option("limit",0,1);
130
+ iLimit = zLimit ? atoi(zLimit) : -1;
131
+ zOffset = find_option("offset",0,1);
132
+ iOffset = zOffset ? atoi(zOffset) : 0;
133
+ iBrief = (find_option("brief","b",0) == 0);
134
+ if( g.argc!=3 ){
135
+ usage("?-l|--log? ?-b|--brief? FILENAME");
136
+ }
137
+ file_tree_name(g.argv[2], &fname, 1);
138
+ rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
139
+ if( rid==0 ){
140
+ fossil_fatal("no history for file: %b", &fname);
141
+ }
142
+ zFilename = blob_str(&fname);
143
+ db_prepare(&q,
144
+ "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
145
+ " coalesce(event.ecomment, event.comment),"
146
+ " coalesce(event.euser, event.user)"
147
+ " FROM mlink, blob b, event, blob ci"
148
+ " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
149
+ " AND b.rid=mlink.fid"
150
+ " AND event.objid=mlink.mid"
151
+ " AND event.objid=ci.rid"
152
+ " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153
+ zFilename, iLimit, iOffset
154
+ );
155
+ blob_zero(&line);
156
+ if( iBrief ){
157
+ printf("History of %s\n", blob_str(&fname));
158
+ }
159
+ while( db_step(&q)==SQLITE_ROW ){
160
+ const char *zFileUuid = db_column_text(&q, 0);
161
+ const char *zCiUuid = db_column_text(&q,1);
162
+ const char *zDate = db_column_text(&q, 2);
163
+ const char *zCom = db_column_text(&q, 3);
164
+ const char *zUser = db_column_text(&q, 4);
165
+ char *zOut;
166
+ if( iBrief ){
167
+ printf("%s ", zDate);
168
+ zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169
+ zCiUuid, zCom, zUser, zFileUuid);
170
+ comment_print(zOut, 11, 79);
171
+ sqlite3_free(zOut);
172
+ }else{
173
+ blob_reset(&line);
174
+ blob_appendf(&line, "%.10s ", zCiUuid);
175
+ blob_appendf(&line, "%.10s ", zDate);
176
+ blob_appendf(&line, "%8.8s ", zUser);
177
+ blob_appendf(&line,"%-40.40s\n", zCom );
178
+ comment_print(blob_str(&line), 0, 79);
179
+ }
180
+ }
181
+ db_finalize(&q);
182
+ blob_reset(&fname);
183
+ }
91184
}
92185
93186
94187
/*
95188
** WEBPAGE: finfo
96189
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo FILENAME
 
 
 
 
 
 
 
 
27 **
28 ** Print the change history for a single file.
 
29 **
30 ** The "--limit N" and "--offset P" options limit the output to the first
31 ** N changes after skipping P changes.
 
32 */
33 void finfo_cmd(void){
34 Stmt q;
35 int vid;
36 Blob dest;
37 const char *zFilename;
38 const char *zLimit;
39 const char *zOffset;
40 int iLimit, iOffset;
41
42 db_must_be_within_tree();
43 vid = db_lget_int("checkout", 0);
44 if( vid==0 ){
45 fossil_panic("no checkout to finfo files in");
46 }
47 zLimit = find_option("limit",0,1);
48 iLimit = zLimit ? atoi(zLimit) : -1;
49 zOffset = find_option("offset",0,1);
50 iOffset = zOffset ? atoi(zOffset) : 0;
51 if (g.argc<3) {
52 usage("FILENAME");
53 }
54 file_tree_name(g.argv[2], &dest, 1);
55 zFilename = blob_str(&dest);
56 db_prepare(&q,
57 "SELECT "
58 " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
59 " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
60 " date(event.mtime,'localtime'),"
61 " coalesce(event.ecomment, event.comment),"
62 " coalesce(event.euser, event.user)"
63 " FROM mlink, event"
64 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
65 " AND event.objid=mlink.mid"
66 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
67 zFilename, iLimit, iOffset
68 );
69
70 printf("History of %s\n", zFilename);
71 while( db_step(&q)==SQLITE_ROW ){
72 const char *zFileUuid = db_column_text(&q, 0);
73 const char *zCiUuid = db_column_text(&q, 1);
74 const char *zDate = db_column_text(&q, 2);
75 const char *zCom = db_column_text(&q, 3);
76 const char *zUser = db_column_text(&q, 4);
77 char *zOut;
78 printf("%s ", zDate);
79 if( zFileUuid==0 ){
80 zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
81 zCiUuid, zCom, zUser);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82 }else{
83 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
84 zCiUuid, zCom, zUser, zFileUuid);
85 }
86 comment_print(zOut, 11, 79);
87 sqlite3_free(zOut);
88 }
89 db_finalize(&q);
90 blob_reset(&dest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91 }
92
93
94 /*
95 ** WEBPAGE: finfo
96
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo {?-l|--log? / -s|--status / --p|--print} FILENAME
27 **
28 ** Print the complete change history for a single file going backwards
29 ** in time. The default is -l.
30 **
31 ** For the -l|--log option: If "-b|--brief" is specified one line per revision
32 ** is printed, otherwise the full comment is printed. The "--limit N"
33 ** and "--offset P" options limits the output to the first N changes
34 ** after skipping P changes.
35 **
36 ** In the -s form prints the status as <status> <revision>. This is
37 ** a quick status and does not check for up-to-date-ness of the file.
38 **
39 ** The -p form, there's an optional flag "-r|--revision REVISION". The
40 ** specified version (or the latest checked out version) is printed to
41 ** stdout.
42 */
43 void finfo_cmd(void){
 
44 int vid;
 
 
 
 
 
45
46 db_must_be_within_tree();
47 vid = db_lget_int("checkout", 0);
48 if( vid==0 ){
49 fossil_panic("no checkout to finfo files in");
50 }
51 vfile_check_signature(vid, 1);
52 if (find_option("status","s",0)) {
53 Stmt q;
54 Blob line;
55 Blob fname;
56
57 if( g.argc!=3 ) usage("-s|--status FILENAME");
58 file_tree_name(g.argv[2], &fname, 1);
59 db_prepare(&q,
60 "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
61 " FROM vfile WHERE vfile.pathname=%B", &fname);
62 blob_zero(&line);
63 if ( db_step(&q)==SQLITE_ROW ) {
64 Blob uuid;
65 int isDeleted = db_column_int(&q, 1);
66 int isNew = db_column_int(&q,2) == 0;
67 int chnged = db_column_int(&q,3);
68 int renamed = db_column_int(&q,4);
69
70 blob_zero(&uuid);
71 db_blob(&uuid,
72 "SELECT uuid FROM blob, mlink, vfile WHERE "
73 "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
74 "vfile.pathname=%B",
75 &fname
76 );
77 if( isNew ){
78 blob_appendf(&line, "new");
79 }else if( isDeleted ){
80 blob_appendf(&line, "deleted");
81 }else if( renamed ){
82 blob_appendf(&line, "renamed");
83 }else if( chnged ){
84 blob_appendf(&line, "edited");
85 }else{
86 blob_appendf(&line, "unchanged");
87 }
88 blob_appendf(&line, " ");
89 blob_appendf(&line, " %10.10s", blob_str(&uuid));
90 blob_reset(&uuid);
91 }else{
92 blob_appendf(&line, "unknown 0000000000");
93 }
94 db_finalize(&q);
95 printf("%s\n", blob_str(&line));
96 blob_reset(&fname);
97 blob_reset(&line);
98 }else if( find_option("print","p",0) ){
99 Blob record;
100 Blob fname;
101 const char *zRevision = find_option("revision", "r", 1);
102
103 file_tree_name(g.argv[2], &fname, 1);
104 if( zRevision ){
105 historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
106 }else{
107 int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
108 if( rid==0 ){
109 fossil_fatal("no history for file: %b", &fname);
110 }
111 content_get(rid, &record);
112 }
113 blob_write_to_file(&record, "-");
114 blob_reset(&record);
115 blob_reset(&fname);
116 }else{
117 Blob line;
118 Stmt q;
119 Blob fname;
120 int rid;
121 const char *zFilename;
122 const char *zLimit;
123 const char *zOffset;
124 int iLimit, iOffset, iBrief;
125
126 if( find_option("log","l",0) ){
127 /* this is the default, no-op */
128 }
129 zLimit = find_option("limit",0,1);
130 iLimit = zLimit ? atoi(zLimit) : -1;
131 zOffset = find_option("offset",0,1);
132 iOffset = zOffset ? atoi(zOffset) : 0;
133 iBrief = (find_option("brief","b",0) == 0);
134 if( g.argc!=3 ){
135 usage("?-l|--log? ?-b|--brief? FILENAME");
136 }
137 file_tree_name(g.argv[2], &fname, 1);
138 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
139 if( rid==0 ){
140 fossil_fatal("no history for file: %b", &fname);
141 }
142 zFilename = blob_str(&fname);
143 db_prepare(&q,
144 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
145 " coalesce(event.ecomment, event.comment),"
146 " coalesce(event.euser, event.user)"
147 " FROM mlink, blob b, event, blob ci"
148 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
149 " AND b.rid=mlink.fid"
150 " AND event.objid=mlink.mid"
151 " AND event.objid=ci.rid"
152 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153 zFilename, iLimit, iOffset
154 );
155 blob_zero(&line);
156 if( iBrief ){
157 printf("History of %s\n", blob_str(&fname));
158 }
159 while( db_step(&q)==SQLITE_ROW ){
160 const char *zFileUuid = db_column_text(&q, 0);
161 const char *zCiUuid = db_column_text(&q,1);
162 const char *zDate = db_column_text(&q, 2);
163 const char *zCom = db_column_text(&q, 3);
164 const char *zUser = db_column_text(&q, 4);
165 char *zOut;
166 if( iBrief ){
167 printf("%s ", zDate);
168 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169 zCiUuid, zCom, zUser, zFileUuid);
170 comment_print(zOut, 11, 79);
171 sqlite3_free(zOut);
172 }else{
173 blob_reset(&line);
174 blob_appendf(&line, "%.10s ", zCiUuid);
175 blob_appendf(&line, "%.10s ", zDate);
176 blob_appendf(&line, "%8.8s ", zUser);
177 blob_appendf(&line,"%-40.40s\n", zCom );
178 comment_print(blob_str(&line), 0, 79);
179 }
180 }
181 db_finalize(&q);
182 blob_reset(&fname);
183 }
184 }
185
186
187 /*
188 ** WEBPAGE: finfo
189
+146 -53
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
2121
#include "finfo.h"
2222
2323
/*
2424
** COMMAND: finfo
2525
**
26
-** Usage: %fossil finfo FILENAME
26
+** Usage: %fossil finfo {?-l|--log? / -s|--status / --p|--print} FILENAME
27
+**
28
+** Print the complete change history for a single file going backwards
29
+** in time. The default is -l.
30
+**
31
+** For the -l|--log option: If "-b|--brief" is specified one line per revision
32
+** is printed, otherwise the full comment is printed. The "--limit N"
33
+** and "--offset P" options limits the output to the first N changes
34
+** after skipping P changes.
2735
**
28
-** Print the change history for a single file.
36
+** In the -s form prints the status as <status> <revision>. This is
37
+** a quick status and does not check for up-to-date-ness of the file.
2938
**
30
-** The "--limit N" and "--offset P" options limit the output to the first
31
-** N changes after skipping P changes.
39
+** The -p form, there's an optional flag "-r|--revision REVISION". The
40
+** specified version (or the latest checked out version) is printed to
41
+** stdout.
3242
*/
3343
void finfo_cmd(void){
34
- Stmt q;
3544
int vid;
36
- Blob dest;
37
- const char *zFilename;
38
- const char *zLimit;
39
- const char *zOffset;
40
- int iLimit, iOffset;
4145
4246
db_must_be_within_tree();
4347
vid = db_lget_int("checkout", 0);
4448
if( vid==0 ){
4549
fossil_panic("no checkout to finfo files in");
4650
}
47
- zLimit = find_option("limit",0,1);
48
- iLimit = zLimit ? atoi(zLimit) : -1;
49
- zOffset = find_option("offset",0,1);
50
- iOffset = zOffset ? atoi(zOffset) : 0;
51
- if (g.argc<3) {
52
- usage("FILENAME");
53
- }
54
- file_tree_name(g.argv[2], &dest, 1);
55
- zFilename = blob_str(&dest);
56
- db_prepare(&q,
57
- "SELECT "
58
- " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
59
- " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
60
- " date(event.mtime,'localtime'),"
61
- " coalesce(event.ecomment, event.comment),"
62
- " coalesce(event.euser, event.user)"
63
- " FROM mlink, event"
64
- " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
65
- " AND event.objid=mlink.mid"
66
- " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
67
- zFilename, iLimit, iOffset
68
- );
69
-
70
- printf("History of %s\n", zFilename);
71
- while( db_step(&q)==SQLITE_ROW ){
72
- const char *zFileUuid = db_column_text(&q, 0);
73
- const char *zCiUuid = db_column_text(&q, 1);
74
- const char *zDate = db_column_text(&q, 2);
75
- const char *zCom = db_column_text(&q, 3);
76
- const char *zUser = db_column_text(&q, 4);
77
- char *zOut;
78
- printf("%s ", zDate);
79
- if( zFileUuid==0 ){
80
- zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
81
- zCiUuid, zCom, zUser);
51
+ vfile_check_signature(vid, 1);
52
+ if (find_option("status","s",0)) {
53
+ Stmt q;
54
+ Blob line;
55
+ Blob fname;
56
+
57
+ if( g.argc!=3 ) usage("-s|--status FILENAME");
58
+ file_tree_name(g.argv[2], &fname, 1);
59
+ db_prepare(&q,
60
+ "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
61
+ " FROM vfile WHERE vfile.pathname=%B", &fname);
62
+ blob_zero(&line);
63
+ if ( db_step(&q)==SQLITE_ROW ) {
64
+ Blob uuid;
65
+ int isDeleted = db_column_int(&q, 1);
66
+ int isNew = db_column_int(&q,2) == 0;
67
+ int chnged = db_column_int(&q,3);
68
+ int renamed = db_column_int(&q,4);
69
+
70
+ blob_zero(&uuid);
71
+ db_blob(&uuid,
72
+ "SELECT uuid FROM blob, mlink, vfile WHERE "
73
+ "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
74
+ "vfile.pathname=%B",
75
+ &fname
76
+ );
77
+ if( isNew ){
78
+ blob_appendf(&line, "new");
79
+ }else if( isDeleted ){
80
+ blob_appendf(&line, "deleted");
81
+ }else if( renamed ){
82
+ blob_appendf(&line, "renamed");
83
+ }else if( chnged ){
84
+ blob_appendf(&line, "edited");
85
+ }else{
86
+ blob_appendf(&line, "unchanged");
87
+ }
88
+ blob_appendf(&line, " ");
89
+ blob_appendf(&line, " %10.10s", blob_str(&uuid));
90
+ blob_reset(&uuid);
91
+ }else{
92
+ blob_appendf(&line, "unknown 0000000000");
93
+ }
94
+ db_finalize(&q);
95
+ printf("%s\n", blob_str(&line));
96
+ blob_reset(&fname);
97
+ blob_reset(&line);
98
+ }else if( find_option("print","p",0) ){
99
+ Blob record;
100
+ Blob fname;
101
+ const char *zRevision = find_option("revision", "r", 1);
102
+
103
+ file_tree_name(g.argv[2], &fname, 1);
104
+ if( zRevision ){
105
+ historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
82106
}else{
83
- zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
84
- zCiUuid, zCom, zUser, zFileUuid);
85
- }
86
- comment_print(zOut, 11, 79);
87
- sqlite3_free(zOut);
88
- }
89
- db_finalize(&q);
90
- blob_reset(&dest);
107
+ int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
108
+ if( rid==0 ){
109
+ fossil_fatal("no history for file: %b", &fname);
110
+ }
111
+ content_get(rid, &record);
112
+ }
113
+ blob_write_to_file(&record, "-");
114
+ blob_reset(&record);
115
+ blob_reset(&fname);
116
+ }else{
117
+ Blob line;
118
+ Stmt q;
119
+ Blob fname;
120
+ int rid;
121
+ const char *zFilename;
122
+ const char *zLimit;
123
+ const char *zOffset;
124
+ int iLimit, iOffset, iBrief;
125
+
126
+ if( find_option("log","l",0) ){
127
+ /* this is the default, no-op */
128
+ }
129
+ zLimit = find_option("limit",0,1);
130
+ iLimit = zLimit ? atoi(zLimit) : -1;
131
+ zOffset = find_option("offset",0,1);
132
+ iOffset = zOffset ? atoi(zOffset) : 0;
133
+ iBrief = (find_option("brief","b",0) == 0);
134
+ if( g.argc!=3 ){
135
+ usage("?-l|--log? ?-b|--brief? FILENAME");
136
+ }
137
+ file_tree_name(g.argv[2], &fname, 1);
138
+ rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
139
+ if( rid==0 ){
140
+ fossil_fatal("no history for file: %b", &fname);
141
+ }
142
+ zFilename = blob_str(&fname);
143
+ db_prepare(&q,
144
+ "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
145
+ " coalesce(event.ecomment, event.comment),"
146
+ " coalesce(event.euser, event.user)"
147
+ " FROM mlink, blob b, event, blob ci"
148
+ " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
149
+ " AND b.rid=mlink.fid"
150
+ " AND event.objid=mlink.mid"
151
+ " AND event.objid=ci.rid"
152
+ " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153
+ zFilename, iLimit, iOffset
154
+ );
155
+ blob_zero(&line);
156
+ if( iBrief ){
157
+ printf("History of %s\n", blob_str(&fname));
158
+ }
159
+ while( db_step(&q)==SQLITE_ROW ){
160
+ const char *zFileUuid = db_column_text(&q, 0);
161
+ const char *zCiUuid = db_column_text(&q,1);
162
+ const char *zDate = db_column_text(&q, 2);
163
+ const char *zCom = db_column_text(&q, 3);
164
+ const char *zUser = db_column_text(&q, 4);
165
+ char *zOut;
166
+ if( iBrief ){
167
+ printf("%s ", zDate);
168
+ zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169
+ zCiUuid, zCom, zUser, zFileUuid);
170
+ comment_print(zOut, 11, 79);
171
+ sqlite3_free(zOut);
172
+ }else{
173
+ blob_reset(&line);
174
+ blob_appendf(&line, "%.10s ", zCiUuid);
175
+ blob_appendf(&line, "%.10s ", zDate);
176
+ blob_appendf(&line, "%8.8s ", zUser);
177
+ blob_appendf(&line,"%-40.40s\n", zCom );
178
+ comment_print(blob_str(&line), 0, 79);
179
+ }
180
+ }
181
+ db_finalize(&q);
182
+ blob_reset(&fname);
183
+ }
91184
}
92185
93186
94187
/*
95188
** WEBPAGE: finfo
96189
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo FILENAME
 
 
 
 
 
 
 
 
27 **
28 ** Print the change history for a single file.
 
29 **
30 ** The "--limit N" and "--offset P" options limit the output to the first
31 ** N changes after skipping P changes.
 
32 */
33 void finfo_cmd(void){
34 Stmt q;
35 int vid;
36 Blob dest;
37 const char *zFilename;
38 const char *zLimit;
39 const char *zOffset;
40 int iLimit, iOffset;
41
42 db_must_be_within_tree();
43 vid = db_lget_int("checkout", 0);
44 if( vid==0 ){
45 fossil_panic("no checkout to finfo files in");
46 }
47 zLimit = find_option("limit",0,1);
48 iLimit = zLimit ? atoi(zLimit) : -1;
49 zOffset = find_option("offset",0,1);
50 iOffset = zOffset ? atoi(zOffset) : 0;
51 if (g.argc<3) {
52 usage("FILENAME");
53 }
54 file_tree_name(g.argv[2], &dest, 1);
55 zFilename = blob_str(&dest);
56 db_prepare(&q,
57 "SELECT "
58 " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
59 " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
60 " date(event.mtime,'localtime'),"
61 " coalesce(event.ecomment, event.comment),"
62 " coalesce(event.euser, event.user)"
63 " FROM mlink, event"
64 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
65 " AND event.objid=mlink.mid"
66 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
67 zFilename, iLimit, iOffset
68 );
69
70 printf("History of %s\n", zFilename);
71 while( db_step(&q)==SQLITE_ROW ){
72 const char *zFileUuid = db_column_text(&q, 0);
73 const char *zCiUuid = db_column_text(&q, 1);
74 const char *zDate = db_column_text(&q, 2);
75 const char *zCom = db_column_text(&q, 3);
76 const char *zUser = db_column_text(&q, 4);
77 char *zOut;
78 printf("%s ", zDate);
79 if( zFileUuid==0 ){
80 zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
81 zCiUuid, zCom, zUser);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82 }else{
83 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
84 zCiUuid, zCom, zUser, zFileUuid);
85 }
86 comment_print(zOut, 11, 79);
87 sqlite3_free(zOut);
88 }
89 db_finalize(&q);
90 blob_reset(&dest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91 }
92
93
94 /*
95 ** WEBPAGE: finfo
96
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,168 @@
21 #include "finfo.h"
22
23 /*
24 ** COMMAND: finfo
25 **
26 ** Usage: %fossil finfo {?-l|--log? / -s|--status / --p|--print} FILENAME
27 **
28 ** Print the complete change history for a single file going backwards
29 ** in time. The default is -l.
30 **
31 ** For the -l|--log option: If "-b|--brief" is specified one line per revision
32 ** is printed, otherwise the full comment is printed. The "--limit N"
33 ** and "--offset P" options limits the output to the first N changes
34 ** after skipping P changes.
35 **
36 ** In the -s form prints the status as <status> <revision>. This is
37 ** a quick status and does not check for up-to-date-ness of the file.
38 **
39 ** The -p form, there's an optional flag "-r|--revision REVISION". The
40 ** specified version (or the latest checked out version) is printed to
41 ** stdout.
42 */
43 void finfo_cmd(void){
 
44 int vid;
 
 
 
 
 
45
46 db_must_be_within_tree();
47 vid = db_lget_int("checkout", 0);
48 if( vid==0 ){
49 fossil_panic("no checkout to finfo files in");
50 }
51 vfile_check_signature(vid, 1);
52 if (find_option("status","s",0)) {
53 Stmt q;
54 Blob line;
55 Blob fname;
56
57 if( g.argc!=3 ) usage("-s|--status FILENAME");
58 file_tree_name(g.argv[2], &fname, 1);
59 db_prepare(&q,
60 "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
61 " FROM vfile WHERE vfile.pathname=%B", &fname);
62 blob_zero(&line);
63 if ( db_step(&q)==SQLITE_ROW ) {
64 Blob uuid;
65 int isDeleted = db_column_int(&q, 1);
66 int isNew = db_column_int(&q,2) == 0;
67 int chnged = db_column_int(&q,3);
68 int renamed = db_column_int(&q,4);
69
70 blob_zero(&uuid);
71 db_blob(&uuid,
72 "SELECT uuid FROM blob, mlink, vfile WHERE "
73 "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
74 "vfile.pathname=%B",
75 &fname
76 );
77 if( isNew ){
78 blob_appendf(&line, "new");
79 }else if( isDeleted ){
80 blob_appendf(&line, "deleted");
81 }else if( renamed ){
82 blob_appendf(&line, "renamed");
83 }else if( chnged ){
84 blob_appendf(&line, "edited");
85 }else{
86 blob_appendf(&line, "unchanged");
87 }
88 blob_appendf(&line, " ");
89 blob_appendf(&line, " %10.10s", blob_str(&uuid));
90 blob_reset(&uuid);
91 }else{
92 blob_appendf(&line, "unknown 0000000000");
93 }
94 db_finalize(&q);
95 printf("%s\n", blob_str(&line));
96 blob_reset(&fname);
97 blob_reset(&line);
98 }else if( find_option("print","p",0) ){
99 Blob record;
100 Blob fname;
101 const char *zRevision = find_option("revision", "r", 1);
102
103 file_tree_name(g.argv[2], &fname, 1);
104 if( zRevision ){
105 historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
106 }else{
107 int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
108 if( rid==0 ){
109 fossil_fatal("no history for file: %b", &fname);
110 }
111 content_get(rid, &record);
112 }
113 blob_write_to_file(&record, "-");
114 blob_reset(&record);
115 blob_reset(&fname);
116 }else{
117 Blob line;
118 Stmt q;
119 Blob fname;
120 int rid;
121 const char *zFilename;
122 const char *zLimit;
123 const char *zOffset;
124 int iLimit, iOffset, iBrief;
125
126 if( find_option("log","l",0) ){
127 /* this is the default, no-op */
128 }
129 zLimit = find_option("limit",0,1);
130 iLimit = zLimit ? atoi(zLimit) : -1;
131 zOffset = find_option("offset",0,1);
132 iOffset = zOffset ? atoi(zOffset) : 0;
133 iBrief = (find_option("brief","b",0) == 0);
134 if( g.argc!=3 ){
135 usage("?-l|--log? ?-b|--brief? FILENAME");
136 }
137 file_tree_name(g.argv[2], &fname, 1);
138 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
139 if( rid==0 ){
140 fossil_fatal("no history for file: %b", &fname);
141 }
142 zFilename = blob_str(&fname);
143 db_prepare(&q,
144 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
145 " coalesce(event.ecomment, event.comment),"
146 " coalesce(event.euser, event.user)"
147 " FROM mlink, blob b, event, blob ci"
148 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
149 " AND b.rid=mlink.fid"
150 " AND event.objid=mlink.mid"
151 " AND event.objid=ci.rid"
152 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
153 zFilename, iLimit, iOffset
154 );
155 blob_zero(&line);
156 if( iBrief ){
157 printf("History of %s\n", blob_str(&fname));
158 }
159 while( db_step(&q)==SQLITE_ROW ){
160 const char *zFileUuid = db_column_text(&q, 0);
161 const char *zCiUuid = db_column_text(&q,1);
162 const char *zDate = db_column_text(&q, 2);
163 const char *zCom = db_column_text(&q, 3);
164 const char *zUser = db_column_text(&q, 4);
165 char *zOut;
166 if( iBrief ){
167 printf("%s ", zDate);
168 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
169 zCiUuid, zCom, zUser, zFileUuid);
170 comment_print(zOut, 11, 79);
171 sqlite3_free(zOut);
172 }else{
173 blob_reset(&line);
174 blob_appendf(&line, "%.10s ", zCiUuid);
175 blob_appendf(&line, "%.10s ", zDate);
176 blob_appendf(&line, "%8.8s ", zUser);
177 blob_appendf(&line,"%-40.40s\n", zCom );
178 comment_print(blob_str(&line), 0, 79);
179 }
180 }
181 db_finalize(&q);
182 blob_reset(&fname);
183 }
184 }
185
186
187 /*
188 ** WEBPAGE: finfo
189
+27 -9
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
4343
** leaf. VERSION can also be "current" to select the leaf of the current
4444
** version or "latest" to select the most recent check-in.
4545
**
4646
** If one or more FILES are listed after the VERSION then only the
4747
** named files are candidates to be updated. If FILES is omitted, all
48
-** files in the current checkout are subject to be updated.
48
+** files in the current checkout are subject to be updated. Using
49
+** a directory name for one of the FILES arguments is the same as
50
+** using every subdirectory and file beneath that directory.
4951
**
5052
** The -n or --nochange option causes this command to do a "dry run". It
5153
** prints out what would have happened but does not actually make any
5254
** changes to the current checkout or the repository.
5355
**
@@ -111,11 +113,11 @@
111113
tid = db_int(0, "SELECT rid FROM leaves, event"
112114
" WHERE event.objid=leaves.rid"
113115
" ORDER BY event.mtime DESC");
114116
}
115117
116
- if( tid==vid ) return; /* Nothing to update */
118
+ if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
117119
db_begin_transaction();
118120
vfile_check_signature(vid, 1);
119121
if( !nochangeFlag ) undo_begin();
120122
load_vfile_from_rid(tid);
121123
@@ -166,27 +168,39 @@
166168
);
167169
}
168170
db_finalize(&q);
169171
170172
/* If FILES appear on the command-line, remove from the "fv" table
171
- ** every entry that is not named on the command-line.
173
+ ** every entry that is not named on the command-line or which is not
174
+ ** in a directory named on the command-line.
172175
*/
173176
if( g.argc>=4 ){
174177
Blob sql; /* SQL statement to purge unwanted entries */
175
- char *zSep = "("; /* Separator in the list of filenames */
176178
Blob treename; /* Normalized filename */
177179
int i; /* Loop counter */
180
+ const char *zSep; /* Term separator */
178181
179182
blob_zero(&sql);
180
- blob_append(&sql, "DELETE FROM fv WHERE fn NOT IN ", -1);
183
+ blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184
+ zSep = "";
181185
for(i=3; i<g.argc; i++){
182186
file_tree_name(g.argv[i], &treename, 1);
183
- blob_appendf(&sql, "%s'%q'", zSep, blob_str(&treename));
187
+ if( file_isdir(g.argv[i])==1 ){
188
+ if( blob_size(&treename)>0 ){
189
+ blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190
+ }else{
191
+ blob_reset(&sql);
192
+ blob_append(&sql, "DELETE FROM fv", -1);
193
+ break;
194
+ }
195
+ }else{
196
+ blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197
+ }
198
+ zSep = "AND ";
184199
blob_reset(&treename);
185
- zSep = ",";
186200
}
187
- blob_append(&sql, ")", -1);
201
+ /* fprintf(stderr, "%s\n", blob_str(&sql)); */
188202
db_multi_exec(blob_str(&sql));
189203
blob_reset(&sql);
190204
}
191205
192206
db_prepare(&q,
@@ -264,11 +278,15 @@
264278
blob_reset(&v);
265279
blob_reset(&e);
266280
blob_reset(&t);
267281
blob_reset(&r);
268282
}else if( verboseFlag ){
269
- printf("UNCHANGED %s\n", zName);
283
+ if( chnged ){
284
+ printf("EDITED %s\n", zName);
285
+ }else{
286
+ printf("UNCHANGED %s\n", zName);
287
+ }
270288
}
271289
free(zFullPath);
272290
}
273291
db_finalize(&q);
274292
275293
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
43 ** leaf. VERSION can also be "current" to select the leaf of the current
44 ** version or "latest" to select the most recent check-in.
45 **
46 ** If one or more FILES are listed after the VERSION then only the
47 ** named files are candidates to be updated. If FILES is omitted, all
48 ** files in the current checkout are subject to be updated.
 
 
49 **
50 ** The -n or --nochange option causes this command to do a "dry run". It
51 ** prints out what would have happened but does not actually make any
52 ** changes to the current checkout or the repository.
53 **
@@ -111,11 +113,11 @@
111 tid = db_int(0, "SELECT rid FROM leaves, event"
112 " WHERE event.objid=leaves.rid"
113 " ORDER BY event.mtime DESC");
114 }
115
116 if( tid==vid ) return; /* Nothing to update */
117 db_begin_transaction();
118 vfile_check_signature(vid, 1);
119 if( !nochangeFlag ) undo_begin();
120 load_vfile_from_rid(tid);
121
@@ -166,27 +168,39 @@
166 );
167 }
168 db_finalize(&q);
169
170 /* If FILES appear on the command-line, remove from the "fv" table
171 ** every entry that is not named on the command-line.
 
172 */
173 if( g.argc>=4 ){
174 Blob sql; /* SQL statement to purge unwanted entries */
175 char *zSep = "("; /* Separator in the list of filenames */
176 Blob treename; /* Normalized filename */
177 int i; /* Loop counter */
 
178
179 blob_zero(&sql);
180 blob_append(&sql, "DELETE FROM fv WHERE fn NOT IN ", -1);
 
181 for(i=3; i<g.argc; i++){
182 file_tree_name(g.argv[i], &treename, 1);
183 blob_appendf(&sql, "%s'%q'", zSep, blob_str(&treename));
 
 
 
 
 
 
 
 
 
 
 
184 blob_reset(&treename);
185 zSep = ",";
186 }
187 blob_append(&sql, ")", -1);
188 db_multi_exec(blob_str(&sql));
189 blob_reset(&sql);
190 }
191
192 db_prepare(&q,
@@ -264,11 +278,15 @@
264 blob_reset(&v);
265 blob_reset(&e);
266 blob_reset(&t);
267 blob_reset(&r);
268 }else if( verboseFlag ){
269 printf("UNCHANGED %s\n", zName);
 
 
 
 
270 }
271 free(zFullPath);
272 }
273 db_finalize(&q);
274
275
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
43 ** leaf. VERSION can also be "current" to select the leaf of the current
44 ** version or "latest" to select the most recent check-in.
45 **
46 ** If one or more FILES are listed after the VERSION then only the
47 ** named files are candidates to be updated. If FILES is omitted, all
48 ** files in the current checkout are subject to be updated. Using
49 ** a directory name for one of the FILES arguments is the same as
50 ** using every subdirectory and file beneath that directory.
51 **
52 ** The -n or --nochange option causes this command to do a "dry run". It
53 ** prints out what would have happened but does not actually make any
54 ** changes to the current checkout or the repository.
55 **
@@ -111,11 +113,11 @@
113 tid = db_int(0, "SELECT rid FROM leaves, event"
114 " WHERE event.objid=leaves.rid"
115 " ORDER BY event.mtime DESC");
116 }
117
118 if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
119 db_begin_transaction();
120 vfile_check_signature(vid, 1);
121 if( !nochangeFlag ) undo_begin();
122 load_vfile_from_rid(tid);
123
@@ -166,27 +168,39 @@
168 );
169 }
170 db_finalize(&q);
171
172 /* If FILES appear on the command-line, remove from the "fv" table
173 ** every entry that is not named on the command-line or which is not
174 ** in a directory named on the command-line.
175 */
176 if( g.argc>=4 ){
177 Blob sql; /* SQL statement to purge unwanted entries */
 
178 Blob treename; /* Normalized filename */
179 int i; /* Loop counter */
180 const char *zSep; /* Term separator */
181
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
187 if( file_isdir(g.argv[i])==1 ){
188 if( blob_size(&treename)>0 ){
189 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190 }else{
191 blob_reset(&sql);
192 blob_append(&sql, "DELETE FROM fv", -1);
193 break;
194 }
195 }else{
196 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197 }
198 zSep = "AND ";
199 blob_reset(&treename);
 
200 }
201 /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202 db_multi_exec(blob_str(&sql));
203 blob_reset(&sql);
204 }
205
206 db_prepare(&q,
@@ -264,11 +278,15 @@
278 blob_reset(&v);
279 blob_reset(&e);
280 blob_reset(&t);
281 blob_reset(&r);
282 }else if( verboseFlag ){
283 if( chnged ){
284 printf("EDITED %s\n", zName);
285 }else{
286 printf("UNCHANGED %s\n", zName);
287 }
288 }
289 free(zFullPath);
290 }
291 db_finalize(&q);
292
293
+27 -9
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
4343
** leaf. VERSION can also be "current" to select the leaf of the current
4444
** version or "latest" to select the most recent check-in.
4545
**
4646
** If one or more FILES are listed after the VERSION then only the
4747
** named files are candidates to be updated. If FILES is omitted, all
48
-** files in the current checkout are subject to be updated.
48
+** files in the current checkout are subject to be updated. Using
49
+** a directory name for one of the FILES arguments is the same as
50
+** using every subdirectory and file beneath that directory.
4951
**
5052
** The -n or --nochange option causes this command to do a "dry run". It
5153
** prints out what would have happened but does not actually make any
5254
** changes to the current checkout or the repository.
5355
**
@@ -111,11 +113,11 @@
111113
tid = db_int(0, "SELECT rid FROM leaves, event"
112114
" WHERE event.objid=leaves.rid"
113115
" ORDER BY event.mtime DESC");
114116
}
115117
116
- if( tid==vid ) return; /* Nothing to update */
118
+ if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
117119
db_begin_transaction();
118120
vfile_check_signature(vid, 1);
119121
if( !nochangeFlag ) undo_begin();
120122
load_vfile_from_rid(tid);
121123
@@ -166,27 +168,39 @@
166168
);
167169
}
168170
db_finalize(&q);
169171
170172
/* If FILES appear on the command-line, remove from the "fv" table
171
- ** every entry that is not named on the command-line.
173
+ ** every entry that is not named on the command-line or which is not
174
+ ** in a directory named on the command-line.
172175
*/
173176
if( g.argc>=4 ){
174177
Blob sql; /* SQL statement to purge unwanted entries */
175
- char *zSep = "("; /* Separator in the list of filenames */
176178
Blob treename; /* Normalized filename */
177179
int i; /* Loop counter */
180
+ const char *zSep; /* Term separator */
178181
179182
blob_zero(&sql);
180
- blob_append(&sql, "DELETE FROM fv WHERE fn NOT IN ", -1);
183
+ blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184
+ zSep = "";
181185
for(i=3; i<g.argc; i++){
182186
file_tree_name(g.argv[i], &treename, 1);
183
- blob_appendf(&sql, "%s'%q'", zSep, blob_str(&treename));
187
+ if( file_isdir(g.argv[i])==1 ){
188
+ if( blob_size(&treename)>0 ){
189
+ blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190
+ }else{
191
+ blob_reset(&sql);
192
+ blob_append(&sql, "DELETE FROM fv", -1);
193
+ break;
194
+ }
195
+ }else{
196
+ blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197
+ }
198
+ zSep = "AND ";
184199
blob_reset(&treename);
185
- zSep = ",";
186200
}
187
- blob_append(&sql, ")", -1);
201
+ /* fprintf(stderr, "%s\n", blob_str(&sql)); */
188202
db_multi_exec(blob_str(&sql));
189203
blob_reset(&sql);
190204
}
191205
192206
db_prepare(&q,
@@ -264,11 +278,15 @@
264278
blob_reset(&v);
265279
blob_reset(&e);
266280
blob_reset(&t);
267281
blob_reset(&r);
268282
}else if( verboseFlag ){
269
- printf("UNCHANGED %s\n", zName);
283
+ if( chnged ){
284
+ printf("EDITED %s\n", zName);
285
+ }else{
286
+ printf("UNCHANGED %s\n", zName);
287
+ }
270288
}
271289
free(zFullPath);
272290
}
273291
db_finalize(&q);
274292
275293
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
43 ** leaf. VERSION can also be "current" to select the leaf of the current
44 ** version or "latest" to select the most recent check-in.
45 **
46 ** If one or more FILES are listed after the VERSION then only the
47 ** named files are candidates to be updated. If FILES is omitted, all
48 ** files in the current checkout are subject to be updated.
 
 
49 **
50 ** The -n or --nochange option causes this command to do a "dry run". It
51 ** prints out what would have happened but does not actually make any
52 ** changes to the current checkout or the repository.
53 **
@@ -111,11 +113,11 @@
111 tid = db_int(0, "SELECT rid FROM leaves, event"
112 " WHERE event.objid=leaves.rid"
113 " ORDER BY event.mtime DESC");
114 }
115
116 if( tid==vid ) return; /* Nothing to update */
117 db_begin_transaction();
118 vfile_check_signature(vid, 1);
119 if( !nochangeFlag ) undo_begin();
120 load_vfile_from_rid(tid);
121
@@ -166,27 +168,39 @@
166 );
167 }
168 db_finalize(&q);
169
170 /* If FILES appear on the command-line, remove from the "fv" table
171 ** every entry that is not named on the command-line.
 
172 */
173 if( g.argc>=4 ){
174 Blob sql; /* SQL statement to purge unwanted entries */
175 char *zSep = "("; /* Separator in the list of filenames */
176 Blob treename; /* Normalized filename */
177 int i; /* Loop counter */
 
178
179 blob_zero(&sql);
180 blob_append(&sql, "DELETE FROM fv WHERE fn NOT IN ", -1);
 
181 for(i=3; i<g.argc; i++){
182 file_tree_name(g.argv[i], &treename, 1);
183 blob_appendf(&sql, "%s'%q'", zSep, blob_str(&treename));
 
 
 
 
 
 
 
 
 
 
 
184 blob_reset(&treename);
185 zSep = ",";
186 }
187 blob_append(&sql, ")", -1);
188 db_multi_exec(blob_str(&sql));
189 blob_reset(&sql);
190 }
191
192 db_prepare(&q,
@@ -264,11 +278,15 @@
264 blob_reset(&v);
265 blob_reset(&e);
266 blob_reset(&t);
267 blob_reset(&r);
268 }else if( verboseFlag ){
269 printf("UNCHANGED %s\n", zName);
 
 
 
 
270 }
271 free(zFullPath);
272 }
273 db_finalize(&q);
274
275
--- src/update.c
+++ src/update.c
@@ -43,11 +43,13 @@
43 ** leaf. VERSION can also be "current" to select the leaf of the current
44 ** version or "latest" to select the most recent check-in.
45 **
46 ** If one or more FILES are listed after the VERSION then only the
47 ** named files are candidates to be updated. If FILES is omitted, all
48 ** files in the current checkout are subject to be updated. Using
49 ** a directory name for one of the FILES arguments is the same as
50 ** using every subdirectory and file beneath that directory.
51 **
52 ** The -n or --nochange option causes this command to do a "dry run". It
53 ** prints out what would have happened but does not actually make any
54 ** changes to the current checkout or the repository.
55 **
@@ -111,11 +113,11 @@
113 tid = db_int(0, "SELECT rid FROM leaves, event"
114 " WHERE event.objid=leaves.rid"
115 " ORDER BY event.mtime DESC");
116 }
117
118 if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
119 db_begin_transaction();
120 vfile_check_signature(vid, 1);
121 if( !nochangeFlag ) undo_begin();
122 load_vfile_from_rid(tid);
123
@@ -166,27 +168,39 @@
168 );
169 }
170 db_finalize(&q);
171
172 /* If FILES appear on the command-line, remove from the "fv" table
173 ** every entry that is not named on the command-line or which is not
174 ** in a directory named on the command-line.
175 */
176 if( g.argc>=4 ){
177 Blob sql; /* SQL statement to purge unwanted entries */
 
178 Blob treename; /* Normalized filename */
179 int i; /* Loop counter */
180 const char *zSep; /* Term separator */
181
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
187 if( file_isdir(g.argv[i])==1 ){
188 if( blob_size(&treename)>0 ){
189 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190 }else{
191 blob_reset(&sql);
192 blob_append(&sql, "DELETE FROM fv", -1);
193 break;
194 }
195 }else{
196 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197 }
198 zSep = "AND ";
199 blob_reset(&treename);
 
200 }
201 /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202 db_multi_exec(blob_str(&sql));
203 blob_reset(&sql);
204 }
205
206 db_prepare(&q,
@@ -264,11 +278,15 @@
278 blob_reset(&v);
279 blob_reset(&e);
280 blob_reset(&t);
281 blob_reset(&r);
282 }else if( verboseFlag ){
283 if( chnged ){
284 printf("EDITED %s\n", zName);
285 }else{
286 printf("UNCHANGED %s\n", zName);
287 }
288 }
289 free(zFullPath);
290 }
291 db_finalize(&q);
292
293

Keyboard Shortcuts

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