This vignette provides detailed documentation and usage examples for
two key functions in the review package:
svnLog()
and svnExport()
. These functions
simplify interacting with SVN-managed files by retrieving revision
histories and restoring previous versions.
svnLog()
: Retrieves the edit history
of a filesvnExport()
: Restores a file to a
specified revisionsvnLog()
The svnLog()
function provides the history of all edits
made to a file, including the author, revision, and date/time of each
commit. This function helps track modifications and identify specific
revisions.
Let’s examine the history of script/data-assembly.R
.
svnLog("script/data-assembly.R")
Output:
rev | author | datetime | msg |
---|---|---|---|
3 | Bob | 2025-01-15 10:00:00 | Added new feature |
2 | Alice Johnson | 2025-01-10 09:00:00 | Modified data load |
1 | John Smith | 2025-01-05 08:30:00 | Initial commit |
The data frame above shows the commit history, sorted such that the most recent commit appears in the first row. It includes columns for the author, revision number, and commit timestamp. This information is essential for efficiently restoring or reviewing previous versions.
svnExport()
The svnExport()
function restores a file to a specified
revision, saving it with a new name to avoid overwriting the current
version. This is particularly useful when paired with
svnLog()
to identify the desired revision.
Using the revision numbers from svnLog()
, we can restore
the first revision of the file:
svnExport(.file = "script/data-assembly.R", .revision = 2)
This creates a new file, data-assembly-2.R
, in the
repository directory. You can confirm its existence:
file.exists("script/data-assembly-2.R")
TRUE
By combining svnLog()
to identify revision numbers and
svnExport()
to restore specific versions, you can
efficiently manage and review file changes in your SVN repository. The
restored files are saved with a new name using the format
{original_file_name}-{revision_number}
to preserve your
working version.