SVK::XD(3p)

NAME
SVK::XD - svk depot and checkout handling.

SYNOPSIS
  use SVK::XD;
  $xd = SVK::XD->new (depotmap => { '' => '/path/to/repos'});

TERMINOLOGY

depot
    A repository referred by a name. The default depot is '' (the empty string).

depotpath
    A path referred by a depot name and the path inside the depot. For example, //foo/bar means /foo/bar in the default depot '', and /test/foo/bar means /foo/bar in the depot test.

copath
    Checkout path. A path in the file system that has a checked out version of a certain depotpath.

CONSTRUCTOR
Options to "new":

depotmap
    A hash reference for depot name and repository path mapping.

checkout
    A Data::Hierarchy object for checkout paths mapping.

giantlock
    A filename for global locking. This file protects all read and write accesses to the "statefile".

    When SVK begins to execute any command, it attempt to get a write lock on this "giant lock" file. Once it gets the lock, it writes its PID to the file, reads in its "statefile", and begins to execute the command. Executing the command consists of a "lock" phase and a "run" phase. During the lock phase, a command can do one of three things: request to keep the giant lock for the entire execution (for commands which modify large parts of the "statefile"), request to lock individual checkout paths, or not request a lock.

    In the first case, the command sets the "hold_giant" field on the SVK::Command object (this should probably change to a real API), and the command does not release the giant lock until it is finished; it can rewrite the "statefile" at the end of its execution without waiting on the lock, since it already holds it.

    In the second case, the command calls "lock" on the SVK::XD object one or more times; this places a "lock" entry inside the Data::Hierarchy object in the statefile next to each locked path, unless they are already locked by another process. Between its lock phase and its run phase, the "statefile" is written to disk (with the new "lock" entries) and the giant lock is dropped. After the run phase, SVK acquires the giant lock again, reads in the "statefile", copies all entries from the paths that it has locked into the version it just read, clears the lock entries from the hierarchy, writes the "statefile" to disk, and drops the giant lock. Any changes to the hierarchy other than in the locked paths will be ignored.

    In the third case, SVK just drops the giant lock after the lock phase and never tries to read or write the "statefile" again.

statefile
    Filename for serializing "SVK::XD" object.

svkpath
    Directory name of "giantlock" and "statefile".

METHODS

  Serialization and locking

load
    Load the serialized "SVK::XD" data from statefile. Initialize $self if there's nothing to load. The giant lock is acquired when calling "load".

store
store
    Serialize $self to the statefile. If giant lock is still ours, overwrite the file directly. Otherwise load the file again and merge the paths we locked into the new state file. After "store" is called, giant is unlocked.

lock
    Lock the given checkout path, store the state with the lock info to prevent other instances from modifying locked paths.

unlock
    Unlock all the checkout paths that were locked by this instance.

giant_lock
    Lock the statefile globally. All other instances need to wait for the lock before they can do anything.

giant_unlock
    Release the giant lock.

  Depot and path translation

find_repos
    Given depotpath and an option about if the repository should be opened. Returns an array of repository path, the path inside repository, and the "SVN::Repos" object if caller wants the repository to be opened.

find_repos_from_co
    Given the checkout path and an option about if the repository should be opened. Returns an array of repository path, the path inside repository, the absolute checkout path, the checkout info, and the "SVN::Repos" object if caller wants the repository to be opened.

find_repos_from_co_maybe
    Like "find_repos_from_co", but falls back to see if the given path is a depotpath. In that case, the checkout paths returned will be undef.

find_depotname

  create_path_object
Creates and returns a new path object. It can be either SVK::Path::Checkout, SVK::Path::View or SVK::Path.

Takes a hash with arguments.

If "copath_anchor" argument is defined then SVK::Path::Checkout is created and other arguments are used to build its "source" in SVK::Path::Checkout using this method. If "revision" argument is not defined then the one checkout path is based on is used.

If "view" argument is defined then SVK::Path::View is created and other arguments are used to build its "source" in SVK::Path::Checkout using this method.

Otherwise SVK::Path is created.

Depot can be passed as SVK::Depot object in "depot" argument or using "depotname", "repospath" and "repos" arguments. Object takes precendence.

  Checkout handling

auto_prop
    Return a hash of properties that should attach to the file automatically when added.

depot_delta
    Generate "SVN::Delta::Editor" calls to represent the changes between "(oldroot, oldpath)" and "(newroot, newpath)". oldpath is a array ref for anchor and target, newpath is just a string.

    Options:

    editor
        The editor receiving delta calls.

    no_textdelta
        Don't generate text deltas in "apply_textdelta" calls.

    no_recurse
    notice_ancestry
checkout_delta
    Generate "SVN::Delta::Editor" calls to represent the local changes made to the checked out revision.

    Options:

    delete_verbose
        Generate delete_entry calls for sub-entries within deleted entry.

    absent_verbose
        Generate absent_* calls for sub-entries within absent entry.

    unknown_verbose
        generate cb_unknown calls for sub-entries within absent entry.

    absent_ignore
        Don't generate absent_* calls.

    expand_copy
        Mimic the behavior like SVN::Repos::dir_delta, lose copy information and treat all copied descendents as added too.

    cb_ignored
        Called for ignored items if defined.

    cb_unchanged
        Called for unchanged files if defined.

get_entry($copath)
    Returns the Data::Hierarchy entry and the schedule of the entry.

get_fh
    Returns a file handle with keyword translation and line-ending layers attached.

get_props
    Returns the properties associated with a node. Properties schedule for commit are merged if $copath is given.