Repository navigation
Search & replace: dry run, page-only scope, skip symbolic links - #1639
Open
DominikNetcare wants to merge 27 commits into
Open
DominikNetcare wants to merge 27 commits into
DominikNetcare wants to merge 27 commits into
Conversation
Text, method and properties search no longer follow symbolic links unless "Include symbolic links" is checked (includeSymLinks input). Following links finds the same pages again under other paths and can make searches on large wikis slow. A search that starts at a symbolic link still covers the linked pages. The search results show whether a page is reached via a symbolic link, mark every symbolic link in the page path and report how long the search took.
Search and replace uses the search code, which now skips symbolic links by default. Replace has always changed the pages behind symbolic links too, and its form offers no option to include them, so it keeps doing so.
Finding the children of a page read the page data (content and properties) to look up symbolic links, so even a title search read every page file. Pages can now list their children without symbolic links (WikiPage.getChildrenWithoutSymbolicLinks), which file based pages do from the directory listing alone. Traversals use it when the pruning strategy skips symbolic links. Also stop looking up a symbolic link for every non-page file in a page directory: symbolic links are collected from the properties anyway. On a wiki with 50,000 pages, title search went from ~2.5s to ~1.3s.
Text, method and properties search accept a searchThreads input (1-4, "Threads" on the search form). With more than one thread, the children and page data of the pages to visit are loaded ahead on worker threads, while pages are still matched and reported one at a time, on the request thread and in the same order. 1, the default, searches sequentially as before. On a wiki with 50,000 pages, 4 threads made content and properties search about 2.3 times and title search about 1.9 times faster. # Conflicts: # src/fitnesse/responders/search/ResultResponder.java
The REST API still searches with one thread unless searchThreads is given.
Replace changes pages while traversing them, so pages must not be loaded ahead.
With "Use wildcards" checked (useWildcards input), an asterisk in the search text matches any characters within a line, in title and content search; * alone finds all pages in the search scope. Without it the search text is still matched literally.
Replacing through a symbolic link changes the linked page itself, which is often outside the selected page and may be reached more than once, so the replacement could even be applied twice. Replace now skips symbolic links unless "Include symbolic links" is checked on the replace form (includeSymLinks input), like search.
The "Dry run" button on the replace forms (dryRun input) lists the pages a replacement would change, each with its changed lines before and after the replacement side by side, and saves nothing.
Replace already took the searchScope input, but its forms always replaced in the current page and its children.
It is a <button>, which the themes show as secondary button, unlike the primary submit inputs. Being the first button, it is also what pressing enter in the form does.
Before and after lines are compared word by word; the words that are replaced and the words replacing them are highlighted.
The replace forms choose between the current page only (searchScope=pageOnly) and the current page with its children, instead of offering the parent pages like the search form.
The changed lines are shown directly in two result columns, which are not sortable, instead of a table in one column.
The results of search and replace offered to save the request as a link. For replace, which the form posts, that link was empty, and following it would replace again. Now the link is only offered for searches with a query string.
This reverts commit b9d8e7e: one Changes column with a before/after table per page reads better than two separate result columns.
…formance # Conflicts: # FitNesseRoot/FitNesse/ReleaseNotes/content.txt
# Conflicts: # FitNesseRoot/FitNesse/ReleaseNotes/content.txt
# Conflicts: # FitNesseRoot/FitNesse/ReleaseNotes/content.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes search & replace safer:
dryRuninput) lists the pages a replacement would change, with the changed lines before and after side by side and the replaced words highlighted. Nothing is saved.searchScope=pageOnly) and this page and children (default, as before).includeSymLinks). Replacing through a link changes the linked page itself, which is often outside the selected page and may be reached more than once, so a replacement could even be applied twice.Depends on #1638, please merge after it (stacked on #1638, #1637 and #1636, shows their commits too until they are merged); the changes of this PR alone: netcare-io/fitnesse@feature/search-wildcards...feature/replace-dry-run
After #1638 is merged, I'll update this branch right away (merging master into it), so it merges cleanly.
Changes
ContentReplacer),ChangedLinesdiffs old and new content line by line and the changed lines word by word;<button>, which the themes show as secondary button, and being the first button it is also what pressing enter does.searchScope=pageOnlysearches/replaces the selected page only; it also works for search via REST. The parent pages androotstill work for replace via REST, but are not offered on the form.includeSymLinks,dryRunandpageOnlyadded to the RestfulServices page, release notes added.Behaviour change
Replace no longer follows symbolic links unless
includeSymLinksis given.No performance impact (replace always runs with one thread).
Tests
Unit tests for
ChangedLines(changed, added and removed lines, word marks, escaping), dry run for text and method replace (shows changes, saves nothing), the scope options, symbolic links on and off, and the save-as-link condition. Unit tests andFitNesse.SuiteAcceptanceTestspass.