Fossil SCM

Remove non tech notes from the list and error checking performed by fossil wiki --technote. Ambiguity of tech note with the same timestamp resolved in favour of the tech note with the highest modification timestamp.

dave.vines 2016-04-01 14:47
Commit 3d2341a2965d217f6685bd858d88f2f183691ee0
--- src/event.c
+++ src/event.c
@@ -555,10 +555,12 @@
555555
){
556556
int rid; /* Artifact id of the tech note */
557557
const char *zId; /* id of the tech note */
558558
rid = db_int(0, "SELECT objid FROM event"
559559
" WHERE datetime(mtime)=datetime('%q') AND type = 'e'"
560
+ " AND tagid IS NOT NULL"
561
+ " ORDER BY mtime DESC"
560562
" LIMIT 1",
561563
zETime
562564
);
563565
if( rid==0 && !isNew ){
564566
#ifdef FOSSIL_ENABLE_JSON
565567
--- src/event.c
+++ src/event.c
@@ -555,10 +555,12 @@
555 ){
556 int rid; /* Artifact id of the tech note */
557 const char *zId; /* id of the tech note */
558 rid = db_int(0, "SELECT objid FROM event"
559 " WHERE datetime(mtime)=datetime('%q') AND type = 'e'"
 
 
560 " LIMIT 1",
561 zETime
562 );
563 if( rid==0 && !isNew ){
564 #ifdef FOSSIL_ENABLE_JSON
565
--- src/event.c
+++ src/event.c
@@ -555,10 +555,12 @@
555 ){
556 int rid; /* Artifact id of the tech note */
557 const char *zId; /* id of the tech note */
558 rid = db_int(0, "SELECT objid FROM event"
559 " WHERE datetime(mtime)=datetime('%q') AND type = 'e'"
560 " AND tagid IS NOT NULL"
561 " ORDER BY mtime DESC"
562 " LIMIT 1",
563 zETime
564 );
565 if( rid==0 && !isNew ){
566 #ifdef FOSSIL_ENABLE_JSON
567
+2
--- src/wiki.c
+++ src/wiki.c
@@ -1276,10 +1276,11 @@
12761276
zMimeType = pWiki->zMimetype;
12771277
}
12781278
}else{
12791279
rid = db_int(0, "SELECT objid FROM event"
12801280
" WHERE datetime(mtime)=datetime('%q') AND type='e'"
1281
+ " AND tagid IS NOT NULL"
12811282
" ORDER BY mtime DESC LIMIT 1",
12821283
zPageName
12831284
);
12841285
if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0
12851286
&& (pWiki->zMimetype && *pWiki->zMimetype)){
@@ -1326,10 +1327,11 @@
13261327
" ORDER BY lower(tagname) /*sort*/"
13271328
);
13281329
}else{
13291330
db_prepare(&q,
13301331
"SELECT datetime(mtime) FROM event WHERE type='e'"
1332
+ " AND tagid IS NOT NULL"
13311333
" ORDER BY mtime /*sort*/"
13321334
);
13331335
}
13341336
while( db_step(&q)==SQLITE_ROW ){
13351337
const char *zName = db_column_text(&q, 0);
13361338
--- src/wiki.c
+++ src/wiki.c
@@ -1276,10 +1276,11 @@
1276 zMimeType = pWiki->zMimetype;
1277 }
1278 }else{
1279 rid = db_int(0, "SELECT objid FROM event"
1280 " WHERE datetime(mtime)=datetime('%q') AND type='e'"
 
1281 " ORDER BY mtime DESC LIMIT 1",
1282 zPageName
1283 );
1284 if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0
1285 && (pWiki->zMimetype && *pWiki->zMimetype)){
@@ -1326,10 +1327,11 @@
1326 " ORDER BY lower(tagname) /*sort*/"
1327 );
1328 }else{
1329 db_prepare(&q,
1330 "SELECT datetime(mtime) FROM event WHERE type='e'"
 
1331 " ORDER BY mtime /*sort*/"
1332 );
1333 }
1334 while( db_step(&q)==SQLITE_ROW ){
1335 const char *zName = db_column_text(&q, 0);
1336
--- src/wiki.c
+++ src/wiki.c
@@ -1276,10 +1276,11 @@
1276 zMimeType = pWiki->zMimetype;
1277 }
1278 }else{
1279 rid = db_int(0, "SELECT objid FROM event"
1280 " WHERE datetime(mtime)=datetime('%q') AND type='e'"
1281 " AND tagid IS NOT NULL"
1282 " ORDER BY mtime DESC LIMIT 1",
1283 zPageName
1284 );
1285 if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0
1286 && (pWiki->zMimetype && *pWiki->zMimetype)){
@@ -1326,10 +1327,11 @@
1327 " ORDER BY lower(tagname) /*sort*/"
1328 );
1329 }else{
1330 db_prepare(&q,
1331 "SELECT datetime(mtime) FROM event WHERE type='e'"
1332 " AND tagid IS NOT NULL"
1333 " ORDER BY mtime /*sort*/"
1334 );
1335 }
1336 while( db_step(&q)==SQLITE_ROW ){
1337 const char *zName = db_column_text(&q, 0);
1338
+10 -5
--- test/wiki.test
+++ test/wiki.test
@@ -181,32 +181,31 @@
181181
set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
182182
write_file f9 "Timestamp: $t1"
183183
fossil attachment add f9 --technote {2016-01-05 01:02:03}
184184
test wiki-31 {$CODE == 0}
185185
fossil wiki create {Attachment collision} f9 --technote now
186
-test wiki-32 {$CODE == 0} knownBug
186
+test wiki-32 {$CODE == 0}
187187
#
188188
# Now waste time until the next second so that the remaining tests
189
-# don't have to suffer from this known bug with attachments. This
190
-# delay could be removed if that bug is fixed, but probably shouldn't
191
-# be.
189
+# don't have to worry about a potential collision
192190
set t0 [clock seconds]
193191
while {$t0 == [clock seconds]} {
194192
after 100
195193
}
196194
197195
###############################################################################
198
-# Check a technote with no timestamp can not be created, but that
196
+# Check a technote with no timestamp cannot be created, but that
199197
# "now" is a valid stamp.
200198
set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
201199
write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
202200
fossil wiki create "Unstamped Note" f10 --technote -expectError
203201
test wiki-33 {$CODE != 0}
204202
fossil wiki create "Unstamped Note" f10 --technote now
205203
test wiki-34 {$CODE == 0}
206204
fossil wiki list -t
207205
test wiki-35 {[string match "*$t2*" $RESULT]}
206
+
208207
###############################################################################
209208
# Check an attachment to it in the same second works.
210209
write_file f11 "Time Stamp was $t2"
211210
fossil attachment add f11 --technote $t2
212211
test wiki-36 {$CODE == 0}
@@ -213,10 +212,16 @@
213212
fossil timeline
214213
test wiki-36-1 {$CODE == 0}
215214
fossil wiki list -t
216215
test wiki-36-2 {$CODE == 0}
217216
217
+###############################################################################
218
+# Check that we have the expected number of tech notes on the list (and not
219
+# extra ones from other events (such as the attachments) - 7 tech notes
220
+# expected created by tests 9, 17, 19, 29, 31, 32 and 34
221
+fossil wiki list --technote
222
+test wiki-37 {[llength [split $RESULT "\n"]] == 7}
218223
219224
###############################################################################
220225
221226
test_cleanup
222227
223228
--- test/wiki.test
+++ test/wiki.test
@@ -181,32 +181,31 @@
181 set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
182 write_file f9 "Timestamp: $t1"
183 fossil attachment add f9 --technote {2016-01-05 01:02:03}
184 test wiki-31 {$CODE == 0}
185 fossil wiki create {Attachment collision} f9 --technote now
186 test wiki-32 {$CODE == 0} knownBug
187 #
188 # Now waste time until the next second so that the remaining tests
189 # don't have to suffer from this known bug with attachments. This
190 # delay could be removed if that bug is fixed, but probably shouldn't
191 # be.
192 set t0 [clock seconds]
193 while {$t0 == [clock seconds]} {
194 after 100
195 }
196
197 ###############################################################################
198 # Check a technote with no timestamp can not be created, but that
199 # "now" is a valid stamp.
200 set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
201 write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
202 fossil wiki create "Unstamped Note" f10 --technote -expectError
203 test wiki-33 {$CODE != 0}
204 fossil wiki create "Unstamped Note" f10 --technote now
205 test wiki-34 {$CODE == 0}
206 fossil wiki list -t
207 test wiki-35 {[string match "*$t2*" $RESULT]}
 
208 ###############################################################################
209 # Check an attachment to it in the same second works.
210 write_file f11 "Time Stamp was $t2"
211 fossil attachment add f11 --technote $t2
212 test wiki-36 {$CODE == 0}
@@ -213,10 +212,16 @@
213 fossil timeline
214 test wiki-36-1 {$CODE == 0}
215 fossil wiki list -t
216 test wiki-36-2 {$CODE == 0}
217
 
 
 
 
 
 
218
219 ###############################################################################
220
221 test_cleanup
222
223
--- test/wiki.test
+++ test/wiki.test
@@ -181,32 +181,31 @@
181 set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
182 write_file f9 "Timestamp: $t1"
183 fossil attachment add f9 --technote {2016-01-05 01:02:03}
184 test wiki-31 {$CODE == 0}
185 fossil wiki create {Attachment collision} f9 --technote now
186 test wiki-32 {$CODE == 0}
187 #
188 # Now waste time until the next second so that the remaining tests
189 # don't have to worry about a potential collision
 
 
190 set t0 [clock seconds]
191 while {$t0 == [clock seconds]} {
192 after 100
193 }
194
195 ###############################################################################
196 # Check a technote with no timestamp cannot be created, but that
197 # "now" is a valid stamp.
198 set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
199 write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
200 fossil wiki create "Unstamped Note" f10 --technote -expectError
201 test wiki-33 {$CODE != 0}
202 fossil wiki create "Unstamped Note" f10 --technote now
203 test wiki-34 {$CODE == 0}
204 fossil wiki list -t
205 test wiki-35 {[string match "*$t2*" $RESULT]}
206
207 ###############################################################################
208 # Check an attachment to it in the same second works.
209 write_file f11 "Time Stamp was $t2"
210 fossil attachment add f11 --technote $t2
211 test wiki-36 {$CODE == 0}
@@ -213,10 +212,16 @@
212 fossil timeline
213 test wiki-36-1 {$CODE == 0}
214 fossil wiki list -t
215 test wiki-36-2 {$CODE == 0}
216
217 ###############################################################################
218 # Check that we have the expected number of tech notes on the list (and not
219 # extra ones from other events (such as the attachments) - 7 tech notes
220 # expected created by tests 9, 17, 19, 29, 31, 32 and 34
221 fossil wiki list --technote
222 test wiki-37 {[llength [split $RESULT "\n"]] == 7}
223
224 ###############################################################################
225
226 test_cleanup
227
228

Keyboard Shortcuts

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