Fossil SCM
[WIP] Removed the conditional code around some options: up to five "extras" WILL be shown by default; single-line difference reports WILL be shown first (ahead of those with "diff blocks") and "diff blocks" WILL have dividers. Removed a number of my "place holder" comments.
Commit
996a056f9d3b9ebbbb3b127a1a438370ba83a3bcf715822b35892122b6718aa3
Parent
e494b979545c52b…
1 file changed
+27
-133
+27
-133
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -42,31 +42,10 @@ | ||
| 42 | 42 | ** non-static so that it can be called from here. |
| 43 | 43 | **----------------------------------------------------------------------------- |
| 44 | 44 | ** Options to control the "local changes" changes. At present, these are |
| 45 | 45 | ** defines: if these changes are adopted, some may want to be made into |
| 46 | 46 | ** configuration options. |
| 47 | -** | |
| 48 | -** INTEGER: Controls how many unmanaged files will be shown before the "plus xxx | |
| 49 | -** other matching files." line is shown (with an option to view all of them).*/ | |
| 50 | -#define LOCAL_DIFF_MAX_EXTRAS (5) | |
| 51 | -/* | |
| 52 | -** STRING: Controls whether the "extras" report is initially shown or hidden. A | |
| 53 | -** value of "0" hides the report; a value of "" (an empty string) will show it. | |
| 54 | -*/ | |
| 55 | -#define LOCAL_DIFF_EXTRAS_MODE ("") | |
| 56 | -/* | |
| 57 | -** BOOLEAN: Controls whether one or two passes are made through the list of | |
| 58 | -** changed files. In two-pass mode, all single-line differences are displayed | |
| 59 | -** ahead of all differences involving "diff-blocks", making them less likely to | |
| 60 | -** be overlooked. If disabled, only one pass is made, listing all changes in the | |
| 61 | -** order found. Possible TODO: Do the same for "normal" diffs. */ | |
| 62 | -#define LOCAL_DIFF_USE_TWO_PASSES (1) | |
| 63 | -/* | |
| 64 | -** BOOLEAN: Controls whether dividers ("<hr/>") added after any "diff-blocks" | |
| 65 | -** (except the last one)... IMHO doing so makes it easier to see where one block | |
| 66 | -** ends and the next starts. Possible TODO: Do the same for "normal" diffs. */ | |
| 67 | -#define LOCAL_DIFF_ADD_DIVIDER (1) | |
| 68 | 47 | /*---------------------------------------------------------------------------*/ |
| 69 | 48 | |
| 70 | 49 | /* |
| 71 | 50 | ** Return a string (in memory obtained from malloc) holding a |
| 72 | 51 | ** comma-separated list of tags that apply to check-in with |
| @@ -548,24 +527,23 @@ | ||
| 548 | 527 | ReCompiled *pRe, /* Only show diffs that match this regex, if not NULL */ |
| 549 | 528 | int pass /* 0x01 - Display single-line entries only */ |
| 550 | 529 | /* 0x02 - Display entries with "diff blocks" only */ |
| 551 | 530 | /* 0x03 - Display both */ |
| 552 | 531 | ){ |
| 553 | -#if LOCAL_DIFF_ADD_DIVIDER | |
| 554 | 532 | /* This remembers whether a side-by-side "diff-block" was shown the last |
| 555 | 533 | ** time through. If it was, we will add "<hr/>" to better separate the |
| 556 | 534 | ** blocks. |
| 557 | 535 | */ |
| 558 | 536 | static int diffShownLastTime = 0; |
| 559 | -#endif | |
| 537 | + | |
| 560 | 538 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 561 | 539 | int isFilePresent = !file_access(zFullName, F_OK); |
| 540 | + | |
| 562 | 541 | /* Determing up-front whether we would be showing a "diff-block" so we can |
| 563 | 542 | ** filter them according to which pass we are on: the first pass will show |
| 564 | 543 | ** only the "single-line" entries; the second will show only those with |
| 565 | - ** diff-blocks. In single-pass mode (the original way), 'pass' will be "3", | |
| 566 | - ** so all entries are shown in their original order. | |
| 544 | + ** diff-blocks. | |
| 567 | 545 | */ |
| 568 | 546 | int showDiff = ( isDeleted && isFilePresent ) |
| 569 | 547 | || ( !isDeleted && !isNew && ( ( isChnged == 1 ) |
| 570 | 548 | || ( isChnged == 2 ) |
| 571 | 549 | || ( isChnged == 4 ) |
| @@ -574,20 +552,20 @@ | ||
| 574 | 552 | /* We don't use 'diffFlags' in these tests so that whether "Hide diffs" is |
| 575 | 553 | ** in effect or not, the order won't change. |
| 576 | 554 | */ |
| 577 | 555 | if( showDiff && (pass == 1) ){ return; } /* Don't do diff on pass 1 of 2 */ |
| 578 | 556 | if( !showDiff && (pass == 2) ){ return; } /* Don't do line on pass 2 of 2 */ |
| 579 | -#if LOCAL_DIFF_ADD_DIVIDER | |
| 557 | + | |
| 580 | 558 | /* If a SBS diff-block was shown by the previous entry, add a divider */ |
| 581 | 559 | if( diffShownLastTime && (diffFlags & DIFF_SIDEBYSIDE) ){ |
| 582 | 560 | @ <hr/> |
| 583 | 561 | } |
| 584 | 562 | /* Record whether we will be showing a diff-block this time. We DO factor in |
| 585 | 563 | ** 'diffFlags' here so that in "Hide diffs" mode, we don't get extra lines. |
| 586 | 564 | */ |
| 587 | 565 | diffShownLastTime = showDiff && diffFlags; |
| 588 | -#endif | |
| 566 | + | |
| 589 | 567 | @ <p> |
| 590 | 568 | if( !g.perm.Hyperlink ){ |
| 591 | 569 | if( isDeleted ){ |
| 592 | 570 | if( isFilePresent ){ |
| 593 | 571 | @ Deleted %h(zName) (still present as a local file). |
| @@ -850,12 +828,12 @@ | ||
| 850 | 828 | db_finalize(&q); |
| 851 | 829 | style_finish_page(); |
| 852 | 830 | } |
| 853 | 831 | |
| 854 | 832 | /* |
| 855 | -** Options for the "extras" report. The bit-mask versions are used for "&ef=.." | |
| 856 | -** to select which category(ies) to show. | |
| 833 | +** Options for the "extras" report in "local-diff" mode. The bit-mask versions | |
| 834 | +** are used for "&ef=.." to select which category(ies) to show. | |
| 857 | 835 | */ |
| 858 | 836 | enum { |
| 859 | 837 | EXB_PLAIN, EXB_IGNORE, EXB_CLEAN, EXB_KEEP, |
| 860 | 838 | |
| 861 | 839 | EX_PLAIN = 1 << EXB_PLAIN, /* Matches none of the others */ |
| @@ -904,90 +882,35 @@ | ||
| 904 | 882 | pIgnore = glob_create(zIgnoreFlag); /* Object versions of above */ |
| 905 | 883 | pKeep = glob_create(zKeepFlag); |
| 906 | 884 | pClean = glob_create(zCleanFlag); |
| 907 | 885 | nRoot = (int)strlen(g.zLocalRoot); /* Length of root component */ |
| 908 | 886 | Stmt q; |
| 909 | - Blob repo; /* TODO:LD May not be needed */ | |
| 910 | - int maxExtrasToShow = LOCAL_DIFF_MAX_EXTRAS; | |
| 887 | + Blob repo; | |
| 888 | + int maxExtrasToShow = 5; /* Before showing "+ xx others" */ | |
| 911 | 889 | int extrasFlags = atoi(zExtra); /* Which entries to show */ |
| 912 | 890 | int nExtras; |
| 913 | 891 | int nMatch; |
| 914 | 892 | int nShown; |
| 915 | 893 | int nPlain; |
| 916 | 894 | int nIgnore; |
| 917 | 895 | int nClean; |
| 918 | 896 | int nKeep; |
| 919 | 897 | |
| 920 | - /*TODO:LD? | |
| 921 | - ** It feels sensible to limit the number of "extra" entries shown by default | |
| 922 | - ** for cases where "ignore-glob" or "clean-glob" haven't been fully setup. | |
| 923 | - ** A minor irritation is that this can lead to "... plus 1 more file", on a | |
| 924 | - ** line that COULD have been used to display the omitted file. If we knew in | |
| 925 | - ** advance how many entries were going to match, we could temporarily "bump" | |
| 926 | - ** the limit by one show all entries would be shown. However, to know the | |
| 927 | - ** number of matches in advance we'd have to: | |
| 928 | - ** a) Pre-scan SFILE, testing and counting matches against each glob-list, | |
| 929 | - ** possibly bump the limit, then re-scan the table repeating the tests | |
| 930 | - ** against each glob-list to decide which to show. | |
| 931 | - ** b) SFILE could have an extra FLAGS field: during the pre-scan, this could | |
| 932 | - ** be updated to indicate which groups each file belong to. This would | |
| 933 | - ** save re-testing every file against each glob-list (the main pass could | |
| 934 | - ** select "WHERE flags & selector" to get only the matching entries), but | |
| 935 | - ** the updates (selecting by "pathname" each time) could be a bit much. | |
| 936 | - ** c) vfile_scan() -- where SFILE is populated -- COULD have an option to | |
| 937 | - ** do the testing at the time entries are added. This would be the "best" | |
| 938 | - ** way, but feels too much disruption to other code for what is only a | |
| 939 | - ** minor benefit. | |
| 940 | - ** For now, I'll stick with the minor annoyance of "plus 1 more file" :-) | |
| 941 | - ** | |
| 942 | - ** Being able to determine the counts up-front would also allow us to hide | |
| 943 | - ** the whole "extras report" if there were no unmanaged files. | |
| 944 | - ** | |
| 945 | - **TODO:LD? | |
| 946 | - ** Does it make sense (and/or is it practiable) to offer an "ADD" button | |
| 947 | - ** against files that are unmanaged? | |
| 948 | - ** | |
| 949 | - **TODO:LD? | |
| 950 | - ** Does it make sense (and/or ...) to offer ediing of the various blob-lists | |
| 951 | - ** from the Extras report? Showing the existing configuration screen would | |
| 952 | - ** probably not be a problem (permissions permitting), but what happens if | |
| 953 | - ** those settings have been overriden by .fossil-settings/ignore-glob? As we | |
| 954 | - ** have access to the local checkout, is it feasible to edit it in the browser | |
| 955 | - ** (perhaps piggy-backing /fileedit)? | |
| 956 | - */ | |
| 957 | - | |
| 958 | - locate_unmanaged_files(0, NULL, 0, NULL); /* Get all unmanaged */ | |
| 898 | + locate_unmanaged_files(0, NULL, 0, NULL); /* Get all unmanaged files */ | |
| 959 | 899 | /*TODO:LD |
| 960 | 900 | ** The first two of these exclusions come from clean_cmd() in checkin.c. |
| 961 | 901 | ** Not sure exactly what they are intended to do (seem to have no effect on |
| 962 | - ** my test repos). Last exclusion is an alternative to the WHERE clause above | |
| 963 | - ** so that COUNT(*) returns the correct value. TODO Even though, as noted | |
| 964 | - ** above, getting the count ahead of time is of little use (it was used to | |
| 965 | - ** bump the display limit if only one entry would be omitted), I'll probably | |
| 966 | - ** retain omitting the WHERE, and using DELETE FROM to exclude reserved | |
| 967 | - ** names, just in case (c) above were to be implemented. | |
| 902 | + ** my test repos). | |
| 968 | 903 | */ |
| 969 | - /*TODO:LD deletions from clean_cmd() */ | |
| 970 | 904 | if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ |
| 971 | 905 | db_multi_exec("DELETE FROM sfile WHERE pathname=%B", &repo); |
| 972 | 906 | } |
| 973 | 907 | db_multi_exec("DELETE FROM sfile WHERE pathname IN" |
| 974 | 908 | " (SELECT pathname FROM vfile)"); |
| 975 | - /*TODO:LD Delete reserved names, rather than WHERE them out. */ | |
| 976 | 909 | db_multi_exec("DELETE FROM sfile WHERE pathname IN (%s)", |
| 977 | 910 | fossil_all_reserved_names(0)); |
| 978 | 911 | |
| 979 | - /*TODO:LD | |
| 980 | - ** If we had a count of matching entries before scanning, this is where | |
| 981 | - ** we'd bump the maximum to show so as to avoid "plus 1 file". | |
| 982 | - ** ... | |
| 983 | - ** If there's only one more than the maximum, let it through... | |
| 984 | - ** a line used to say "plus 1 more" may as well display that item! | |
| 985 | - if( nExtras == maxExtrasToShow+1 ){ maxExtrasToShow++; } | |
| 986 | - ** ... | |
| 987 | - */ | |
| 988 | - | |
| 989 | 912 | /* Handle the special case where zExtra was empty (and got converted to zero). |
| 990 | 913 | ** If so, show "plain" files (those not matching any glob-list) but with an |
| 991 | 914 | ** upper limit to the number shown (set above). If a value WAS given (i.e. |
| 992 | 915 | ** after following a link), display all of the selected entries. */ |
| 993 | 916 | if( extrasFlags==0 ){ |
| @@ -1029,12 +952,10 @@ | ||
| 1029 | 952 | " ORDER BY 1", /*TODO:LD Order by pathname, as for differences? */ |
| 1030 | 953 | g.zLocalRoot |
| 1031 | 954 | ); |
| 1032 | 955 | /* |
| 1033 | 956 | ** Put the file-list in one paragraph with line-breaks between. |
| 1034 | - **TODO:LD | |
| 1035 | - ** Might a table (with columns for name, ignore/clean/keep) work? | |
| 1036 | 957 | */ |
| 1037 | 958 | @ <p> |
| 1038 | 959 | nExtras = nMatch = nShown = nPlain = nKeep = nClean = nIgnore = 0; |
| 1039 | 960 | while( db_step(&q)==SQLITE_ROW ){ |
| 1040 | 961 | const char *zName = db_column_text(&q, 0); |
| @@ -1196,38 +1117,29 @@ | ||
| 1196 | 1117 | ** marked kept)... this is what you'd most want to see if you've created a new |
| 1197 | 1118 | ** source file and forgotten to "fossil add" it. A value of "0" will hide the |
| 1198 | 1119 | ** extras report. Other (numeric) values control what the report shows (e.g. |
| 1199 | 1120 | ** "1" would list ALL unmanaged files without limiting their number). |
| 1200 | 1121 | ** |
| 1201 | - ** If the "ef=" isn't present (as when first navigating to "/local") then a | |
| 1202 | - ** default setting is used. Set to "0" to initially hide the report. | |
| 1122 | + ** If the "ef=" is absent then default to "" (show (some) unmanaged files). | |
| 1203 | 1123 | */ |
| 1204 | 1124 | zExtra = P("ef"); |
| 1205 | 1125 | if( zExtra==NULL ) { |
| 1206 | - zExtra = LOCAL_DIFF_EXTRAS_MODE; | |
| 1126 | + zExtra = ""; | |
| 1207 | 1127 | } |
| 1208 | 1128 | showExtras = strcmp(zExtra,"0")!=0; |
| 1209 | 1129 | |
| 1210 | 1130 | /* Local mode is selected by either "/local" or with a "name" of "ckout". |
| 1211 | 1131 | ** First, check we have access to the checkout (and report to the user if we |
| 1212 | 1132 | ** don't), then refresh the "vfile" table (recording which files in the |
| 1213 | 1133 | ** checkout have changed etc.). We then change the "name" parameter to "tip" |
| 1214 | 1134 | ** so that the "header" section displays info about the check-in that the |
| 1215 | 1135 | ** checkout came from. |
| 1216 | - **TODO:LD | |
| 1217 | - ** It would probably make sense to limit "/local" (and other links that come | |
| 1218 | - ** from it) to only be permitted when Fossil is running locally in "ui" mode. | |
| 1219 | - ** It's probably not critical when all you can do is view files in the | |
| 1220 | - ** checkout (they can already see the checked-in versions), but if a COMMIT | |
| 1221 | - ** option WERE ever to be implemented, you wouldn't essentially random people | |
| 1222 | - ** on the internet firing off commits! | |
| 1223 | 1136 | */ |
| 1224 | 1137 | bLocalMode = (g.zPath[0]=='l') || (fossil_strcmp(zName,"ckout")==0); |
| 1225 | 1138 | if( bLocalMode ){ |
| 1226 | 1139 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1227 | 1140 | if( vid==0 ){ |
| 1228 | - /*TODO:LD Is this the right response? */ | |
| 1229 | 1141 | style_header("No Local Checkout"); |
| 1230 | 1142 | @ No access to local checkout. |
| 1231 | 1143 | style_finish_page(); |
| 1232 | 1144 | return; |
| 1233 | 1145 | } |
| @@ -1525,30 +1437,24 @@ | ||
| 1525 | 1437 | @ %z(button) |
| 1526 | 1438 | @ Ignore Whitespace</a> |
| 1527 | 1439 | } |
| 1528 | 1440 | } |
| 1529 | 1441 | if( bLocalMode ){ |
| 1530 | - @ %z(chref("button","%R/localpatch")) Patch</a> | |
| 1531 | - }else | |
| 1442 | + @ %z(chref("button","%R/localpatch")) Patch</a> | |
| 1443 | + if( showExtras ){ | |
| 1444 | + @ %z(chref("button","%R/local?diff=%d%s&ef=0",diffType,zW))Hide Extras</a> | |
| 1445 | + }else{ | |
| 1446 | + @ %z(chref("button","%R/local?diff=%d%s&ef=",diffType,zW))Show Extras</a> | |
| 1447 | + } | |
| 1448 | + }else //TODO:LD Rejoin else-if? | |
| 1532 | 1449 | if( zParent ){ |
| 1533 | 1450 | @ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) |
| 1534 | 1451 | @ Patch</a> |
| 1535 | 1452 | } |
| 1536 | 1453 | if( g.perm.Admin ){ |
| 1537 | 1454 | @ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a> |
| 1538 | 1455 | } |
| 1539 | - if( bLocalMode ){ | |
| 1540 | - if( showExtras ){ | |
| 1541 | - @ %z(chref("button","%R/local?diff=%d%s&ef=0",diffType,zW))Hide Extras</a> | |
| 1542 | - }else{ | |
| 1543 | - @ %z(chref("button","%R/local?diff=%d%s&ef=",diffType,zW))Show Extras</a> | |
| 1544 | - } | |
| 1545 | - /*TODO:LD | |
| 1546 | - ** There would be a fair chunk of stuff to get right (not least appropriate | |
| 1547 | - ** restrictions), but it MIGHT be nice to have a COMMIT button here... | |
| 1548 | - */ | |
| 1549 | - } | |
| 1550 | 1456 | @</div> |
| 1551 | 1457 | if( pRe ){ |
| 1552 | 1458 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 1553 | 1459 | @ are shown.</b></p> |
| 1554 | 1460 | } |
| @@ -1555,14 +1461,10 @@ | ||
| 1555 | 1461 | if( bLocalMode ){ |
| 1556 | 1462 | if( showExtras ){ |
| 1557 | 1463 | append_extras_report(zExtra, diffType, zW); |
| 1558 | 1464 | } |
| 1559 | 1465 | /* Following SQL taken from diff_against_disk() in diffcmd.c */ |
| 1560 | - /*TODO:LD | |
| 1561 | - ** That code wrapped the query/processing in a transaction (but, from | |
| 1562 | - ** memory, other similar uses did not). Is it neeeded? | |
| 1563 | - */ | |
| 1564 | 1466 | db_begin_transaction(); |
| 1565 | 1467 | db_prepare(&q3, |
| 1566 | 1468 | "SELECT pathname, deleted, chnged , rid==0, rid, islink" |
| 1567 | 1469 | " FROM vfile" |
| 1568 | 1470 | " WHERE vid=%d" |
| @@ -1570,24 +1472,17 @@ | ||
| 1570 | 1472 | " ORDER BY pathname /*scan*/", |
| 1571 | 1473 | vid |
| 1572 | 1474 | ); |
| 1573 | 1475 | |
| 1574 | 1476 | /* To prevent single-line diff-entries (those without "diff-blocks") from |
| 1575 | - ** getting "lost", there's an optional "two-pass" mode for processing | |
| 1576 | - ** differences. If enabled, the first pass will only show one-line entries | |
| 1577 | - ** and the second pass will only show those with diff-blocks. This has the | |
| 1578 | - ** side-effect of altering the order entries are shown in (but within each | |
| 1579 | - ** group the original order is maintained). | |
| 1580 | - ** | |
| 1581 | - ** If disabled, (pass gets set to 3), only one pass is made on which all | |
| 1582 | - ** entries are shown in their "normal" order. | |
| 1583 | - **TODO:LD | |
| 1584 | - ** Add this to the original (non-local) loop? | |
| 1477 | + ** getting "lost", the first pass will only show one-line entries and the | |
| 1478 | + ** second pass will only show those with diff-blocks. | |
| 1479 | + ** TODO:LD Add this to the original (non-local) loop? | |
| 1585 | 1480 | */ |
| 1586 | - int pass = LOCAL_DIFF_USE_TWO_PASSES?1:3; | |
| 1481 | + int pass; | |
| 1587 | 1482 | int anyDifferences = 0; |
| 1588 | - do{ | |
| 1483 | + for(pass=1; pass<=2; pass++) { | |
| 1589 | 1484 | while( db_step(&q3)==SQLITE_ROW ){ |
| 1590 | 1485 | const char *zPathname = db_column_text(&q3,0); |
| 1591 | 1486 | int isDeleted = db_column_int(&q3, 1); |
| 1592 | 1487 | int isChnged = db_column_int(&q3,2); |
| 1593 | 1488 | int isNew = db_column_int(&q3,3); |
| @@ -1598,11 +1493,11 @@ | ||
| 1598 | 1493 | isDeleted, isChnged, isNew, isLink, diffFlags,pRe,pass ); |
| 1599 | 1494 | free(zUuid); |
| 1600 | 1495 | anyDifferences = 1; |
| 1601 | 1496 | } |
| 1602 | 1497 | db_reset(&q3); |
| 1603 | - }while( ++pass < 3 ); /* Either "1, 2, stop" or "3, stop". */ | |
| 1498 | + } | |
| 1604 | 1499 | if( !anyDifferences ){ |
| 1605 | 1500 | @ <p>No changes in the local checkout.</p> |
| 1606 | 1501 | } |
| 1607 | 1502 | db_end_transaction(1); /* ROLLBACK to fix uncommitted xaction complaint */ |
| 1608 | 1503 | /*TODO:LD: Implement the optional two-pass code? */ |
| @@ -1650,11 +1545,10 @@ | ||
| 1650 | 1545 | login_check_credentials(); |
| 1651 | 1546 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1652 | 1547 | |
| 1653 | 1548 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1654 | 1549 | if( vid==0 ){ |
| 1655 | - /*TODO:LD Is this the right response? */ | |
| 1656 | 1550 | style_header("No Local Checkout"); |
| 1657 | 1551 | @ No access to local checkout. |
| 1658 | 1552 | style_finish_page(); |
| 1659 | 1553 | return; |
| 1660 | 1554 | } |
| @@ -2516,11 +2410,11 @@ | ||
| 2516 | 2410 | diffFlags = construct_diff_flags(diffType) | DIFF_HTML; |
| 2517 | 2411 | |
| 2518 | 2412 | style_set_current_feature("fdiff"); |
| 2519 | 2413 | style_header("Diff"); |
| 2520 | 2414 | style_submenu_checkbox("w", "Ignore Whitespace", 0, 0); |
| 2521 | - if( bLocalMode ){ | |
| 2415 | + if( bLocalMode ){//TODO:LD Merge these? | |
| 2522 | 2416 | if( diffType==2 ){ |
| 2523 | 2417 | style_submenu_element("Unified Diff", "%R/localdiff?name=%T&diff=1", |
| 2524 | 2418 | zLocalName); |
| 2525 | 2419 | }else{ |
| 2526 | 2420 | style_submenu_element("Side-by-side Diff", "%R/localdiff?name=%T&diff=2", |
| 2527 | 2421 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -42,31 +42,10 @@ | |
| 42 | ** non-static so that it can be called from here. |
| 43 | **----------------------------------------------------------------------------- |
| 44 | ** Options to control the "local changes" changes. At present, these are |
| 45 | ** defines: if these changes are adopted, some may want to be made into |
| 46 | ** configuration options. |
| 47 | ** |
| 48 | ** INTEGER: Controls how many unmanaged files will be shown before the "plus xxx |
| 49 | ** other matching files." line is shown (with an option to view all of them).*/ |
| 50 | #define LOCAL_DIFF_MAX_EXTRAS (5) |
| 51 | /* |
| 52 | ** STRING: Controls whether the "extras" report is initially shown or hidden. A |
| 53 | ** value of "0" hides the report; a value of "" (an empty string) will show it. |
| 54 | */ |
| 55 | #define LOCAL_DIFF_EXTRAS_MODE ("") |
| 56 | /* |
| 57 | ** BOOLEAN: Controls whether one or two passes are made through the list of |
| 58 | ** changed files. In two-pass mode, all single-line differences are displayed |
| 59 | ** ahead of all differences involving "diff-blocks", making them less likely to |
| 60 | ** be overlooked. If disabled, only one pass is made, listing all changes in the |
| 61 | ** order found. Possible TODO: Do the same for "normal" diffs. */ |
| 62 | #define LOCAL_DIFF_USE_TWO_PASSES (1) |
| 63 | /* |
| 64 | ** BOOLEAN: Controls whether dividers ("<hr/>") added after any "diff-blocks" |
| 65 | ** (except the last one)... IMHO doing so makes it easier to see where one block |
| 66 | ** ends and the next starts. Possible TODO: Do the same for "normal" diffs. */ |
| 67 | #define LOCAL_DIFF_ADD_DIVIDER (1) |
| 68 | /*---------------------------------------------------------------------------*/ |
| 69 | |
| 70 | /* |
| 71 | ** Return a string (in memory obtained from malloc) holding a |
| 72 | ** comma-separated list of tags that apply to check-in with |
| @@ -548,24 +527,23 @@ | |
| 548 | ReCompiled *pRe, /* Only show diffs that match this regex, if not NULL */ |
| 549 | int pass /* 0x01 - Display single-line entries only */ |
| 550 | /* 0x02 - Display entries with "diff blocks" only */ |
| 551 | /* 0x03 - Display both */ |
| 552 | ){ |
| 553 | #if LOCAL_DIFF_ADD_DIVIDER |
| 554 | /* This remembers whether a side-by-side "diff-block" was shown the last |
| 555 | ** time through. If it was, we will add "<hr/>" to better separate the |
| 556 | ** blocks. |
| 557 | */ |
| 558 | static int diffShownLastTime = 0; |
| 559 | #endif |
| 560 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 561 | int isFilePresent = !file_access(zFullName, F_OK); |
| 562 | /* Determing up-front whether we would be showing a "diff-block" so we can |
| 563 | ** filter them according to which pass we are on: the first pass will show |
| 564 | ** only the "single-line" entries; the second will show only those with |
| 565 | ** diff-blocks. In single-pass mode (the original way), 'pass' will be "3", |
| 566 | ** so all entries are shown in their original order. |
| 567 | */ |
| 568 | int showDiff = ( isDeleted && isFilePresent ) |
| 569 | || ( !isDeleted && !isNew && ( ( isChnged == 1 ) |
| 570 | || ( isChnged == 2 ) |
| 571 | || ( isChnged == 4 ) |
| @@ -574,20 +552,20 @@ | |
| 574 | /* We don't use 'diffFlags' in these tests so that whether "Hide diffs" is |
| 575 | ** in effect or not, the order won't change. |
| 576 | */ |
| 577 | if( showDiff && (pass == 1) ){ return; } /* Don't do diff on pass 1 of 2 */ |
| 578 | if( !showDiff && (pass == 2) ){ return; } /* Don't do line on pass 2 of 2 */ |
| 579 | #if LOCAL_DIFF_ADD_DIVIDER |
| 580 | /* If a SBS diff-block was shown by the previous entry, add a divider */ |
| 581 | if( diffShownLastTime && (diffFlags & DIFF_SIDEBYSIDE) ){ |
| 582 | @ <hr/> |
| 583 | } |
| 584 | /* Record whether we will be showing a diff-block this time. We DO factor in |
| 585 | ** 'diffFlags' here so that in "Hide diffs" mode, we don't get extra lines. |
| 586 | */ |
| 587 | diffShownLastTime = showDiff && diffFlags; |
| 588 | #endif |
| 589 | @ <p> |
| 590 | if( !g.perm.Hyperlink ){ |
| 591 | if( isDeleted ){ |
| 592 | if( isFilePresent ){ |
| 593 | @ Deleted %h(zName) (still present as a local file). |
| @@ -850,12 +828,12 @@ | |
| 850 | db_finalize(&q); |
| 851 | style_finish_page(); |
| 852 | } |
| 853 | |
| 854 | /* |
| 855 | ** Options for the "extras" report. The bit-mask versions are used for "&ef=.." |
| 856 | ** to select which category(ies) to show. |
| 857 | */ |
| 858 | enum { |
| 859 | EXB_PLAIN, EXB_IGNORE, EXB_CLEAN, EXB_KEEP, |
| 860 | |
| 861 | EX_PLAIN = 1 << EXB_PLAIN, /* Matches none of the others */ |
| @@ -904,90 +882,35 @@ | |
| 904 | pIgnore = glob_create(zIgnoreFlag); /* Object versions of above */ |
| 905 | pKeep = glob_create(zKeepFlag); |
| 906 | pClean = glob_create(zCleanFlag); |
| 907 | nRoot = (int)strlen(g.zLocalRoot); /* Length of root component */ |
| 908 | Stmt q; |
| 909 | Blob repo; /* TODO:LD May not be needed */ |
| 910 | int maxExtrasToShow = LOCAL_DIFF_MAX_EXTRAS; |
| 911 | int extrasFlags = atoi(zExtra); /* Which entries to show */ |
| 912 | int nExtras; |
| 913 | int nMatch; |
| 914 | int nShown; |
| 915 | int nPlain; |
| 916 | int nIgnore; |
| 917 | int nClean; |
| 918 | int nKeep; |
| 919 | |
| 920 | /*TODO:LD? |
| 921 | ** It feels sensible to limit the number of "extra" entries shown by default |
| 922 | ** for cases where "ignore-glob" or "clean-glob" haven't been fully setup. |
| 923 | ** A minor irritation is that this can lead to "... plus 1 more file", on a |
| 924 | ** line that COULD have been used to display the omitted file. If we knew in |
| 925 | ** advance how many entries were going to match, we could temporarily "bump" |
| 926 | ** the limit by one show all entries would be shown. However, to know the |
| 927 | ** number of matches in advance we'd have to: |
| 928 | ** a) Pre-scan SFILE, testing and counting matches against each glob-list, |
| 929 | ** possibly bump the limit, then re-scan the table repeating the tests |
| 930 | ** against each glob-list to decide which to show. |
| 931 | ** b) SFILE could have an extra FLAGS field: during the pre-scan, this could |
| 932 | ** be updated to indicate which groups each file belong to. This would |
| 933 | ** save re-testing every file against each glob-list (the main pass could |
| 934 | ** select "WHERE flags & selector" to get only the matching entries), but |
| 935 | ** the updates (selecting by "pathname" each time) could be a bit much. |
| 936 | ** c) vfile_scan() -- where SFILE is populated -- COULD have an option to |
| 937 | ** do the testing at the time entries are added. This would be the "best" |
| 938 | ** way, but feels too much disruption to other code for what is only a |
| 939 | ** minor benefit. |
| 940 | ** For now, I'll stick with the minor annoyance of "plus 1 more file" :-) |
| 941 | ** |
| 942 | ** Being able to determine the counts up-front would also allow us to hide |
| 943 | ** the whole "extras report" if there were no unmanaged files. |
| 944 | ** |
| 945 | **TODO:LD? |
| 946 | ** Does it make sense (and/or is it practiable) to offer an "ADD" button |
| 947 | ** against files that are unmanaged? |
| 948 | ** |
| 949 | **TODO:LD? |
| 950 | ** Does it make sense (and/or ...) to offer ediing of the various blob-lists |
| 951 | ** from the Extras report? Showing the existing configuration screen would |
| 952 | ** probably not be a problem (permissions permitting), but what happens if |
| 953 | ** those settings have been overriden by .fossil-settings/ignore-glob? As we |
| 954 | ** have access to the local checkout, is it feasible to edit it in the browser |
| 955 | ** (perhaps piggy-backing /fileedit)? |
| 956 | */ |
| 957 | |
| 958 | locate_unmanaged_files(0, NULL, 0, NULL); /* Get all unmanaged */ |
| 959 | /*TODO:LD |
| 960 | ** The first two of these exclusions come from clean_cmd() in checkin.c. |
| 961 | ** Not sure exactly what they are intended to do (seem to have no effect on |
| 962 | ** my test repos). Last exclusion is an alternative to the WHERE clause above |
| 963 | ** so that COUNT(*) returns the correct value. TODO Even though, as noted |
| 964 | ** above, getting the count ahead of time is of little use (it was used to |
| 965 | ** bump the display limit if only one entry would be omitted), I'll probably |
| 966 | ** retain omitting the WHERE, and using DELETE FROM to exclude reserved |
| 967 | ** names, just in case (c) above were to be implemented. |
| 968 | */ |
| 969 | /*TODO:LD deletions from clean_cmd() */ |
| 970 | if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ |
| 971 | db_multi_exec("DELETE FROM sfile WHERE pathname=%B", &repo); |
| 972 | } |
| 973 | db_multi_exec("DELETE FROM sfile WHERE pathname IN" |
| 974 | " (SELECT pathname FROM vfile)"); |
| 975 | /*TODO:LD Delete reserved names, rather than WHERE them out. */ |
| 976 | db_multi_exec("DELETE FROM sfile WHERE pathname IN (%s)", |
| 977 | fossil_all_reserved_names(0)); |
| 978 | |
| 979 | /*TODO:LD |
| 980 | ** If we had a count of matching entries before scanning, this is where |
| 981 | ** we'd bump the maximum to show so as to avoid "plus 1 file". |
| 982 | ** ... |
| 983 | ** If there's only one more than the maximum, let it through... |
| 984 | ** a line used to say "plus 1 more" may as well display that item! |
| 985 | if( nExtras == maxExtrasToShow+1 ){ maxExtrasToShow++; } |
| 986 | ** ... |
| 987 | */ |
| 988 | |
| 989 | /* Handle the special case where zExtra was empty (and got converted to zero). |
| 990 | ** If so, show "plain" files (those not matching any glob-list) but with an |
| 991 | ** upper limit to the number shown (set above). If a value WAS given (i.e. |
| 992 | ** after following a link), display all of the selected entries. */ |
| 993 | if( extrasFlags==0 ){ |
| @@ -1029,12 +952,10 @@ | |
| 1029 | " ORDER BY 1", /*TODO:LD Order by pathname, as for differences? */ |
| 1030 | g.zLocalRoot |
| 1031 | ); |
| 1032 | /* |
| 1033 | ** Put the file-list in one paragraph with line-breaks between. |
| 1034 | **TODO:LD |
| 1035 | ** Might a table (with columns for name, ignore/clean/keep) work? |
| 1036 | */ |
| 1037 | @ <p> |
| 1038 | nExtras = nMatch = nShown = nPlain = nKeep = nClean = nIgnore = 0; |
| 1039 | while( db_step(&q)==SQLITE_ROW ){ |
| 1040 | const char *zName = db_column_text(&q, 0); |
| @@ -1196,38 +1117,29 @@ | |
| 1196 | ** marked kept)... this is what you'd most want to see if you've created a new |
| 1197 | ** source file and forgotten to "fossil add" it. A value of "0" will hide the |
| 1198 | ** extras report. Other (numeric) values control what the report shows (e.g. |
| 1199 | ** "1" would list ALL unmanaged files without limiting their number). |
| 1200 | ** |
| 1201 | ** If the "ef=" isn't present (as when first navigating to "/local") then a |
| 1202 | ** default setting is used. Set to "0" to initially hide the report. |
| 1203 | */ |
| 1204 | zExtra = P("ef"); |
| 1205 | if( zExtra==NULL ) { |
| 1206 | zExtra = LOCAL_DIFF_EXTRAS_MODE; |
| 1207 | } |
| 1208 | showExtras = strcmp(zExtra,"0")!=0; |
| 1209 | |
| 1210 | /* Local mode is selected by either "/local" or with a "name" of "ckout". |
| 1211 | ** First, check we have access to the checkout (and report to the user if we |
| 1212 | ** don't), then refresh the "vfile" table (recording which files in the |
| 1213 | ** checkout have changed etc.). We then change the "name" parameter to "tip" |
| 1214 | ** so that the "header" section displays info about the check-in that the |
| 1215 | ** checkout came from. |
| 1216 | **TODO:LD |
| 1217 | ** It would probably make sense to limit "/local" (and other links that come |
| 1218 | ** from it) to only be permitted when Fossil is running locally in "ui" mode. |
| 1219 | ** It's probably not critical when all you can do is view files in the |
| 1220 | ** checkout (they can already see the checked-in versions), but if a COMMIT |
| 1221 | ** option WERE ever to be implemented, you wouldn't essentially random people |
| 1222 | ** on the internet firing off commits! |
| 1223 | */ |
| 1224 | bLocalMode = (g.zPath[0]=='l') || (fossil_strcmp(zName,"ckout")==0); |
| 1225 | if( bLocalMode ){ |
| 1226 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1227 | if( vid==0 ){ |
| 1228 | /*TODO:LD Is this the right response? */ |
| 1229 | style_header("No Local Checkout"); |
| 1230 | @ No access to local checkout. |
| 1231 | style_finish_page(); |
| 1232 | return; |
| 1233 | } |
| @@ -1525,30 +1437,24 @@ | |
| 1525 | @ %z(button) |
| 1526 | @ Ignore Whitespace</a> |
| 1527 | } |
| 1528 | } |
| 1529 | if( bLocalMode ){ |
| 1530 | @ %z(chref("button","%R/localpatch")) Patch</a> |
| 1531 | }else |
| 1532 | if( zParent ){ |
| 1533 | @ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) |
| 1534 | @ Patch</a> |
| 1535 | } |
| 1536 | if( g.perm.Admin ){ |
| 1537 | @ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a> |
| 1538 | } |
| 1539 | if( bLocalMode ){ |
| 1540 | if( showExtras ){ |
| 1541 | @ %z(chref("button","%R/local?diff=%d%s&ef=0",diffType,zW))Hide Extras</a> |
| 1542 | }else{ |
| 1543 | @ %z(chref("button","%R/local?diff=%d%s&ef=",diffType,zW))Show Extras</a> |
| 1544 | } |
| 1545 | /*TODO:LD |
| 1546 | ** There would be a fair chunk of stuff to get right (not least appropriate |
| 1547 | ** restrictions), but it MIGHT be nice to have a COMMIT button here... |
| 1548 | */ |
| 1549 | } |
| 1550 | @</div> |
| 1551 | if( pRe ){ |
| 1552 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 1553 | @ are shown.</b></p> |
| 1554 | } |
| @@ -1555,14 +1461,10 @@ | |
| 1555 | if( bLocalMode ){ |
| 1556 | if( showExtras ){ |
| 1557 | append_extras_report(zExtra, diffType, zW); |
| 1558 | } |
| 1559 | /* Following SQL taken from diff_against_disk() in diffcmd.c */ |
| 1560 | /*TODO:LD |
| 1561 | ** That code wrapped the query/processing in a transaction (but, from |
| 1562 | ** memory, other similar uses did not). Is it neeeded? |
| 1563 | */ |
| 1564 | db_begin_transaction(); |
| 1565 | db_prepare(&q3, |
| 1566 | "SELECT pathname, deleted, chnged , rid==0, rid, islink" |
| 1567 | " FROM vfile" |
| 1568 | " WHERE vid=%d" |
| @@ -1570,24 +1472,17 @@ | |
| 1570 | " ORDER BY pathname /*scan*/", |
| 1571 | vid |
| 1572 | ); |
| 1573 | |
| 1574 | /* To prevent single-line diff-entries (those without "diff-blocks") from |
| 1575 | ** getting "lost", there's an optional "two-pass" mode for processing |
| 1576 | ** differences. If enabled, the first pass will only show one-line entries |
| 1577 | ** and the second pass will only show those with diff-blocks. This has the |
| 1578 | ** side-effect of altering the order entries are shown in (but within each |
| 1579 | ** group the original order is maintained). |
| 1580 | ** |
| 1581 | ** If disabled, (pass gets set to 3), only one pass is made on which all |
| 1582 | ** entries are shown in their "normal" order. |
| 1583 | **TODO:LD |
| 1584 | ** Add this to the original (non-local) loop? |
| 1585 | */ |
| 1586 | int pass = LOCAL_DIFF_USE_TWO_PASSES?1:3; |
| 1587 | int anyDifferences = 0; |
| 1588 | do{ |
| 1589 | while( db_step(&q3)==SQLITE_ROW ){ |
| 1590 | const char *zPathname = db_column_text(&q3,0); |
| 1591 | int isDeleted = db_column_int(&q3, 1); |
| 1592 | int isChnged = db_column_int(&q3,2); |
| 1593 | int isNew = db_column_int(&q3,3); |
| @@ -1598,11 +1493,11 @@ | |
| 1598 | isDeleted, isChnged, isNew, isLink, diffFlags,pRe,pass ); |
| 1599 | free(zUuid); |
| 1600 | anyDifferences = 1; |
| 1601 | } |
| 1602 | db_reset(&q3); |
| 1603 | }while( ++pass < 3 ); /* Either "1, 2, stop" or "3, stop". */ |
| 1604 | if( !anyDifferences ){ |
| 1605 | @ <p>No changes in the local checkout.</p> |
| 1606 | } |
| 1607 | db_end_transaction(1); /* ROLLBACK to fix uncommitted xaction complaint */ |
| 1608 | /*TODO:LD: Implement the optional two-pass code? */ |
| @@ -1650,11 +1545,10 @@ | |
| 1650 | login_check_credentials(); |
| 1651 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1652 | |
| 1653 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1654 | if( vid==0 ){ |
| 1655 | /*TODO:LD Is this the right response? */ |
| 1656 | style_header("No Local Checkout"); |
| 1657 | @ No access to local checkout. |
| 1658 | style_finish_page(); |
| 1659 | return; |
| 1660 | } |
| @@ -2516,11 +2410,11 @@ | |
| 2516 | diffFlags = construct_diff_flags(diffType) | DIFF_HTML; |
| 2517 | |
| 2518 | style_set_current_feature("fdiff"); |
| 2519 | style_header("Diff"); |
| 2520 | style_submenu_checkbox("w", "Ignore Whitespace", 0, 0); |
| 2521 | if( bLocalMode ){ |
| 2522 | if( diffType==2 ){ |
| 2523 | style_submenu_element("Unified Diff", "%R/localdiff?name=%T&diff=1", |
| 2524 | zLocalName); |
| 2525 | }else{ |
| 2526 | style_submenu_element("Side-by-side Diff", "%R/localdiff?name=%T&diff=2", |
| 2527 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -42,31 +42,10 @@ | |
| 42 | ** non-static so that it can be called from here. |
| 43 | **----------------------------------------------------------------------------- |
| 44 | ** Options to control the "local changes" changes. At present, these are |
| 45 | ** defines: if these changes are adopted, some may want to be made into |
| 46 | ** configuration options. |
| 47 | /*---------------------------------------------------------------------------*/ |
| 48 | |
| 49 | /* |
| 50 | ** Return a string (in memory obtained from malloc) holding a |
| 51 | ** comma-separated list of tags that apply to check-in with |
| @@ -548,24 +527,23 @@ | |
| 527 | ReCompiled *pRe, /* Only show diffs that match this regex, if not NULL */ |
| 528 | int pass /* 0x01 - Display single-line entries only */ |
| 529 | /* 0x02 - Display entries with "diff blocks" only */ |
| 530 | /* 0x03 - Display both */ |
| 531 | ){ |
| 532 | /* This remembers whether a side-by-side "diff-block" was shown the last |
| 533 | ** time through. If it was, we will add "<hr/>" to better separate the |
| 534 | ** blocks. |
| 535 | */ |
| 536 | static int diffShownLastTime = 0; |
| 537 | |
| 538 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 539 | int isFilePresent = !file_access(zFullName, F_OK); |
| 540 | |
| 541 | /* Determing up-front whether we would be showing a "diff-block" so we can |
| 542 | ** filter them according to which pass we are on: the first pass will show |
| 543 | ** only the "single-line" entries; the second will show only those with |
| 544 | ** diff-blocks. |
| 545 | */ |
| 546 | int showDiff = ( isDeleted && isFilePresent ) |
| 547 | || ( !isDeleted && !isNew && ( ( isChnged == 1 ) |
| 548 | || ( isChnged == 2 ) |
| 549 | || ( isChnged == 4 ) |
| @@ -574,20 +552,20 @@ | |
| 552 | /* We don't use 'diffFlags' in these tests so that whether "Hide diffs" is |
| 553 | ** in effect or not, the order won't change. |
| 554 | */ |
| 555 | if( showDiff && (pass == 1) ){ return; } /* Don't do diff on pass 1 of 2 */ |
| 556 | if( !showDiff && (pass == 2) ){ return; } /* Don't do line on pass 2 of 2 */ |
| 557 | |
| 558 | /* If a SBS diff-block was shown by the previous entry, add a divider */ |
| 559 | if( diffShownLastTime && (diffFlags & DIFF_SIDEBYSIDE) ){ |
| 560 | @ <hr/> |
| 561 | } |
| 562 | /* Record whether we will be showing a diff-block this time. We DO factor in |
| 563 | ** 'diffFlags' here so that in "Hide diffs" mode, we don't get extra lines. |
| 564 | */ |
| 565 | diffShownLastTime = showDiff && diffFlags; |
| 566 | |
| 567 | @ <p> |
| 568 | if( !g.perm.Hyperlink ){ |
| 569 | if( isDeleted ){ |
| 570 | if( isFilePresent ){ |
| 571 | @ Deleted %h(zName) (still present as a local file). |
| @@ -850,12 +828,12 @@ | |
| 828 | db_finalize(&q); |
| 829 | style_finish_page(); |
| 830 | } |
| 831 | |
| 832 | /* |
| 833 | ** Options for the "extras" report in "local-diff" mode. The bit-mask versions |
| 834 | ** are used for "&ef=.." to select which category(ies) to show. |
| 835 | */ |
| 836 | enum { |
| 837 | EXB_PLAIN, EXB_IGNORE, EXB_CLEAN, EXB_KEEP, |
| 838 | |
| 839 | EX_PLAIN = 1 << EXB_PLAIN, /* Matches none of the others */ |
| @@ -904,90 +882,35 @@ | |
| 882 | pIgnore = glob_create(zIgnoreFlag); /* Object versions of above */ |
| 883 | pKeep = glob_create(zKeepFlag); |
| 884 | pClean = glob_create(zCleanFlag); |
| 885 | nRoot = (int)strlen(g.zLocalRoot); /* Length of root component */ |
| 886 | Stmt q; |
| 887 | Blob repo; |
| 888 | int maxExtrasToShow = 5; /* Before showing "+ xx others" */ |
| 889 | int extrasFlags = atoi(zExtra); /* Which entries to show */ |
| 890 | int nExtras; |
| 891 | int nMatch; |
| 892 | int nShown; |
| 893 | int nPlain; |
| 894 | int nIgnore; |
| 895 | int nClean; |
| 896 | int nKeep; |
| 897 | |
| 898 | locate_unmanaged_files(0, NULL, 0, NULL); /* Get all unmanaged files */ |
| 899 | /*TODO:LD |
| 900 | ** The first two of these exclusions come from clean_cmd() in checkin.c. |
| 901 | ** Not sure exactly what they are intended to do (seem to have no effect on |
| 902 | ** my test repos). |
| 903 | */ |
| 904 | if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ |
| 905 | db_multi_exec("DELETE FROM sfile WHERE pathname=%B", &repo); |
| 906 | } |
| 907 | db_multi_exec("DELETE FROM sfile WHERE pathname IN" |
| 908 | " (SELECT pathname FROM vfile)"); |
| 909 | db_multi_exec("DELETE FROM sfile WHERE pathname IN (%s)", |
| 910 | fossil_all_reserved_names(0)); |
| 911 | |
| 912 | /* Handle the special case where zExtra was empty (and got converted to zero). |
| 913 | ** If so, show "plain" files (those not matching any glob-list) but with an |
| 914 | ** upper limit to the number shown (set above). If a value WAS given (i.e. |
| 915 | ** after following a link), display all of the selected entries. */ |
| 916 | if( extrasFlags==0 ){ |
| @@ -1029,12 +952,10 @@ | |
| 952 | " ORDER BY 1", /*TODO:LD Order by pathname, as for differences? */ |
| 953 | g.zLocalRoot |
| 954 | ); |
| 955 | /* |
| 956 | ** Put the file-list in one paragraph with line-breaks between. |
| 957 | */ |
| 958 | @ <p> |
| 959 | nExtras = nMatch = nShown = nPlain = nKeep = nClean = nIgnore = 0; |
| 960 | while( db_step(&q)==SQLITE_ROW ){ |
| 961 | const char *zName = db_column_text(&q, 0); |
| @@ -1196,38 +1117,29 @@ | |
| 1117 | ** marked kept)... this is what you'd most want to see if you've created a new |
| 1118 | ** source file and forgotten to "fossil add" it. A value of "0" will hide the |
| 1119 | ** extras report. Other (numeric) values control what the report shows (e.g. |
| 1120 | ** "1" would list ALL unmanaged files without limiting their number). |
| 1121 | ** |
| 1122 | ** If the "ef=" is absent then default to "" (show (some) unmanaged files). |
| 1123 | */ |
| 1124 | zExtra = P("ef"); |
| 1125 | if( zExtra==NULL ) { |
| 1126 | zExtra = ""; |
| 1127 | } |
| 1128 | showExtras = strcmp(zExtra,"0")!=0; |
| 1129 | |
| 1130 | /* Local mode is selected by either "/local" or with a "name" of "ckout". |
| 1131 | ** First, check we have access to the checkout (and report to the user if we |
| 1132 | ** don't), then refresh the "vfile" table (recording which files in the |
| 1133 | ** checkout have changed etc.). We then change the "name" parameter to "tip" |
| 1134 | ** so that the "header" section displays info about the check-in that the |
| 1135 | ** checkout came from. |
| 1136 | */ |
| 1137 | bLocalMode = (g.zPath[0]=='l') || (fossil_strcmp(zName,"ckout")==0); |
| 1138 | if( bLocalMode ){ |
| 1139 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1140 | if( vid==0 ){ |
| 1141 | style_header("No Local Checkout"); |
| 1142 | @ No access to local checkout. |
| 1143 | style_finish_page(); |
| 1144 | return; |
| 1145 | } |
| @@ -1525,30 +1437,24 @@ | |
| 1437 | @ %z(button) |
| 1438 | @ Ignore Whitespace</a> |
| 1439 | } |
| 1440 | } |
| 1441 | if( bLocalMode ){ |
| 1442 | @ %z(chref("button","%R/localpatch")) Patch</a> |
| 1443 | if( showExtras ){ |
| 1444 | @ %z(chref("button","%R/local?diff=%d%s&ef=0",diffType,zW))Hide Extras</a> |
| 1445 | }else{ |
| 1446 | @ %z(chref("button","%R/local?diff=%d%s&ef=",diffType,zW))Show Extras</a> |
| 1447 | } |
| 1448 | }else //TODO:LD Rejoin else-if? |
| 1449 | if( zParent ){ |
| 1450 | @ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) |
| 1451 | @ Patch</a> |
| 1452 | } |
| 1453 | if( g.perm.Admin ){ |
| 1454 | @ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a> |
| 1455 | } |
| 1456 | @</div> |
| 1457 | if( pRe ){ |
| 1458 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 1459 | @ are shown.</b></p> |
| 1460 | } |
| @@ -1555,14 +1461,10 @@ | |
| 1461 | if( bLocalMode ){ |
| 1462 | if( showExtras ){ |
| 1463 | append_extras_report(zExtra, diffType, zW); |
| 1464 | } |
| 1465 | /* Following SQL taken from diff_against_disk() in diffcmd.c */ |
| 1466 | db_begin_transaction(); |
| 1467 | db_prepare(&q3, |
| 1468 | "SELECT pathname, deleted, chnged , rid==0, rid, islink" |
| 1469 | " FROM vfile" |
| 1470 | " WHERE vid=%d" |
| @@ -1570,24 +1472,17 @@ | |
| 1472 | " ORDER BY pathname /*scan*/", |
| 1473 | vid |
| 1474 | ); |
| 1475 | |
| 1476 | /* To prevent single-line diff-entries (those without "diff-blocks") from |
| 1477 | ** getting "lost", the first pass will only show one-line entries and the |
| 1478 | ** second pass will only show those with diff-blocks. |
| 1479 | ** TODO:LD Add this to the original (non-local) loop? |
| 1480 | */ |
| 1481 | int pass; |
| 1482 | int anyDifferences = 0; |
| 1483 | for(pass=1; pass<=2; pass++) { |
| 1484 | while( db_step(&q3)==SQLITE_ROW ){ |
| 1485 | const char *zPathname = db_column_text(&q3,0); |
| 1486 | int isDeleted = db_column_int(&q3, 1); |
| 1487 | int isChnged = db_column_int(&q3,2); |
| 1488 | int isNew = db_column_int(&q3,3); |
| @@ -1598,11 +1493,11 @@ | |
| 1493 | isDeleted, isChnged, isNew, isLink, diffFlags,pRe,pass ); |
| 1494 | free(zUuid); |
| 1495 | anyDifferences = 1; |
| 1496 | } |
| 1497 | db_reset(&q3); |
| 1498 | } |
| 1499 | if( !anyDifferences ){ |
| 1500 | @ <p>No changes in the local checkout.</p> |
| 1501 | } |
| 1502 | db_end_transaction(1); /* ROLLBACK to fix uncommitted xaction complaint */ |
| 1503 | /*TODO:LD: Implement the optional two-pass code? */ |
| @@ -1650,11 +1545,10 @@ | |
| 1545 | login_check_credentials(); |
| 1546 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1547 | |
| 1548 | vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
| 1549 | if( vid==0 ){ |
| 1550 | style_header("No Local Checkout"); |
| 1551 | @ No access to local checkout. |
| 1552 | style_finish_page(); |
| 1553 | return; |
| 1554 | } |
| @@ -2516,11 +2410,11 @@ | |
| 2410 | diffFlags = construct_diff_flags(diffType) | DIFF_HTML; |
| 2411 | |
| 2412 | style_set_current_feature("fdiff"); |
| 2413 | style_header("Diff"); |
| 2414 | style_submenu_checkbox("w", "Ignore Whitespace", 0, 0); |
| 2415 | if( bLocalMode ){//TODO:LD Merge these? |
| 2416 | if( diffType==2 ){ |
| 2417 | style_submenu_element("Unified Diff", "%R/localdiff?name=%T&diff=1", |
| 2418 | zLocalName); |
| 2419 | }else{ |
| 2420 | style_submenu_element("Side-by-side Diff", "%R/localdiff?name=%T&diff=2", |
| 2421 |