Fossil SCM

add TECHNOTEID to fossil attach command

dave.vines 2016-04-18 13:36
Commit 70131d08e27bf47f50a40132dd80dd85f657c3e6
3 files changed +17 -9 +3 -2 +14 -2
+17 -9
--- src/attach.c
+++ src/attach.c
@@ -685,15 +685,24 @@
685685
}
686686
687687
/*
688688
** COMMAND: attachment*
689689
**
690
-** Usage: %fossil attachment add ?PAGENAME? FILENAME [-t|--technote DATETIME ]
690
+** Usage: %fossil attachment add ?PAGENAME? FILENAME ?OPTIONS?
691
+**
692
+** Add an attachment to an existing wiki page or tech note.
691693
**
692
-** Add an attachment to an existing wiki page or tech note. One of
693
-** PAGENAME or DATETIME must be specified.
694
+** Options:
695
+** -t|--technote DATETIME Specifies the timestamp of
696
+** the technote to which the attachment
697
+** is to be made. The attachment will be
698
+** to the most recently modified tech note
699
+** with the specified timestamp.
700
+** -t|--technote TECHNOTE-ID Specifies the technote to be
701
+** updated by its technote id.
694702
**
703
+** One of PAGENAME, DATETIME or TECHNOTE-ID must be specified.
695704
*/
696705
void attachment_cmd(void){
697706
int n;
698707
db_find_and_open_repository(0, 0);
699708
if( g.argc<3 ){
@@ -732,17 +741,16 @@
732741
}
733742
zTarget = zPageName;
734743
zFile = g.argv[4];
735744
}else{
736745
if( g.argc!=4 ){
737
- usage("add FILENAME --technote DATETIME");
746
+ usage("add FILENAME --technote DATETIME|TECHNOTE-ID");
738747
}
739
- rid = db_int(0, "SELECT objid FROM event"
740
- " WHERE datetime(mtime)=datetime('%q') AND type='e'"
741
- " ORDER BY mtime DESC LIMIT 1",
742
- zETime
743
- );
748
+ rid = wiki_technote_to_rid(zETime);
749
+ if( rid<0 ){
750
+ fossil_fatal("ambiguous tech note id: %s", zETime);
751
+ }
744752
if( (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 ){
745753
zBody = pWiki->zWiki;
746754
}
747755
if( zBody==0 ){
748756
fossil_fatal("technote [%s] not found",zETime);
749757
--- src/attach.c
+++ src/attach.c
@@ -685,15 +685,24 @@
685 }
686
687 /*
688 ** COMMAND: attachment*
689 **
690 ** Usage: %fossil attachment add ?PAGENAME? FILENAME [-t|--technote DATETIME ]
 
 
691 **
692 ** Add an attachment to an existing wiki page or tech note. One of
693 ** PAGENAME or DATETIME must be specified.
 
 
 
 
 
 
694 **
 
695 */
696 void attachment_cmd(void){
697 int n;
698 db_find_and_open_repository(0, 0);
699 if( g.argc<3 ){
@@ -732,17 +741,16 @@
732 }
733 zTarget = zPageName;
734 zFile = g.argv[4];
735 }else{
736 if( g.argc!=4 ){
737 usage("add FILENAME --technote DATETIME");
738 }
739 rid = db_int(0, "SELECT objid FROM event"
740 " WHERE datetime(mtime)=datetime('%q') AND type='e'"
741 " ORDER BY mtime DESC LIMIT 1",
742 zETime
743 );
744 if( (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 ){
745 zBody = pWiki->zWiki;
746 }
747 if( zBody==0 ){
748 fossil_fatal("technote [%s] not found",zETime);
749
--- src/attach.c
+++ src/attach.c
@@ -685,15 +685,24 @@
685 }
686
687 /*
688 ** COMMAND: attachment*
689 **
690 ** Usage: %fossil attachment add ?PAGENAME? FILENAME ?OPTIONS?
691 **
692 ** Add an attachment to an existing wiki page or tech note.
693 **
694 ** Options:
695 ** -t|--technote DATETIME Specifies the timestamp of
696 ** the technote to which the attachment
697 ** is to be made. The attachment will be
698 ** to the most recently modified tech note
699 ** with the specified timestamp.
700 ** -t|--technote TECHNOTE-ID Specifies the technote to be
701 ** updated by its technote id.
702 **
703 ** One of PAGENAME, DATETIME or TECHNOTE-ID must be specified.
704 */
705 void attachment_cmd(void){
706 int n;
707 db_find_and_open_repository(0, 0);
708 if( g.argc<3 ){
@@ -732,17 +741,16 @@
741 }
742 zTarget = zPageName;
743 zFile = g.argv[4];
744 }else{
745 if( g.argc!=4 ){
746 usage("add FILENAME --technote DATETIME|TECHNOTE-ID");
747 }
748 rid = wiki_technote_to_rid(zETime);
749 if( rid<0 ){
750 fossil_fatal("ambiguous tech note id: %s", zETime);
751 }
 
752 if( (pWiki = manifest_get(rid, CFTYPE_EVENT, 0))!=0 ){
753 zBody = pWiki->zWiki;
754 }
755 if( zBody==0 ){
756 fossil_fatal("technote [%s] not found",zETime);
757
+3 -2
--- src/wiki.c
+++ src/wiki.c
@@ -1142,13 +1142,14 @@
11421142
db_finalize(&q);
11431143
}
11441144
if (!rid) {
11451145
if (strlen(zETime)>4) {
11461146
rid = db_int(0, "SELECT objid"
1147
- " FROM event"
1147
+ " FROM event"
11481148
" WHERE datetime(mtime)=datetime('%q')"
1149
- " AND type='e'"
1149
+ " AND type='e'"
1150
+ " AND tagid IS NOT NULL"
11501151
" ORDER BY mtime DESC LIMIT 1",
11511152
zETime);
11521153
}
11531154
}
11541155
return rid;
11551156
--- src/wiki.c
+++ src/wiki.c
@@ -1142,13 +1142,14 @@
1142 db_finalize(&q);
1143 }
1144 if (!rid) {
1145 if (strlen(zETime)>4) {
1146 rid = db_int(0, "SELECT objid"
1147 " FROM event"
1148 " WHERE datetime(mtime)=datetime('%q')"
1149 " AND type='e'"
 
1150 " ORDER BY mtime DESC LIMIT 1",
1151 zETime);
1152 }
1153 }
1154 return rid;
1155
--- src/wiki.c
+++ src/wiki.c
@@ -1142,13 +1142,14 @@
1142 db_finalize(&q);
1143 }
1144 if (!rid) {
1145 if (strlen(zETime)>4) {
1146 rid = db_int(0, "SELECT objid"
1147 " FROM event"
1148 " WHERE datetime(mtime)=datetime('%q')"
1149 " AND type='e'"
1150 " AND tagid IS NOT NULL"
1151 " ORDER BY mtime DESC LIMIT 1",
1152 zETime);
1153 }
1154 }
1155 return rid;
1156
+14 -2
--- test/wiki.test
+++ test/wiki.test
@@ -309,21 +309,33 @@
309309
# Check we can update technote by its id
310310
write_file f14 "Updated text for the really old tech note"
311311
fossil wiki commit {Old tech note} f14 --technote $anoldtechnoteid
312312
fossil wiki export a14 --technote $anoldtechnoteid
313313
test wiki-43 {[similar_file f14 a14]}
314
+
315
+###############################################################################
316
+# Check we can add attachments to a technote by its id
317
+fossil attachment add fa --technote $anoldtechnoteid
318
+test wiki-44 {$CODE == 0}
314319
315320
###############################################################################
316321
# Also check that we can specify a prefix of the tech note id
317322
write_file f15 "Updated text for the really old tech note specified by its id"
318323
fossil wiki commit {Old tech note} f15 --technote [string range $anoldtechnoteid 0 20]
319324
fossil wiki export a15 --technote $anoldtechnoteid
320
-test wiki-44 {[similar_file f15 a15]}
325
+test wiki-45 {[similar_file f15 a15]}
326
+
327
+###############################################################################
328
+# Check we can add attachments to a technote by a prefix of its id
329
+fossil attachment add fa --technote [string range $anoldtechnoteid 0 20]
330
+test wiki-46 {$CODE == 0}
321331
322332
###############################################################################
323333
# And we get an error for the ambiguous tech note id
324334
fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
325
-test wiki-45 {$CODE != 0}
335
+test wiki-47 {$CODE != 0}
336
+fossil attachment add fa --technote $duplicateid -expectError
337
+test wiki-48 {$CODE != 0}
326338
327339
###############################################################################
328340
test_cleanup
329341
330342
--- test/wiki.test
+++ test/wiki.test
@@ -309,21 +309,33 @@
309 # Check we can update technote by its id
310 write_file f14 "Updated text for the really old tech note"
311 fossil wiki commit {Old tech note} f14 --technote $anoldtechnoteid
312 fossil wiki export a14 --technote $anoldtechnoteid
313 test wiki-43 {[similar_file f14 a14]}
 
 
 
 
 
314
315 ###############################################################################
316 # Also check that we can specify a prefix of the tech note id
317 write_file f15 "Updated text for the really old tech note specified by its id"
318 fossil wiki commit {Old tech note} f15 --technote [string range $anoldtechnoteid 0 20]
319 fossil wiki export a15 --technote $anoldtechnoteid
320 test wiki-44 {[similar_file f15 a15]}
 
 
 
 
 
321
322 ###############################################################################
323 # And we get an error for the ambiguous tech note id
324 fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
325 test wiki-45 {$CODE != 0}
 
 
326
327 ###############################################################################
328 test_cleanup
329
330
--- test/wiki.test
+++ test/wiki.test
@@ -309,21 +309,33 @@
309 # Check we can update technote by its id
310 write_file f14 "Updated text for the really old tech note"
311 fossil wiki commit {Old tech note} f14 --technote $anoldtechnoteid
312 fossil wiki export a14 --technote $anoldtechnoteid
313 test wiki-43 {[similar_file f14 a14]}
314
315 ###############################################################################
316 # Check we can add attachments to a technote by its id
317 fossil attachment add fa --technote $anoldtechnoteid
318 test wiki-44 {$CODE == 0}
319
320 ###############################################################################
321 # Also check that we can specify a prefix of the tech note id
322 write_file f15 "Updated text for the really old tech note specified by its id"
323 fossil wiki commit {Old tech note} f15 --technote [string range $anoldtechnoteid 0 20]
324 fossil wiki export a15 --technote $anoldtechnoteid
325 test wiki-45 {[similar_file f15 a15]}
326
327 ###############################################################################
328 # Check we can add attachments to a technote by a prefix of its id
329 fossil attachment add fa --technote [string range $anoldtechnoteid 0 20]
330 test wiki-46 {$CODE == 0}
331
332 ###############################################################################
333 # And we get an error for the ambiguous tech note id
334 fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
335 test wiki-47 {$CODE != 0}
336 fossil attachment add fa --technote $duplicateid -expectError
337 test wiki-48 {$CODE != 0}
338
339 ###############################################################################
340 test_cleanup
341
342

Keyboard Shortcuts

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