Fossil SCM
Add the 'unversioned content' and 'unversioned list' commands to TH1.
Commit
e81fbfd0287d9101a82b60801d54c4236ab32e4c
Parent
e727b3d50b119f1…
2 files changed
+85
+19
+85
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1317,10 +1317,94 @@ | ||
| 1317 | 1317 | }else{ |
| 1318 | 1318 | Th_SetResult(interp, "repository unavailable", -1); |
| 1319 | 1319 | return TH_ERROR; |
| 1320 | 1320 | } |
| 1321 | 1321 | } |
| 1322 | + | |
| 1323 | +/* | |
| 1324 | +** TH1 command: unversioned content FILENAME | |
| 1325 | +** | |
| 1326 | +** Attempts to locate the specified unversioned file and return its contents. | |
| 1327 | +** An error is generated if the repository is not open or the unversioned file | |
| 1328 | +** cannot be found. | |
| 1329 | +*/ | |
| 1330 | +static int unversionedContentCmd( | |
| 1331 | + Th_Interp *interp, | |
| 1332 | + void *p, | |
| 1333 | + int argc, | |
| 1334 | + const char **argv, | |
| 1335 | + int *argl | |
| 1336 | +){ | |
| 1337 | + if( argc!=3 ){ | |
| 1338 | + return Th_WrongNumArgs(interp, "unversioned content FILENAME"); | |
| 1339 | + } | |
| 1340 | + if( Th_IsRepositoryOpen() ){ | |
| 1341 | + int rc; | |
| 1342 | + Blob content; | |
| 1343 | + rc = unversioned_content(argv[2], &content); | |
| 1344 | + if( rc==0 ){ | |
| 1345 | + Th_SetResult(interp, blob_str(&content), blob_size(&content)); | |
| 1346 | + blob_reset(&content); | |
| 1347 | + return TH_OK; | |
| 1348 | + }else{ | |
| 1349 | + return TH_ERROR; | |
| 1350 | + } | |
| 1351 | + }else{ | |
| 1352 | + Th_SetResult(interp, "repository unavailable", -1); | |
| 1353 | + return TH_ERROR; | |
| 1354 | + } | |
| 1355 | +} | |
| 1356 | + | |
| 1357 | +/* | |
| 1358 | +** TH1 command: unversioned list | |
| 1359 | +** | |
| 1360 | +** Returns a list of the names of all unversioned files held in the local | |
| 1361 | +** repository. | |
| 1362 | +*/ | |
| 1363 | +static int unversionedListCmd( | |
| 1364 | + Th_Interp *interp, | |
| 1365 | + void *p, | |
| 1366 | + int argc, | |
| 1367 | + const char **argv, | |
| 1368 | + int *argl | |
| 1369 | +){ | |
| 1370 | + if( argc!=2 ){ | |
| 1371 | + return Th_WrongNumArgs(interp, "unversioned list"); | |
| 1372 | + } | |
| 1373 | + if( Th_IsRepositoryOpen() ){ | |
| 1374 | + Stmt q; | |
| 1375 | + char *zList = 0; | |
| 1376 | + int nList = 0; | |
| 1377 | + db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL" | |
| 1378 | + " ORDER BY name"); | |
| 1379 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 1380 | + Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1); | |
| 1381 | + } | |
| 1382 | + db_finalize(&q); | |
| 1383 | + Th_SetResult(interp, zList, nList); | |
| 1384 | + Th_Free(interp, zList); | |
| 1385 | + return TH_OK; | |
| 1386 | + }else{ | |
| 1387 | + Th_SetResult(interp, "repository unavailable", -1); | |
| 1388 | + return TH_ERROR; | |
| 1389 | + } | |
| 1390 | +} | |
| 1391 | + | |
| 1392 | +static int unversionedCmd( | |
| 1393 | + Th_Interp *interp, | |
| 1394 | + void *p, | |
| 1395 | + int argc, | |
| 1396 | + const char **argv, | |
| 1397 | + int *argl | |
| 1398 | +){ | |
| 1399 | + static const Th_SubCommand aSub[] = { | |
| 1400 | + { "content", unversionedContentCmd }, | |
| 1401 | + { "list", unversionedListCmd }, | |
| 1402 | + { 0, 0 } | |
| 1403 | + }; | |
| 1404 | + return Th_CallSubCommand(interp, p, argc, argv, argl, aSub); | |
| 1405 | +} | |
| 1322 | 1406 | |
| 1323 | 1407 | #ifdef _WIN32 |
| 1324 | 1408 | # include <windows.h> |
| 1325 | 1409 | #else |
| 1326 | 1410 | # include <sys/time.h> |
| @@ -1886,10 +1970,11 @@ | ||
| 1886 | 1970 | {"styleHeader", styleHeaderCmd, 0}, |
| 1887 | 1971 | {"styleFooter", styleFooterCmd, 0}, |
| 1888 | 1972 | {"tclReady", tclReadyCmd, 0}, |
| 1889 | 1973 | {"trace", traceCmd, 0}, |
| 1890 | 1974 | {"stime", stimeCmd, 0}, |
| 1975 | + {"unversioned", unversionedCmd, 0}, | |
| 1891 | 1976 | {"utime", utimeCmd, 0}, |
| 1892 | 1977 | {"verifyCsrf", verifyCsrfCmd, 0}, |
| 1893 | 1978 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 1894 | 1979 | {0, 0, 0} |
| 1895 | 1980 | }; |
| 1896 | 1981 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1317,10 +1317,94 @@ | |
| 1317 | }else{ |
| 1318 | Th_SetResult(interp, "repository unavailable", -1); |
| 1319 | return TH_ERROR; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | #ifdef _WIN32 |
| 1324 | # include <windows.h> |
| 1325 | #else |
| 1326 | # include <sys/time.h> |
| @@ -1886,10 +1970,11 @@ | |
| 1886 | {"styleHeader", styleHeaderCmd, 0}, |
| 1887 | {"styleFooter", styleFooterCmd, 0}, |
| 1888 | {"tclReady", tclReadyCmd, 0}, |
| 1889 | {"trace", traceCmd, 0}, |
| 1890 | {"stime", stimeCmd, 0}, |
| 1891 | {"utime", utimeCmd, 0}, |
| 1892 | {"verifyCsrf", verifyCsrfCmd, 0}, |
| 1893 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 1894 | {0, 0, 0} |
| 1895 | }; |
| 1896 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1317,10 +1317,94 @@ | |
| 1317 | }else{ |
| 1318 | Th_SetResult(interp, "repository unavailable", -1); |
| 1319 | return TH_ERROR; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | /* |
| 1324 | ** TH1 command: unversioned content FILENAME |
| 1325 | ** |
| 1326 | ** Attempts to locate the specified unversioned file and return its contents. |
| 1327 | ** An error is generated if the repository is not open or the unversioned file |
| 1328 | ** cannot be found. |
| 1329 | */ |
| 1330 | static int unversionedContentCmd( |
| 1331 | Th_Interp *interp, |
| 1332 | void *p, |
| 1333 | int argc, |
| 1334 | const char **argv, |
| 1335 | int *argl |
| 1336 | ){ |
| 1337 | if( argc!=3 ){ |
| 1338 | return Th_WrongNumArgs(interp, "unversioned content FILENAME"); |
| 1339 | } |
| 1340 | if( Th_IsRepositoryOpen() ){ |
| 1341 | int rc; |
| 1342 | Blob content; |
| 1343 | rc = unversioned_content(argv[2], &content); |
| 1344 | if( rc==0 ){ |
| 1345 | Th_SetResult(interp, blob_str(&content), blob_size(&content)); |
| 1346 | blob_reset(&content); |
| 1347 | return TH_OK; |
| 1348 | }else{ |
| 1349 | return TH_ERROR; |
| 1350 | } |
| 1351 | }else{ |
| 1352 | Th_SetResult(interp, "repository unavailable", -1); |
| 1353 | return TH_ERROR; |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | /* |
| 1358 | ** TH1 command: unversioned list |
| 1359 | ** |
| 1360 | ** Returns a list of the names of all unversioned files held in the local |
| 1361 | ** repository. |
| 1362 | */ |
| 1363 | static int unversionedListCmd( |
| 1364 | Th_Interp *interp, |
| 1365 | void *p, |
| 1366 | int argc, |
| 1367 | const char **argv, |
| 1368 | int *argl |
| 1369 | ){ |
| 1370 | if( argc!=2 ){ |
| 1371 | return Th_WrongNumArgs(interp, "unversioned list"); |
| 1372 | } |
| 1373 | if( Th_IsRepositoryOpen() ){ |
| 1374 | Stmt q; |
| 1375 | char *zList = 0; |
| 1376 | int nList = 0; |
| 1377 | db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL" |
| 1378 | " ORDER BY name"); |
| 1379 | while( db_step(&q)==SQLITE_ROW ){ |
| 1380 | Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1); |
| 1381 | } |
| 1382 | db_finalize(&q); |
| 1383 | Th_SetResult(interp, zList, nList); |
| 1384 | Th_Free(interp, zList); |
| 1385 | return TH_OK; |
| 1386 | }else{ |
| 1387 | Th_SetResult(interp, "repository unavailable", -1); |
| 1388 | return TH_ERROR; |
| 1389 | } |
| 1390 | } |
| 1391 | |
| 1392 | static int unversionedCmd( |
| 1393 | Th_Interp *interp, |
| 1394 | void *p, |
| 1395 | int argc, |
| 1396 | const char **argv, |
| 1397 | int *argl |
| 1398 | ){ |
| 1399 | static const Th_SubCommand aSub[] = { |
| 1400 | { "content", unversionedContentCmd }, |
| 1401 | { "list", unversionedListCmd }, |
| 1402 | { 0, 0 } |
| 1403 | }; |
| 1404 | return Th_CallSubCommand(interp, p, argc, argv, argl, aSub); |
| 1405 | } |
| 1406 | |
| 1407 | #ifdef _WIN32 |
| 1408 | # include <windows.h> |
| 1409 | #else |
| 1410 | # include <sys/time.h> |
| @@ -1886,10 +1970,11 @@ | |
| 1970 | {"styleHeader", styleHeaderCmd, 0}, |
| 1971 | {"styleFooter", styleFooterCmd, 0}, |
| 1972 | {"tclReady", tclReadyCmd, 0}, |
| 1973 | {"trace", traceCmd, 0}, |
| 1974 | {"stime", stimeCmd, 0}, |
| 1975 | {"unversioned", unversionedCmd, 0}, |
| 1976 | {"utime", utimeCmd, 0}, |
| 1977 | {"verifyCsrf", verifyCsrfCmd, 0}, |
| 1978 | {"wiki", wikiCmd, (void*)&aFlags[0]}, |
| 1979 | {0, 0, 0} |
| 1980 | }; |
| 1981 |
+19
| --- www/th1.md | ||
| +++ www/th1.md | ||
| @@ -173,10 +173,12 @@ | ||
| 173 | 173 | * tclInvoke |
| 174 | 174 | * tclIsSafe |
| 175 | 175 | * tclMakeSafe |
| 176 | 176 | * tclReady |
| 177 | 177 | * trace |
| 178 | + * unversioned content | |
| 179 | + * unversioned list | |
| 178 | 180 | * stime |
| 179 | 181 | * utime |
| 180 | 182 | * verifyCsrf |
| 181 | 183 | * wiki |
| 182 | 184 | |
| @@ -602,10 +604,27 @@ | ||
| 602 | 604 | ------------------------------------- |
| 603 | 605 | |
| 604 | 606 | * trace STRING |
| 605 | 607 | |
| 606 | 608 | Generates a TH1 trace message if TH1 tracing is enabled. |
| 609 | + | |
| 610 | +<a name="unversioned_content"></a>TH1 unversioned content Command | |
| 611 | +------------------------------------------- | |
| 612 | + | |
| 613 | + * unversioned content FILENAME | |
| 614 | + | |
| 615 | +Attempts to locate the specified unversioned file and return its contents. | |
| 616 | +An error is generated if the repository is not open or the unversioned file | |
| 617 | +cannot be found. | |
| 618 | + | |
| 619 | +<a name="unversioned_list"></a>TH1 unversioned list Command | |
| 620 | +------------------------------------------- | |
| 621 | + | |
| 622 | + * unversioned list | |
| 623 | + | |
| 624 | +Returns a list of the names of all unversioned files held in the local | |
| 625 | +repository. | |
| 607 | 626 | |
| 608 | 627 | <a name="stime"></a>TH1 stime Command |
| 609 | 628 | ------------------------------------- |
| 610 | 629 | |
| 611 | 630 | * stime |
| 612 | 631 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -173,10 +173,12 @@ | |
| 173 | * tclInvoke |
| 174 | * tclIsSafe |
| 175 | * tclMakeSafe |
| 176 | * tclReady |
| 177 | * trace |
| 178 | * stime |
| 179 | * utime |
| 180 | * verifyCsrf |
| 181 | * wiki |
| 182 | |
| @@ -602,10 +604,27 @@ | |
| 602 | ------------------------------------- |
| 603 | |
| 604 | * trace STRING |
| 605 | |
| 606 | Generates a TH1 trace message if TH1 tracing is enabled. |
| 607 | |
| 608 | <a name="stime"></a>TH1 stime Command |
| 609 | ------------------------------------- |
| 610 | |
| 611 | * stime |
| 612 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -173,10 +173,12 @@ | |
| 173 | * tclInvoke |
| 174 | * tclIsSafe |
| 175 | * tclMakeSafe |
| 176 | * tclReady |
| 177 | * trace |
| 178 | * unversioned content |
| 179 | * unversioned list |
| 180 | * stime |
| 181 | * utime |
| 182 | * verifyCsrf |
| 183 | * wiki |
| 184 | |
| @@ -602,10 +604,27 @@ | |
| 604 | ------------------------------------- |
| 605 | |
| 606 | * trace STRING |
| 607 | |
| 608 | Generates a TH1 trace message if TH1 tracing is enabled. |
| 609 | |
| 610 | <a name="unversioned_content"></a>TH1 unversioned content Command |
| 611 | ------------------------------------------- |
| 612 | |
| 613 | * unversioned content FILENAME |
| 614 | |
| 615 | Attempts to locate the specified unversioned file and return its contents. |
| 616 | An error is generated if the repository is not open or the unversioned file |
| 617 | cannot be found. |
| 618 | |
| 619 | <a name="unversioned_list"></a>TH1 unversioned list Command |
| 620 | ------------------------------------------- |
| 621 | |
| 622 | * unversioned list |
| 623 | |
| 624 | Returns a list of the names of all unversioned files held in the local |
| 625 | repository. |
| 626 | |
| 627 | <a name="stime"></a>TH1 stime Command |
| 628 | ------------------------------------- |
| 629 | |
| 630 | * stime |
| 631 |