libbe.storage.vcs.base

Define the base VCS (Version Control System) class, which should be subclassed by other Version Control System backends. The base class implements a “do not version” VCS.

class libbe.storage.vcs.base.CachedPathID(encoding=None)

Cache Storage ID <-> path policy.

Paths generated following:

.../.be/BUGDIR/bugs/BUG/comments/COMMENT
   ^-- root path

See libbe.util.id for a discussion of ID formats.

Examples

>>> dir = Dir()
>>> os.mkdir(os.path.join(dir.path, '.be'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '123'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def'))
>>> os.mkdir(os.path.join(dir.path, '.be', 'abc', 'bugs', '456'))
>>> file(os.path.join(dir.path, '.be', 'abc', 'values'),
...      'w').close()
>>> file(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'values'),
...      'w').close()
>>> file(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def', 'values'),
...      'w').close()
>>> c = CachedPathID()
>>> c.root(dir.path)
>>> c.id(os.path.join(dir.path, '.be', 'abc', 'bugs', '123', 'comments', 'def', 'values'))
'def/values'
>>> c.init()
>>> sorted(os.listdir(os.path.join(c._root, '.be')))
['abc', 'id-cache']
>>> c.connect()
>>> c.path('123/values') 
u'.../.be/abc/bugs/123/values'
>>> c.disconnect()
>>> c.destroy()
>>> sorted(os.listdir(os.path.join(c._root, '.be')))
['abc']
>>> c.connect() # demonstrate auto init
>>> sorted(os.listdir(os.path.join(c._root, '.be')))
['abc', 'id-cache']
>>> c.add_id(u'xyz', parent=None) 
u'.../.be/xyz'
>>> c.add_id('xyz/def', parent='xyz') 
u'.../.be/xyz/def'
>>> c.add_id('qrs', parent='123') 
u'.../.be/abc/bugs/123/comments/qrs'
>>> c.disconnect()
>>> c.connect()
>>> c.path('qrs') 
u'.../.be/abc/bugs/123/comments/qrs'
>>> c.remove_id('qrs')
>>> c.path('qrs')
Traceback (most recent call last):
  ...
InvalidID: qrs in revision None
>>> c.disconnect()
>>> c.destroy()
>>> dir.cleanup()

Methods

add_id(id[, parent])
connect()
destroy()
disconnect()
id(path)
init([verbose, cache]) Create cache file for an existing .be directory.
path(id[, relpath])
remove_id(id)
root(path)
add_id(id, parent=None)
connect()
destroy()
disconnect()
id(path)
init(verbose=True, cache=None)

Create cache file for an existing .be directory.

The file contains multiple lines of the form:

UUID        PATH
path(id, relpath=False)
remove_id(id)
root(path)
exception libbe.storage.vcs.base.InvalidPath(path, root, msg=None, **kwargs)
exception libbe.storage.vcs.base.NoSuchFile(pathname, root='.')
exception libbe.storage.vcs.base.SpacerCollision(path, spacer)
class libbe.storage.vcs.base.VCS(*args, **kwargs)

Implement a ‘no-VCS’ interface.

Support for other VCSs can be added by subclassing this class, and overriding methods _vcs_*() with code appropriate for your VCS.

The methods _u_*() are utility methods available to the _vcs_*() methods.

Methods

add(id, *args, **kwargs) Add an entry
ancestors(*args, **kwargs) Return a list of the specified entry’s ancestors’ ids.
changed(revision)
check_storage_version()
children(*args, **kwargs) Return a list of specified entry’s children’s ids.
commit(*args, **kwargs) Commit the current repository, with a commit message string summary and body.
connect() Open a connection to the repository.
destroy() Remove the storage repository.
disconnect() Close the connection to the repository.
exists(*args, **kwargs) Check an entry’s existence
get(*args, **kwargs) Get contents of and entry as they were in a given revision.
get_user_id() Get the VCS’s suggested user id (e.g. “John Doe <jdoe@example.com>”).
init() Create a new storage repository.
installed()
is_readable()
is_writeable()
path(id[, revision, relpath])
recursive_remove(*args, **kwargs) Remove an entry and all its decendents.
remove(*args, **kwargs) Remove an entry.
revision_id([index])
root() Set the root directory to the path’s VCS root.
set(id, value, *args, **kwargs) Set the entry contents.
storage_version([revision, path]) Return the storage version of the on-disk files.
version()
changed(revision)
check_storage_version()
client = 'false'
get_user_id()

Get the VCS’s suggested user id (e.g. “John Doe <jdoe@example.com>”). If the VCS has not been configured with a username, return None. You can override the automatic lookup procedure by setting the VCS.user_id attribute to a string of your choice.

installed()
name = 'None'
path(id, revision=None, relpath=True)
revision_id(index=None)
root()

Set the root directory to the path’s VCS root.

This is the default working directory for future invocations. Consider the following usage case:

You have a project rooted in:

/path/to/source/

by which I mean the VCS repository is in, for example:

/path/to/source/.bzr

However, you’re of in some subdirectory like:

/path/to/source/ui/testing

and you want to comment on a bug. root will locate your VCS root (/path/to/source/) and set the repo there. This means that it doesn’t matter where you are in your project tree when you call “be COMMAND”, it always acts as if you called it from the VCS root.

storage_version(revision=None, path=None)

Return the storage version of the on-disk files.

version()
exception libbe.storage.vcs.base.VCSNotRooted(vcs)
exception libbe.storage.vcs.base.VCSUnableToRoot(vcs)
libbe.storage.vcs.base.VCS_ORDER = ['arch', 'bzr', 'darcs', 'git', 'hg', 'monotone']

List VCS modules in order of preference.

Don’t list this module, it is implicitly last.

libbe.storage.vcs.base.detect_vcs(dir)

Return an VCS instance for the vcs being used in this directory.

Searches in VCS_ORDER.

libbe.storage.vcs.base.installed_vcs()

Return an instance of an installed VCS.

Searches in VCS_ORDER.

libbe.storage.vcs.base.new()
libbe.storage.vcs.base.set_preferred_vcs(name)

Manipulate VCS_ORDER to place name first.

This is primarily indended for testing purposes.

libbe.storage.vcs.base.vcs_by_name(vcs_name)

Return the module for the VCS with the given name.

Searches in VCS_ORDER.

This Page