[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Docs of native Ruby bindings

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2002-01-31 12:00:37 CET

Here are docs of Ruby bindings I wrote a couple of months
ago. I fixed some obvious errors but it's inevitably out of
date and has number of errors. For example, repos binding
is not documented at all. Sean, feel free to discard
anything too old and rip off only usable parts.

=begin
== Svn::Client

This class implements basic functionality necessary to Subversion
clients.

=== Class Methods

--- new() {|prompt, hide|}

Create and return a new Svn::Client object. If the block is given, it
is called when authentication is required for that method. You can
omit it if you are sure you won't need credentials to do access
repository (e.g. accessing local repository).

The block will be called with two arguments, ((|prompt|)) and
((|hide|)). ((|prompt|)) is a string which should be printed as
prompt. ((|hide|)) is a boolean which indicates whether you should
echo back user input on the screen. The block should return a string
object.

--- add(path, recursive)

Schedule a working copy ((|path|)) for addition to the repository.
((|path|))'s parent must be under revision control already, but ((|path|)) is
not. If ((|recursive|)) is TRUE, then assuming ((|path|)) is a directory, all
of its contents will be scheduled for addition as well.

Important: this is a ((*scheduling*)) operation. No changes will
happen to the repository until a commit occurs. This scheduling
can be removed with Svn::Client.revert.

--- delete(path, force)

Schedule a working copy ((|path|)) for removal from the repository.
((|path|))'s parent must be under revision control. If ((|force|)) is TRUE,
then ((|path|)) itself will be recursively removed as well; otherwise
((|path|)) simply stops being tracked by the working copy.

Important: this is a ((*scheduling*)) operation. No changes will
happen to the repository until a commit occurs. This scheduling
can be removed with Svn::Client.revert.

--- status(path, descend, getAll, update)

Given ((|path|)) to a working copy directory (or single file), allocate
and return a hash maps paths to Svn::WcStatus objects.

This is a purely local operation; only information found in the
administrative `entries' files is used to initially build the
structures.

- If ((|descend|)) is TRUE, recurse fully, else do only immediate
children. This (inversely) corresponds to the "-n"
(--nonrecursive) flag in the commandline client app.

- If ((|get_all|)) is TRUE, then all entries are retrieved; otherwise
only "interesting" entries (local mods and/or out-of-date)
will be fetched. This directly corresponds to the "-v"
(--verbose) flag in the commandline client app.

- If ((|update|)) is set, then the repository will be contacted, and
the collection of structures will be augmented with
information about out-of-dateness. This directly corresponds
to the "-u" (--show-updates) flag in the commandline client app.

--- cleanup(dir)

Recursively cleanup a working copy directory ((|dir|)), finishing any
incomplete operations, removing lockfiles, etc.

--- revert(path, recursive)

Restore the pristine version of a working copy ((|path|)), effectively
undoing any local mods. If PATH is a directory, and ((|recursive|)) is
TRUE, this will be a recursive operation.

--- copy(srcPath, dstPath)

Not implemented

=== Instance Methods

--- checkout(url, path, revOrTime, [beforeEditor, afterEditor, xmlFile])

Perform a checkout from ((|url|)), providing pre- and post-checkout hook
editors and batons (((|beforeEditor /
afterEditor|))). These editors are purely optional
and exist only for extensibility. (They are not currently available under
Ruby binding).

((|path|)) will be the root directory of your checked out working copy.

If ((|xmlFile|)) is present, then the checkout will come from the
repository and subdir specified by ((|url|)). An invalid
((|revOrTime|)) revision will cause the "latest" tree to be fetched,
while a valid ((|revOrTime|)) revision will fetch a specific tree.
Alternatively, a Time object can be used as ((|revOrTime|)) to
implicitly select a revision.

If ((|xmlFile|)) is given, it is an xml file to check out from; in
this case, the working copy will record the URL as artificial
ancestry information. An invalid ((|revOrTime|)) revision implies that the
revision ((*must*)) be present in the <delta-pkg> tag, while a valid
REVISION will be simply be stored in the wc. (Note: a <delta-pkg>
revision will ((*always*)) override the one passed in.)

--- update(path, revOrTime, recurse, [beforeEditor, afterEditor, xmlFile])

Perform an update of ((|path|)) (part of a working copy), providing
pre- and post-checkout hook editors and batons (((|beforeEditor|)),
/((|afterEditor|))). These editors are purely optional and exist only
for extensibility.

If ((|xmlSrc|)) is not given, then the update will come from the
repository that ((|path|)) was originally checked-out from. An
invalid ((|revOrTime|)) revision will cause the ((|path|)) to be
updated to the "latest" revision, while a valid ((|revOrTime|))
revision will update to a specific tree. Alternatively, a time object
can be used as ((|revOrTime|)) to implicitly select a revision.

If ((|xmlSrc|)) is given, it is an xml file to update from. An
invalid ((|revOrTime|)) revision implies that the revision ((*must*))
be present in the <delta-pkg> tag, while a valid ((|revOrTime|))
revision will be simply be stored in the wc. (Note: a <delta-pkg>
revision will ((*always*)) override the one passed in.)

--- import(path, Url, newEntry, [logMsg, beforeEditor, afterEditor, [xmlFile, revision]])

Import a tree, using optional pre- and post-commit hook editors
(((|beforeEditor|)) / ((|afterEditor|))). These editors are purely
optional and exist only for extensibility.

Store ((|logMsg|)) as the log of the commit.

((|path|)) is the path to local tree being imported. ((|path|)) can
be a file or directory.

((|url|)) is the repository directory where the imported data is placed.

((|newEntry|)) is the new entry created in the repository directory
identified by ((|url|)).

If ((|path|)) is a file, that file is imported as ((|newEntry|)). If
((|path|)) is a directory, the contents of that directory are
imported, under a new directory the ((|newEntry|)) in the repository. Note
and the directory itself is not imported; that is, the basename of
((|path|)) is not part of the import.

If ((|path|)) is a directory and ((|newEntry|)) is nil, then the
contents of ((|path|)) are imported directly into the repository
directory identified by ((|url|)). ((|newEntry|)) may not be the
empty string.

If ((|newEntry|)) already exists in the youngest revision, raises an
exception.

If ((|xmlDst|)) is given, it is a file in which to store the xml
result of the commit, and ((|revision|)) is used as the revision.

--- commit(target, [logMsg, beforeEditor, afterEditor, [xmlFile, revision]])

Perform an commit, providing pre- and post-commit hook editors and
batons (((|beforeEditor|)) / ((|afterEditor|))). These editors are
purely optional and exist only for extensibility.

Store ((|logMsg|)) as the log of the commit.

((|targets|)) is an array of String paths to commit. They need not be
canonicalized nor condensed; this function will take care of that.

If ((|xmlFile|)) is nil, then the commit will write to a repository,
and the ((|revision|)) argument is ignored.

If ((|xmlFile|)) is nil, it is a file path to commit to. In this
case, if ((|revision|)) is valid, the working copy's revision numbers
will be updated appropriately. If ((|revision|)) is invalid, the
working copy remains unchanged.

=end

= begin
== Svn::Wc

=== Constans

--- ADM_DIR_NAME

=== Class Methods

--- wc?(path)

--- hasBinaryProp?(path)

--- textModified?(path)

--- propsModified?(path)

--- proplist(path)

--- propGet(name, path)

--- propSet(name, value, path)

--- wcProp?(name)

== Svn::WcEntry

=== Constants

--- SCHEDULE_NORMAL
--- SCHEDULE_ADD
--- SCHEDULE_DELETE
--- SCHEDULE_REPLACE
--- SCHEDULE_NORMAL
--- SCHEDULE_ADDED
--- SCHEDULE_DELETED
--- ATTR_NAME
--- ATTR_REVISION
--- ATTR_KIND
--- ATTR_TEXT_TIME
--- ATTR_PROP_TIME
--- ATTR_CHECKSUM
--- ATTR_SCHEDULE
--- ATTR_EXISTENCE
--- ATTR_CHECKSUM
--- ATTR_ANCESTOR
--- ATTR_REJFILE
--- ATTR_PREJFILE
--- VALUE_ADD
--- VALUE_DELETE
--- VALUE_REPLACE
--- VALUE_ADDED
--- VALUE_DELETED
--- THIS_DIR

=== Class Methods

new(path)
entries(path)

=== Instance Methods

--- revision
--- ancestor
--- kind
--- schedule
--- existence
--- conflict?
--- textTime
--- propTime
--- attributes
--- conflicted?

== Svn::WcStatus

=== Constants

--- NONE
--- NORMAL
--- ADDED
--- ABSENT
--- DELETED
--- REPLACED
--- MODIFIED
--- MERGED
--- CONFLICTED

=== Class Methods

--- new(path)
--- statuses(path, descend, getAll)

=== Instance Methods

--- entry
--- reposRev
--- textStatus
--- propStatus
--- locked?
--- reposTextStatus
--- reposPropStatus

=end

=begin

== Svn::RaLib

=== Class methods

--- create(path)

--- print()

== Svn::RaReporter

=== Instance Methods

--- setPath(path, revision)

--- deletePath(path)

--- finishReport()

--- abortReport()

== Svn::Ra

--- name()
--- description()
--- open(URL, callback)
--- close()
--- getLatestRevnum()
--- getDatedRevision(time)
--- getCommitEditor([logMessage, getFunc, setFunc, closeFunc])

getFunc and setFunc are currently ignored.

--- doCheckout
--- doUpdate(revision, deltaEditor, recurse, [target])

=end

=begin
== Svn::Fs

This class contains methods to create, delete and recover Subversion
filesystem. It also has methods to return objects to do further
operation on filesystem like Svn::FsRevisionRoot and Svn::FsTxnRoot.

=== Class Methods

--- open(path)
--- new(path)

Return a new instance of Svn::Fs which refers to Subversion
filesystem at ((|path|)). There will be similar method in Svn::Repos
but it's not implemented yet.

--- create(path)

Create a new, empty Subversion filesystem at ((|path|)) and reterns a
new instance of Svn::Fs which refers to ((|path|)).

--- delete(path)

Delete Subversion filesystem at ((|path|)). Be careful not to use it
on non-Subversion managed directory. At the time of writing, it will
just remove recursively starting at ((|path|)). It doesn't check
whether it's actually Subversion filesystem or not.

--- recover(path)

Perform any necessary non-catastrophic recover on a Berkely DB-based
Subversion filesystem at ((|path|)).

After an unexpected server exit, due to a server crash or a system
crash, a Subversion filesystem based on Berkeley DB needs to run
recovery procedures to bring the database back into a consistent
state and release any locks that were held by the deceased process.
The recovery procedures require exclusive access to the database
--- while they execute, no other process or thread may access the
database.

In a server with multiple worker processes, like Apache, if a
worker process accessing the filesystem dies, you must stop the
other worker processes, and run recovery. Then, the other worker
processes can re-open the database and resume work.

If the server exited cleanly, there is no need to run recovery, but
there is no harm in it, either, and it take very little time. So
it's a fine idea to run recovery when the server process starts,
before it begins handling any requests.

=== Instance Methods

--- close()

Close the object.

--- closed?()

Return true if object is closed.

--- youngestRev()

Return the youngest revision number in the filesystem.

The oldest revision in any filesystem is numbered zero.

--- revisionProp(rev, propname)

Return the value of the property named ((|propname|)) on revision
((|rev|)). If ((|rev|)) has no property by that name , return nil.

--- revisionProplist(rev)

Return a hash table containing entire property list of revision
((|rev|)).

--- changeRevProp(rev, name, value)

Change a revision's property's value or add/delete a property.

((|rev|)) is the revision in the filesystem.
((|name|)) is the name of the property to change.
((|value|)) is the new value of the property, or nil if the property
should be removed.

Note that revision properties are non-historied --- you can change
them after the revision has been committed. They are not protected
via transactions.

--- revisionRoot(rev)

Return an instance of Svn::RevisionRoot of revision ((|rev|)).

--- beginTxn(rev)

Begin an new transaction on the filesystem, based on existing revision
((|rev|)). Return an instance of Svn::TxnRoot.

There will be similar method in Svn::Repos which does not exist now.

--- openTxn(name)

Open the transaction named ((|name|)) and retun and instance of
Svn::TxnRoot.

--- listTransactions

Return array of strings, containing the name of all the currently
active transaction in the filesystem.

== Svn::FsRoot

=== Instance Methods

--- close()

Close the object.

--- dir?(path)

Return true if ((|path|)) is a directory.

--- file?(path)

Return true if ((|path|)) is a file.

--- file(path)

Return an Svn::FsFile object.

--- dir(path)

Return an Svn::FsDir object.

--- node(path)

Return an Svn::FsFile or Svn::FsDir object based on the type of ((|path|)).

== Svn::FsRevisionRoot

This class is a subclass of Svn::FsRoot.

=== Instance Methods

--- deltify(path, recursive)
--- undeltify(path, recursive)

== Svn::FsTxnRoot

This class is a subclass of Svn::FsRoot.

=== Instance Methods.

--- makeDir(path)

Create a new directory named ((|path|)). The new directory has
no entries, and no properties.

--- makeFile(path)

Create a new file named ((|path|)). The file's initial contents
are the empty string, and it has no properties.

--- applyTextdelta(path)

Apply a text delta to the file ((|path|)). Return an Svn::TextDelta
object.

If ((|PATH|)) does not exist, raises an exception. (You cannot use
this method to create new files; use makeFile to create an empty file
first.)

--- changeNodeProp(path, name, value)

Change a node's property's value, or add/delete a property.
- ((|path|)) indicate the node whose property should change.
- ((|name|)) is the name of the property to change.
- ((|value|)) is the new value of the property, or nil if the property should
be removed altogether.

--- merge (sourceNode, ancestorNode)
--- delete (path)
--- deleteTree (path)
--- rename (from, to)
--- copy (node, path)
--- link (node, path)

== Svn::FsTxn

=== Instance Methods

--- name

Return the name of transaction.

--- commit

Commit the transaction.

   If the transaction conflicts with other changes committed to the
   repository, an Svn::Error exception is raised. Otherwise, create
   a new filesystem revision containing the changes made in the transaction
   and return the new revision number.

   If the commit fails, the transaction is still valid; you can make
   more operations to resolve the conflict, or call abort
   to abort the transaction.

--- close

   Close the transaction. This is neither an abort nor a commit;
   the state of the transaction so far is stored in the filesystem, to
   be opened again later.

--- closed?

Return true if the transaction is closed.

--- prop(propname)

Retun the value of the property named ((|propname|)) on the
transaction. If the transaction has no property by that name, return
nil.

--- proplist

Return hash table contanint entire property list of the transaction.

--- changeProp

Change the transactions's property's value, or add/delete a property.
((|name|)) is the name of the property to change, and ((|value|)) is
the new value of the property, or nil if the property should be
removed altogether.

--- abort

Abort the transaction. Any changes made in this transaction are
discarded, and the filesystem is left unchanged.

Any FsRoot objects referring to the transaction's root directory
become invalid; performing any operation on them other than closing
them will raise an Svn::Error exception.

--- baseRevision

Return the transaction's base revison.

--- txnRoot

Return an instance of Svn::FsTxnRoot.

= SvnFsNode

--- path
--- prop
--- proplist
--- propsChanged?
--- copiedFrom
--- different?
--- contentsChanged?
--- getFileDeltaStream (sourceNode)

= Svn::FsDir

This is a subclass of Svn::FsNode

--- entries

= Svn::FsFile

This is a subclass of Svn::FsNode

--- length

Returns the length of file contents.

--- contents

Returns a readable SvnStream to return contents of the file.

=end

=begin
== Svn::DeltaEditor

== Svn::RubyEditor

This class is a subclass of Svn::DeltaEditor. All instance methods in
this class are not implemented. You must create subclass with
concrete definition of each methods.

=== Class methods

--- new

Returns new instance of Svn::RubyEditor.

=== Instance Methods

--- setTargetRevision(targetRevision)
--- replaceRoot(baseRevision)
--- delete(name)
--- addDirectory(name, copyfromPath, copyfromRevision)
--- replaceDirectory(name, baseRevision)
--- changeDirProp(name, value)
--- clsoeDirectory()
--- addFile(path, copyfromPath, copyfromRevision)
--- replaceFile (name, baseRevision)
--- applyTextDelta()
--- changeFileProp(name, value)
--- closeFile()
--- closeEdit()
--- abortEdit()

== Svn::CommitEditor

=end

=begin
= Svn::Stream

--- read(int)
--- write(string)
--- close()

--- dup()

== Svn::EmptyReader

Subclass of Svn::Stream

=== Class Methods

---new()

== Svn::FileStream

=== Constants

--- READ
--- WRITE
--- CREATE
--- APPEND
--- TRUNCATE
--- BINARY
--- EXCL
--- BUFFERED
--- DELONCLOSE

It's probably better to create new File class based on apr_file_t
and move these constants to new class.

=end

=begin
== Svn::TextDelta

=== Class Methods

--- new(sourceStream, targetStream)

=== Instance Methods

--- sendString(str)
--- apply(deltaWindow)
--- close

== Svn::TextDeltaStream

=== Class Methods

--- new (sourceStream, targetStream)

=== Instance Methods

--- nextWindow
--- close

--- md5()

== Svn::TextDeltaWindow

No methods.

=end

-- 
Yoshiki Hayashi

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:01 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.