Fossil SCM

Patches to file.c (for mingw is_dir), finfo.c (various utilities), and update.c (for verbose/nochange), to allow integration into Emacs and IDEs.

venkat 2010-11-07 21:11 venks-emacs
Commit 2a86bb65aac6075fd061637c94c9589a2b148816
3 files changed +5 -2 +147 -51 +20 -7
+5 -2
--- src/file.c
+++ src/file.c
@@ -424,23 +424,26 @@
424424
** false, then simply return 0.
425425
**
426426
** The root of the tree is defined by the g.zLocalRoot variable.
427427
*/
428428
int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
429
- int n;
429
+ int m,n;
430430
Blob full;
431431
db_must_be_within_tree();
432432
file_canonical_name(zOrigName, &full);
433433
n = strlen(g.zLocalRoot);
434
- if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
434
+ m = blob_size(&full);
435
+ if( m<n-1 || memcmp(g.zLocalRoot, blob_buffer(&full), n-1) ){
435436
blob_reset(&full);
436437
if( errFatal ){
437438
fossil_fatal("file outside of checkout tree: %s", zOrigName);
438439
}
439440
return 0;
440441
}
441442
blob_zero(pOut);
443
+ if (m == n - 1)
444
+ return 1;
442445
blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
443446
return 1;
444447
}
445448
446449
/*
447450
--- src/file.c
+++ src/file.c
@@ -424,23 +424,26 @@
424 ** false, then simply return 0.
425 **
426 ** The root of the tree is defined by the g.zLocalRoot variable.
427 */
428 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
429 int n;
430 Blob full;
431 db_must_be_within_tree();
432 file_canonical_name(zOrigName, &full);
433 n = strlen(g.zLocalRoot);
434 if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
 
435 blob_reset(&full);
436 if( errFatal ){
437 fossil_fatal("file outside of checkout tree: %s", zOrigName);
438 }
439 return 0;
440 }
441 blob_zero(pOut);
 
 
442 blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
443 return 1;
444 }
445
446 /*
447
--- src/file.c
+++ src/file.c
@@ -424,23 +424,26 @@
424 ** false, then simply return 0.
425 **
426 ** The root of the tree is defined by the g.zLocalRoot variable.
427 */
428 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
429 int m,n;
430 Blob full;
431 db_must_be_within_tree();
432 file_canonical_name(zOrigName, &full);
433 n = strlen(g.zLocalRoot);
434 m = blob_size(&full);
435 if( m<n-1 || memcmp(g.zLocalRoot, blob_buffer(&full), n-1) ){
436 blob_reset(&full);
437 if( errFatal ){
438 fossil_fatal("file outside of checkout tree: %s", zOrigName);
439 }
440 return 0;
441 }
442 blob_zero(pOut);
443 if (m == n - 1)
444 return 1;
445 blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
446 return 1;
447 }
448
449 /*
450
+147 -51
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,171 @@
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.
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.
2742
**
2843
** Print the change history for a single file.
2944
**
3045
** The "--limit N" and "--offset P" options limit the output to the first
3146
** N changes after skipping P changes.
3247
*/
3348
void finfo_cmd(void){
34
- Stmt q;
3549
int vid;
36
- Blob dest;
37
- const char *zFilename;
38
- const char *zLimit;
39
- const char *zOffset;
40
- int iLimit, iOffset;
4150
4251
db_must_be_within_tree();
4352
vid = db_lget_int("checkout", 0);
4453
if( vid==0 ){
4554
fossil_panic("no checkout to finfo files in");
4655
}
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);
56
+ vfile_check_signature(vid, 1);
57
+ if (find_option("status","s",0)) {
58
+ Stmt q;
59
+ Blob line;
60
+ Blob fname;
61
+
62
+ if (g.argc != 3) {
63
+ usage("-s|--status FILENAME");
64
+ }
65
+ file_tree_name(g.argv[2], &fname, 1);
66
+ db_prepare(&q,
67
+ "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
68
+ " FROM vfile WHERE vfile.pathname=%B", &fname);
69
+ blob_zero(&line);
70
+ if ( db_step(&q)==SQLITE_ROW ) {
71
+ Blob uuid;
72
+ int isDeleted = db_column_int(&q, 1);
73
+ int isNew = db_column_int(&q,2) == 0;
74
+ int chnged = db_column_int(&q,3);
75
+ int renamed = db_column_int(&q,4);
76
+
77
+ blob_zero(&uuid);
78
+ db_blob(&uuid,"SELECT uuid FROM blob, mlink, vfile WHERE "
79
+ "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
80
+ "vfile.pathname=%B",&fname);
81
+ if (isNew) {
82
+ blob_appendf(&line, "new");
83
+ } else if (isDeleted) {
84
+ blob_appendf(&line, "deleted");
85
+ } else if (renamed) {
86
+ blob_appendf(&line, "renamed");
87
+ } else if (chnged) {
88
+ blob_appendf(&line, "edited");
89
+ } else {
90
+ blob_appendf(&line, "unchanged");
91
+ }
92
+ blob_appendf(&line, " ");
93
+ blob_appendf(&line, " %10.10s", blob_str(&uuid));
94
+ blob_reset(&uuid);
95
+ } else {
96
+ blob_appendf(&line, "unknown 0000000000");
97
+ }
98
+ db_finalize(&q);
99
+ printf("%s\n", blob_str(&line));
100
+ blob_reset(&fname);
101
+ blob_reset(&line);
102
+ } else if (find_option("print","p",0)) {
103
+ Blob record;
104
+ Blob fname;
105
+ const char *zRevision = find_option("revision", "r", 1);
106
+
107
+ file_tree_name(g.argv[2], &fname, 1);
108
+ if (zRevision) {
109
+ historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
110
+ } else {
111
+ int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
112
+ if( rid==0 ){
113
+ fossil_fatal("no history for file: %b", &fname);
114
+ }
115
+ content_get(rid, &record);
116
+ }
117
+ blob_write_to_file(&record, "-");
118
+ blob_reset(&record);
119
+ blob_reset(&fname);
120
+ } else {
121
+ Blob line;
122
+ Stmt q;
123
+ Blob fname;
124
+ int rid;
125
+ const char *zFilename;
126
+ const char *zLimit;
127
+ const char *zOffset;
128
+ int iLimit, iOffset, iBrief;
129
+
130
+ if (find_option("log","l",0)) { /* this is the default, no-op */
131
+ }
132
+ zLimit = find_option("limit",0,1);
133
+ iLimit = zLimit ? atoi(zLimit) : -1;
134
+ zOffset = find_option("offset",0,1);
135
+ iOffset = zOffset ? atoi(zOffset) : 0;
136
+ iBrief = (find_option("brief","b",0) == 0);
137
+ if (g.argc != 3) {
138
+ usage("?-l|--log? ?-b|--brief? FILENAME");
139
+ }
140
+ file_tree_name(g.argv[2], &fname, 1);
141
+ rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
142
+ if( rid==0 ){
143
+ fossil_fatal("no history for file: %b", &fname);
144
+ }
145
+ zFilename = blob_str(&fname);
146
+ db_prepare(&q,
147
+ "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
148
+ " coalesce(event.ecomment, event.comment),"
149
+ " coalesce(event.euser, event.user)"
150
+ " FROM mlink, blob b, event, blob ci"
151
+ " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
152
+ " AND b.rid=mlink.fid"
153
+ " AND event.objid=mlink.mid"
154
+ " AND event.objid=ci.rid"
155
+ " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
156
+ zFilename, iLimit, iOffset
157
+ );
158
+ blob_zero(&line);
159
+ if (iBrief) {
160
+ printf("History of %s\n", blob_str(&fname));
161
+ }
162
+ while( db_step(&q)==SQLITE_ROW ){
163
+ const char *zFileUuid = db_column_text(&q, 0);
164
+ const char *zCiUuid = db_column_text(&q,1);
165
+ const char *zDate = db_column_text(&q, 2);
166
+ const char *zCom = db_column_text(&q, 3);
167
+ const char *zUser = db_column_text(&q, 4);
168
+ char *zOut;
169
+ if (iBrief) {
170
+ printf("%s ", zDate);
171
+ zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
172
+ zCiUuid, zCom, zUser, zFileUuid);
173
+ comment_print(zOut, 11, 79);
174
+ sqlite3_free(zOut);
175
+ } else {
176
+ blob_reset(&line);
177
+ blob_appendf(&line, "%.10s ", zCiUuid);
178
+ blob_appendf(&line, "%.10s ", zDate);
179
+ blob_appendf(&line, "%8.8s ", zUser);
180
+ blob_appendf(&line,"%-40.40s\n", zCom );
181
+ comment_print(blob_str(&line), 0, 79);
182
+ }
183
+ }
184
+ db_finalize(&q);
185
+ blob_reset(&fname);
186
+ }
91187
}
92188
93189
94190
/*
95191
** WEBPAGE: finfo
96192
--- src/finfo.c
+++ src/finfo.c
@@ -21,75 +21,171 @@
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,171 @@
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 ** Print the change history for a single file.
44 **
45 ** The "--limit N" and "--offset P" options limit the output to the first
46 ** N changes after skipping P changes.
47 */
48 void finfo_cmd(void){
 
49 int vid;
 
 
 
 
 
50
51 db_must_be_within_tree();
52 vid = db_lget_int("checkout", 0);
53 if( vid==0 ){
54 fossil_panic("no checkout to finfo files in");
55 }
56 vfile_check_signature(vid, 1);
57 if (find_option("status","s",0)) {
58 Stmt q;
59 Blob line;
60 Blob fname;
61
62 if (g.argc != 3) {
63 usage("-s|--status FILENAME");
64 }
65 file_tree_name(g.argv[2], &fname, 1);
66 db_prepare(&q,
67 "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
68 " FROM vfile WHERE vfile.pathname=%B", &fname);
69 blob_zero(&line);
70 if ( db_step(&q)==SQLITE_ROW ) {
71 Blob uuid;
72 int isDeleted = db_column_int(&q, 1);
73 int isNew = db_column_int(&q,2) == 0;
74 int chnged = db_column_int(&q,3);
75 int renamed = db_column_int(&q,4);
76
77 blob_zero(&uuid);
78 db_blob(&uuid,"SELECT uuid FROM blob, mlink, vfile WHERE "
79 "blob.rid = mlink.mid AND mlink.fid = vfile.rid AND "
80 "vfile.pathname=%B",&fname);
81 if (isNew) {
82 blob_appendf(&line, "new");
83 } else if (isDeleted) {
84 blob_appendf(&line, "deleted");
85 } else if (renamed) {
86 blob_appendf(&line, "renamed");
87 } else if (chnged) {
88 blob_appendf(&line, "edited");
89 } else {
90 blob_appendf(&line, "unchanged");
91 }
92 blob_appendf(&line, " ");
93 blob_appendf(&line, " %10.10s", blob_str(&uuid));
94 blob_reset(&uuid);
95 } else {
96 blob_appendf(&line, "unknown 0000000000");
97 }
98 db_finalize(&q);
99 printf("%s\n", blob_str(&line));
100 blob_reset(&fname);
101 blob_reset(&line);
102 } else if (find_option("print","p",0)) {
103 Blob record;
104 Blob fname;
105 const char *zRevision = find_option("revision", "r", 1);
106
107 file_tree_name(g.argv[2], &fname, 1);
108 if (zRevision) {
109 historical_version_of_file(zRevision, blob_str(&fname), &record, 0);
110 } else {
111 int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
112 if( rid==0 ){
113 fossil_fatal("no history for file: %b", &fname);
114 }
115 content_get(rid, &record);
116 }
117 blob_write_to_file(&record, "-");
118 blob_reset(&record);
119 blob_reset(&fname);
120 } else {
121 Blob line;
122 Stmt q;
123 Blob fname;
124 int rid;
125 const char *zFilename;
126 const char *zLimit;
127 const char *zOffset;
128 int iLimit, iOffset, iBrief;
129
130 if (find_option("log","l",0)) { /* this is the default, no-op */
131 }
132 zLimit = find_option("limit",0,1);
133 iLimit = zLimit ? atoi(zLimit) : -1;
134 zOffset = find_option("offset",0,1);
135 iOffset = zOffset ? atoi(zOffset) : 0;
136 iBrief = (find_option("brief","b",0) == 0);
137 if (g.argc != 3) {
138 usage("?-l|--log? ?-b|--brief? FILENAME");
139 }
140 file_tree_name(g.argv[2], &fname, 1);
141 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
142 if( rid==0 ){
143 fossil_fatal("no history for file: %b", &fname);
144 }
145 zFilename = blob_str(&fname);
146 db_prepare(&q,
147 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
148 " coalesce(event.ecomment, event.comment),"
149 " coalesce(event.euser, event.user)"
150 " FROM mlink, blob b, event, blob ci"
151 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
152 " AND b.rid=mlink.fid"
153 " AND event.objid=mlink.mid"
154 " AND event.objid=ci.rid"
155 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
156 zFilename, iLimit, iOffset
157 );
158 blob_zero(&line);
159 if (iBrief) {
160 printf("History of %s\n", blob_str(&fname));
161 }
162 while( db_step(&q)==SQLITE_ROW ){
163 const char *zFileUuid = db_column_text(&q, 0);
164 const char *zCiUuid = db_column_text(&q,1);
165 const char *zDate = db_column_text(&q, 2);
166 const char *zCom = db_column_text(&q, 3);
167 const char *zUser = db_column_text(&q, 4);
168 char *zOut;
169 if (iBrief) {
170 printf("%s ", zDate);
171 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
172 zCiUuid, zCom, zUser, zFileUuid);
173 comment_print(zOut, 11, 79);
174 sqlite3_free(zOut);
175 } else {
176 blob_reset(&line);
177 blob_appendf(&line, "%.10s ", zCiUuid);
178 blob_appendf(&line, "%.10s ", zDate);
179 blob_appendf(&line, "%8.8s ", zUser);
180 blob_appendf(&line,"%-40.40s\n", zCom );
181 comment_print(blob_str(&line), 0, 79);
182 }
183 }
184 db_finalize(&q);
185 blob_reset(&fname);
186 }
187 }
188
189
190 /*
191 ** WEBPAGE: finfo
192
+20 -7
--- src/update.c
+++ src/update.c
@@ -111,11 +111,11 @@
111111
tid = db_int(0, "SELECT rid FROM leaves, event"
112112
" WHERE event.objid=leaves.rid"
113113
" ORDER BY event.mtime DESC");
114114
}
115115
116
- if( tid==vid ) return; /* Nothing to update */
116
+ if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
117117
db_begin_transaction();
118118
vfile_check_signature(vid, 1);
119119
if( !nochangeFlag ) undo_begin();
120120
load_vfile_from_rid(tid);
121121
@@ -170,23 +170,32 @@
170170
/* If FILES appear on the command-line, remove from the "fv" table
171171
** every entry that is not named on the command-line.
172172
*/
173173
if( g.argc>=4 ){
174174
Blob sql; /* SQL statement to purge unwanted entries */
175
- char *zSep = "("; /* Separator in the list of filenames */
176175
Blob treename; /* Normalized filename */
177176
int i; /* Loop counter */
178177
179178
blob_zero(&sql);
180
- blob_append(&sql, "DELETE FROM fv WHERE fn NOT IN ", -1);
179
+ blob_append(&sql, "DELETE FROM fv WHERE ", -1);
181180
for(i=3; i<g.argc; i++){
182181
file_tree_name(g.argv[i], &treename, 1);
183
- blob_appendf(&sql, "%s'%q'", zSep, blob_str(&treename));
182
+ if (file_isdir(g.argv[i]) == 1) {
183
+ if (blob_size(&treename) > 0) {
184
+ blob_appendf(&sql, "fn NOT GLOB '%b/*' ", &treename);
185
+ } else {
186
+ blob_appendf(&sql, "fn NOT GLOB '*' ");
187
+ }
188
+ } else {
189
+ blob_appendf(&sql, "fn <> %B ", &treename);
190
+ }
191
+ if (i < g.argc - 1) {
192
+ blob_append(&sql, "AND ", -1);
193
+ }
184194
blob_reset(&treename);
185
- zSep = ",";
186195
}
187
- blob_append(&sql, ")", -1);
196
+ fprintf(stderr, "%s\n", blob_str(&sql));
188197
db_multi_exec(blob_str(&sql));
189198
blob_reset(&sql);
190199
}
191200
192201
db_prepare(&q,
@@ -264,11 +273,15 @@
264273
blob_reset(&v);
265274
blob_reset(&e);
266275
blob_reset(&t);
267276
blob_reset(&r);
268277
}else if( verboseFlag ){
269
- printf("UNCHANGED %s\n", zName);
278
+ if (chnged) {
279
+ printf("EDITED %s\n", zName);
280
+ } else {
281
+ printf("UNCHANGED %s\n", zName);
282
+ }
270283
}
271284
free(zFullPath);
272285
}
273286
db_finalize(&q);
274287
275288
--- src/update.c
+++ src/update.c
@@ -111,11 +111,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
@@ -170,23 +170,32 @@
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 +273,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
@@ -111,11 +111,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( !verboseFlag && (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
@@ -170,23 +170,32 @@
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 Blob treename; /* Normalized filename */
176 int i; /* Loop counter */
177
178 blob_zero(&sql);
179 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
180 for(i=3; i<g.argc; i++){
181 file_tree_name(g.argv[i], &treename, 1);
182 if (file_isdir(g.argv[i]) == 1) {
183 if (blob_size(&treename) > 0) {
184 blob_appendf(&sql, "fn NOT GLOB '%b/*' ", &treename);
185 } else {
186 blob_appendf(&sql, "fn NOT GLOB '*' ");
187 }
188 } else {
189 blob_appendf(&sql, "fn <> %B ", &treename);
190 }
191 if (i < g.argc - 1) {
192 blob_append(&sql, "AND ", -1);
193 }
194 blob_reset(&treename);
 
195 }
196 fprintf(stderr, "%s\n", blob_str(&sql));
197 db_multi_exec(blob_str(&sql));
198 blob_reset(&sql);
199 }
200
201 db_prepare(&q,
@@ -264,11 +273,15 @@
273 blob_reset(&v);
274 blob_reset(&e);
275 blob_reset(&t);
276 blob_reset(&r);
277 }else if( verboseFlag ){
278 if (chnged) {
279 printf("EDITED %s\n", zName);
280 } else {
281 printf("UNCHANGED %s\n", zName);
282 }
283 }
284 free(zFullPath);
285 }
286 db_finalize(&q);
287
288

Keyboard Shortcuts

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