Fossil

Check-in [3d2341a2]
Login

Check-in [3d2341a2]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | technoteattachcli
Files: files | file ages | folders
SHA1: 3d2341a2965d217f6685bd858d88f2f183691ee0
User & Date: dave.vines 2016-04-01 14:47:09.752
Context
2016-04-04
17:30
Add a --show-artifact-ids to the 'fossil wiki list' command. Note this commit does not add the ability to select what to update on the 'fossil wiki commit' command, that is to come in a later commit. ... (check-in: cbda43e7 user: dave.vines tags: technoteattachcli)
2016-04-01
14:47
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. ... (check-in: 3d2341a2 user: dave.vines tags: technoteattachcli)
2016-03-28
12:12
Stop using 10h as the format for tech note ids. Note that the comment for any existing attachments to tech notes won't change as the comment is generated when the attachment is made (since this change is new, I'd expect there to be none outside of my own personal fossil repositories) ... (check-in: 4ce3c62b user: dave.vines tags: technoteattachcli)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/event.c.
553
554
555
556
557
558
559


560
561
562
563
564
565
566
  const char *zTags,        /* tags */
  const char *zClr          /* background color */
){
  int rid;                /* Artifact id of the tech note */
  const char *zId;        /* id of the tech note */
  rid = db_int(0, "SELECT objid FROM event"
        " WHERE datetime(mtime)=datetime('%q') AND type = 'e'"


        " LIMIT 1",
        zETime
  );
  if( rid==0 && !isNew ){
#ifdef FOSSIL_ENABLE_JSON
    g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
#endif







>
>







553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
  const char *zTags,        /* tags */
  const char *zClr          /* background color */
){
  int rid;                /* Artifact id of the tech note */
  const char *zId;        /* id of the tech note */
  rid = db_int(0, "SELECT objid FROM event"
        " WHERE datetime(mtime)=datetime('%q') AND type = 'e'"
           " AND tagid IS NOT NULL"
        " ORDER BY mtime DESC"
        " LIMIT 1",
        zETime
  );
  if( rid==0 && !isNew ){
#ifdef FOSSIL_ENABLE_JSON
    g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
#endif
Changes to src/wiki.c.
1274
1275
1276
1277
1278
1279
1280

1281
1282
1283
1284
1285
1286
1287
        if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0
           && (pWiki->zMimetype && *pWiki->zMimetype)){
          zMimeType = pWiki->zMimetype;
        }
      }else{
        rid = db_int(0, "SELECT objid FROM event"
                     " WHERE datetime(mtime)=datetime('%q') AND type='e'"

                     " ORDER BY mtime DESC LIMIT 1",
                     zPageName
                     );
        if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0
           && (pWiki->zMimetype && *pWiki->zMimetype)){
          zMimeType = pWiki->zMimetype;
        }







>







1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
        if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0
           && (pWiki->zMimetype && *pWiki->zMimetype)){
          zMimeType = pWiki->zMimetype;
        }
      }else{
        rid = db_int(0, "SELECT objid FROM event"
                     " WHERE datetime(mtime)=datetime('%q') AND type='e'"
                        " AND tagid IS NOT NULL"
                     " ORDER BY mtime DESC LIMIT 1",
                     zPageName
                     );
        if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0
           && (pWiki->zMimetype && *pWiki->zMimetype)){
          zMimeType = pWiki->zMimetype;
        }
1324
1325
1326
1327
1328
1329
1330

1331
1332
1333
1334
1335
1336
1337
      db_prepare(&q,
        "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
        " ORDER BY lower(tagname) /*sort*/"
      );
    }else{
      db_prepare(&q,
        "SELECT datetime(mtime) FROM event WHERE type='e'"

        " ORDER BY mtime /*sort*/"
      );
    }
    while( db_step(&q)==SQLITE_ROW ){
      const char *zName = db_column_text(&q, 0);
      fossil_print( "%s\n",zName);
    }







>







1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
      db_prepare(&q,
        "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
        " ORDER BY lower(tagname) /*sort*/"
      );
    }else{
      db_prepare(&q,
        "SELECT datetime(mtime) FROM event WHERE type='e'"
          " AND tagid IS NOT NULL"
        " ORDER BY mtime /*sort*/"
      );
    }
    while( db_step(&q)==SQLITE_ROW ){
      const char *zName = db_column_text(&q, 0);
      fossil_print( "%s\n",zName);
    }
Changes to test/wiki.test.
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

208
209
210
211
212
213
214
215
216
217






218
219
220
221
222
  after 100
}
set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
write_file f9 "Timestamp: $t1"
fossil attachment add f9 --technote {2016-01-05 01:02:03}
test wiki-31 {$CODE == 0}
fossil wiki create {Attachment collision} f9 --technote now
test wiki-32 {$CODE == 0} knownBug
#
# Now waste time until the next second so that the remaining tests
# don't have to suffer from this known bug with attachments. This
# delay could be removed if that bug is fixed, but probably shouldn't
# be.
set t0 [clock seconds]
while {$t0 == [clock seconds]} {
  after 100
}

###############################################################################
# Check a technote with no timestamp can not be created, but that
# "now" is a valid stamp.
set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
fossil wiki create "Unstamped Note" f10 --technote -expectError
test wiki-33 {$CODE != 0}
fossil wiki create "Unstamped Note" f10 --technote now
test wiki-34 {$CODE == 0}
fossil wiki list -t 
test wiki-35 {[string match "*$t2*" $RESULT]}

###############################################################################
# Check an attachment to it in the same second works. 
write_file f11 "Time Stamp was $t2"
fossil attachment add f11 --technote $t2
test wiki-36 {$CODE == 0}
fossil timeline
test wiki-36-1 {$CODE == 0}
fossil wiki list -t
test wiki-36-2 {$CODE == 0}








###############################################################################

test_cleanup








|


|
<
<






|









>










>
>
>
>
>
>





179
180
181
182
183
184
185
186
187
188
189


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
  after 100
}
set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
write_file f9 "Timestamp: $t1"
fossil attachment add f9 --technote {2016-01-05 01:02:03}
test wiki-31 {$CODE == 0}
fossil wiki create {Attachment collision} f9 --technote now
test wiki-32 {$CODE == 0}
#
# Now waste time until the next second so that the remaining tests
# don't have to worry about a potential collision


set t0 [clock seconds]
while {$t0 == [clock seconds]} {
  after 100
}

###############################################################################
# Check a technote with no timestamp cannot be created, but that
# "now" is a valid stamp.
set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
fossil wiki create "Unstamped Note" f10 --technote -expectError
test wiki-33 {$CODE != 0}
fossil wiki create "Unstamped Note" f10 --technote now
test wiki-34 {$CODE == 0}
fossil wiki list -t 
test wiki-35 {[string match "*$t2*" $RESULT]}

###############################################################################
# Check an attachment to it in the same second works. 
write_file f11 "Time Stamp was $t2"
fossil attachment add f11 --technote $t2
test wiki-36 {$CODE == 0}
fossil timeline
test wiki-36-1 {$CODE == 0}
fossil wiki list -t
test wiki-36-2 {$CODE == 0}

###############################################################################
# Check that we have the expected number of tech notes on the list (and not 
# extra ones from other events (such as the attachments) - 7 tech notes 
# expected created by tests 9, 17, 19, 29, 31, 32 and 34 
fossil wiki list --technote
test wiki-37 {[llength [split $RESULT "\n"]] == 7}

###############################################################################

test_cleanup