The Perl Advent Calendar needs more articles for 2022. Submit your idea today!


SVK::XD - svk depot and checkout handling.


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



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


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.


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


Options to new:


A hash reference for depot name and repository path mapping.


A Data::Hierarchy object for checkout paths mapping.


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.


Filename for serializing SVK::XD object.


Directory name of giantlock and statefile.


Serialization and locking


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


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 the given checkout path, store the state with the lock info to prevent other instances from modifying locked paths.


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


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


Release the giant lock.

Depot and path translation


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.


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.


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.



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


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


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.



The editor receiving delta calls.


Don't generate text deltas in apply_textdelta calls.


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



Generate delete_entry calls for sub-entries within deleted entry.


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


generate cb_unknown calls for sub-entries within absent entry.


Don't generate absent_* calls.


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


Called for ignored items if defined.


Called for unchanged files if defined.


Returns the Data::Hierarchy entry and the schedule of the entry.


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


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