Fossil SCM

Add support for multiple branch names in the doc-branch setting, as discussed in [forum:520d420d04e482b2 | forum post 520d420d04].

stephan 2024-10-20 14:49 trunk
Commit b82749b94bd1db3fe23c128579ea858cca3542b2e41b0f81b18c022d008338a2
2 files changed +25 -17 +4 -3
+25 -17
--- src/search.c
+++ src/search.c
@@ -794,30 +794,38 @@
794794
SRCHFLG_STATIC|SRCHFLG_HTML);
795795
if( (srchFlags & SRCH_DOC)!=0 ){
796796
char *zDocGlob = db_get("doc-glob","");
797797
char *zDocBr = db_get("doc-branch","trunk");
798798
if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
799
+ Glob * pGlob = glob_create(zDocBr)
800
+ /* We're misusing a Glob as a list of comma-/space-delimited
801
+ ** tokens. We're not actually doing glob matches here. */;
802
+ int i;
799803
db_multi_exec(
800804
"CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
801805
);
802
- db_multi_exec(
803
- "INSERT INTO x(label,url,score,id,date,snip)"
804
- " SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
805
- " printf('/doc/%T/%%s',foci.filename),"
806
- " search_score(),"
807
- " 'd'||blob.rid,"
808
- " (SELECT datetime(event.mtime) FROM event"
809
- " WHERE objid=symbolic_name_to_rid(%Q)),"
810
- " search_snippet()"
811
- " FROM foci CROSS JOIN blob"
812
- " WHERE checkinID=symbolic_name_to_rid(%Q)"
813
- " AND blob.uuid=foci.uuid"
814
- " AND search_match(title('d',blob.rid,foci.filename),"
815
- " body('d',blob.rid,foci.filename))"
816
- " AND %z",
817
- zDocBr, zDocBr, zDocBr, glob_expr("foci.filename", zDocGlob)
818
- );
806
+ for( i = 0; i < pGlob->nPattern; ++i ){
807
+ const char * zBranch = pGlob->azPattern[i];
808
+ db_multi_exec(
809
+ "INSERT INTO x(label,url,score,id,date,snip)"
810
+ " SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
811
+ " printf('/doc/%T/%%s',foci.filename),"
812
+ " search_score(),"
813
+ " 'd'||blob.rid,"
814
+ " (SELECT datetime(event.mtime) FROM event"
815
+ " WHERE objid=symbolic_name_to_rid(%Q)),"
816
+ " search_snippet()"
817
+ " FROM foci CROSS JOIN blob"
818
+ " WHERE checkinID=symbolic_name_to_rid(%Q)"
819
+ " AND blob.uuid=foci.uuid"
820
+ " AND search_match(title('d',blob.rid,foci.filename),"
821
+ " body('d',blob.rid,foci.filename))"
822
+ " AND %z",
823
+ zBranch, zBranch, zBranch, glob_expr("foci.filename", zDocGlob)
824
+ );
825
+ }
826
+ glob_free(pGlob);
819827
}
820828
fossil_free(zDocGlob);
821829
fossil_free(zDocBr);
822830
}
823831
if( (srchFlags & SRCH_WIKI)!=0 ){
824832
--- src/search.c
+++ src/search.c
@@ -794,30 +794,38 @@
794 SRCHFLG_STATIC|SRCHFLG_HTML);
795 if( (srchFlags & SRCH_DOC)!=0 ){
796 char *zDocGlob = db_get("doc-glob","");
797 char *zDocBr = db_get("doc-branch","trunk");
798 if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
 
 
 
 
799 db_multi_exec(
800 "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
801 );
802 db_multi_exec(
803 "INSERT INTO x(label,url,score,id,date,snip)"
804 " SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
805 " printf('/doc/%T/%%s',foci.filename),"
806 " search_score(),"
807 " 'd'||blob.rid,"
808 " (SELECT datetime(event.mtime) FROM event"
809 " WHERE objid=symbolic_name_to_rid(%Q)),"
810 " search_snippet()"
811 " FROM foci CROSS JOIN blob"
812 " WHERE checkinID=symbolic_name_to_rid(%Q)"
813 " AND blob.uuid=foci.uuid"
814 " AND search_match(title('d',blob.rid,foci.filename),"
815 " body('d',blob.rid,foci.filename))"
816 " AND %z",
817 zDocBr, zDocBr, zDocBr, glob_expr("foci.filename", zDocGlob)
818 );
 
 
 
 
819 }
820 fossil_free(zDocGlob);
821 fossil_free(zDocBr);
822 }
823 if( (srchFlags & SRCH_WIKI)!=0 ){
824
--- src/search.c
+++ src/search.c
@@ -794,30 +794,38 @@
794 SRCHFLG_STATIC|SRCHFLG_HTML);
795 if( (srchFlags & SRCH_DOC)!=0 ){
796 char *zDocGlob = db_get("doc-glob","");
797 char *zDocBr = db_get("doc-branch","trunk");
798 if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
799 Glob * pGlob = glob_create(zDocBr)
800 /* We're misusing a Glob as a list of comma-/space-delimited
801 ** tokens. We're not actually doing glob matches here. */;
802 int i;
803 db_multi_exec(
804 "CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;"
805 );
806 for( i = 0; i < pGlob->nPattern; ++i ){
807 const char * zBranch = pGlob->azPattern[i];
808 db_multi_exec(
809 "INSERT INTO x(label,url,score,id,date,snip)"
810 " SELECT printf('Document: %%s',title('d',blob.rid,foci.filename)),"
811 " printf('/doc/%T/%%s',foci.filename),"
812 " search_score(),"
813 " 'd'||blob.rid,"
814 " (SELECT datetime(event.mtime) FROM event"
815 " WHERE objid=symbolic_name_to_rid(%Q)),"
816 " search_snippet()"
817 " FROM foci CROSS JOIN blob"
818 " WHERE checkinID=symbolic_name_to_rid(%Q)"
819 " AND blob.uuid=foci.uuid"
820 " AND search_match(title('d',blob.rid,foci.filename),"
821 " body('d',blob.rid,foci.filename))"
822 " AND %z",
823 zBranch, zBranch, zBranch, glob_expr("foci.filename", zDocGlob)
824 );
825 }
826 glob_free(pGlob);
827 }
828 fossil_free(zDocGlob);
829 fossil_free(zDocBr);
830 }
831 if( (srchFlags & SRCH_WIKI)!=0 ){
832
+4 -3
--- src/setup.c
+++ src/setup.c
@@ -2187,14 +2187,15 @@
21872187
@ <tr><td>*<td><td>Search all checked-in files</tr>
21882188
@ <tr><td><i>(blank)</i><td>
21892189
@ <td>Search nothing. (Disables document search).</tr>
21902190
@ </table>
21912191
@ <hr>
2192
- entry_attribute("Document Branch", 20, "doc-branch", "db", "trunk", 0);
2192
+ entry_attribute("Document Branches", 20, "doc-branch", "db", "trunk", 0);
21932193
@ <p>When searching documents, use the versions of the files found at the
2194
- @ type of the "Document Branch" branch. Recommended value: "trunk".
2195
- @ Document search is disabled if blank.
2194
+ @ type of the "Document Branches" branch. Recommended value: "trunk".
2195
+ @ Document search is disabled if blank. It may be a list of branch names
2196
+ @ separated by spaces and/or commas.
21962197
@ <hr>
21972198
onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
21982199
@ <br>
21992200
onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
22002201
@ <br>
22012202
--- src/setup.c
+++ src/setup.c
@@ -2187,14 +2187,15 @@
2187 @ <tr><td>*<td><td>Search all checked-in files</tr>
2188 @ <tr><td><i>(blank)</i><td>
2189 @ <td>Search nothing. (Disables document search).</tr>
2190 @ </table>
2191 @ <hr>
2192 entry_attribute("Document Branch", 20, "doc-branch", "db", "trunk", 0);
2193 @ <p>When searching documents, use the versions of the files found at the
2194 @ type of the "Document Branch" branch. Recommended value: "trunk".
2195 @ Document search is disabled if blank.
 
2196 @ <hr>
2197 onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
2198 @ <br>
2199 onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
2200 @ <br>
2201
--- src/setup.c
+++ src/setup.c
@@ -2187,14 +2187,15 @@
2187 @ <tr><td>*<td><td>Search all checked-in files</tr>
2188 @ <tr><td><i>(blank)</i><td>
2189 @ <td>Search nothing. (Disables document search).</tr>
2190 @ </table>
2191 @ <hr>
2192 entry_attribute("Document Branches", 20, "doc-branch", "db", "trunk", 0);
2193 @ <p>When searching documents, use the versions of the files found at the
2194 @ type of the "Document Branches" branch. Recommended value: "trunk".
2195 @ Document search is disabled if blank. It may be a list of branch names
2196 @ separated by spaces and/or commas.
2197 @ <hr>
2198 onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
2199 @ <br>
2200 onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
2201 @ <br>
2202

Keyboard Shortcuts

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