Skip to contents

Compare the deparsed source of package functions across two already installed versions of the same package. With name set, compares exactly one function. With name = NULL (the default), compares every function in scope at once, using a single extraction subprocess per version rather than one per function.

Usage

diff_versions(
  package,
  name = NULL,
  v1,
  v2,
  lib = .libPaths(),
  timeout = 30,
  scope = c("exported", "all"),
  store = NULL,
  store_label = NULL,
  store_tags = character()
)

Arguments

package

A single installed package name.

name

A single function name, exported or internal, or NULL (the default) to diff every function in scope instead.

v1, v2

Single version strings to compare.

lib

Character vector of library paths to search. Defaults to .libPaths().

timeout

Maximum number of seconds allowed for each extraction subprocess. Must be finite and positive.

scope

Only used when name is NULL. "exported" (the default) diffs only exported functions; "all" also includes internal (non-exported) functions.

store

An optional insider_store handle (see insider_store()). When supplied, the returned insider_diff or insider_diff_package object is also recorded in the store via store_save(); the resulting id is attached as its "store_id" attribute. The default, NULL, records nothing, consistent with the store's explicit, opt-in design.

store_label

An optional label passed through to store_save() when store is supplied.

store_tags

Optional character tags passed through to store_save() when store is supplied.

Value

Invisibly: when name is given, an insider_diff object containing the resolved library paths for each version, whether the sources are byte-identical, added and removed line counts, argument-name changes, the ordered line diff, and the original deparsed source for each version. When name is NULL, an insider_diff_package object containing a per-function summary data frame (name, status added/removed/changed/identical, exported flags, line-diff counts, whether formals changed) plus diffs, a named list of the same per-function insider_diff objects the single-function form returns, so x$diffs[["some_fn"]] can be inspected or printed directly.

Examples

if (FALSE) { # \dontrun{
diff_versions("fs", "path_has_parent", "1.6.5", "2.1.0")
diff_versions("fs", v1 = "1.6.5", v2 = "2.1.0")
} # }