vcs — Transifex v0.8.0 documentation

# Transifex v0.8.0 documentation

# `vcs`

## Models

class `VcsUnit`(*args, **kwargs)

  A snapshot of a VCS project, an instance of a repository’s files.

  A vcsunit is a VCS module (component) snapshot, which represents an actual directory of files (eg. a repository, branch combination, or a repository, directory, date one). VcsUnits can be checked-out and managed like any real set of actual files.

  It can be considered as the equivalent of a filesystem’s directory.

      >>> u = VcsUnit.objects.create(name="Foo")
      >>> u = VcsUnit.objects.get(name="Foo")
      >>> print u.name
      Foo
      >>> VcsUnit.objects.create( name="Foo")
      Traceback (most recent call last):
          ...
      IntegrityError: column name is not unique
      >>> u.delete()

`need_browser`(fn)
  Decorator to initialize the vcsunit.browser when it is needed.

`suite`()

  Define the testing suite for Django’s test runner.

  Enables test execution with `./manage.py test <appname>`.

## Library

### VCS backends

class `BzrBrowser`(root, name=None, branch=None)

  A browser class for Bazaar repositories.

  Bazaar homepage: http://bazaar-vcs.org/

      >>> b = BzrBrowser(
      ... root='http://fedorapeople.org/~wtogami/temp/InstantMirror/',
      ... name='test-bzr')
      >>> BzrBrowser(root='foo', name='../..')
      Traceback (most recent call last):
        ...
      AssertionError: Unit checkout path outside of nominal repo checkout path.

  `init_repo`()

    Initialize the `repo` variable on the browser.

    If local repo exists, use that. If not, clone/checkout the repo.

  `remote_path`
    Return remote path for cloning.
  `setup_repo`()

    Initialize the working tree for the first time.

    Commands used: bzr checkout –lightweight <remote_path> <self.path>

class `CvsBrowser`(root, name=None, branch='HEAD', module=None)

  A browser class for CVS repositories.

  CVS homepage: http://www.nongnu.org/cvs/

      >>> b = CvsBrowser(root=':pserver:anonymous@cvs.fedoraproject.org:/cvs/elvis',
      ... module='switchdesk')
      >>> print b.module
      switchdesk
      >>> b = CvsBrowser(root=':pserver:anonymous@cvs.fedoraproject.org:/cvs/elvis/switchdesk')
      >>> print b.module
      switchdesk
      >>> b.init_repo()
      >>> b.update()
      >>> CvsBrowser(root='foo', name='../..')
      ...
      AssertionError: Unit checkout path outside of nominal repo checkout path.

  `init_repo`()

    Initialize the `repo` variable on the browser.

    If local repo exists, use that. If not, check it out.

  `remote_path`
    Return remote path for checkout.
  `setup_repo`()

    Initialize repository for the first time.

    Commands used: cvs -d checkout

class `GitBrowser`(root, name=None, branch='master')

  A browser class for Git repositories.

  Git homepage: http://git.or.cz/

      >>> b = GitBrowser(root='http://git.fedorahosted.org/git/elections.git',
      ... name='test-git', branch='master')
      >>> GitBrowser(root='foo', name='../..', branch='tip')
      Traceback (most recent call last):
        ...
      AssertionError: Unit checkout path outside of nominal repo checkout path.

  `init_repo`()

    Initialize the `repo` variable on the browser.

    If local repo exists, use that. If not, clone it.

  `remote_path`
    Return remote path for cloning.
  `setup_repo`()

    Initialize repository for the first time.

    Commands used: git clone <remote_path> <self.path> if branch != master: git branch <branch> <remote_branch> git co <branch>

class `HgBrowser`(root, name=None, branch='default')

  A browser class for Mercurial repositories.

  Mercurial homepage: http://www.selenic.com/mercurial/

      >>> b = HgBrowser(root='http://code.transifex.org/transifex',
      ... name='test-hg', branch='default')
      >>> HgBrowser(root='foo', name='../..', branch='default')
      Traceback (most recent call last):
        ...
      AssertionError: Unit checkout path outside of nominal repo checkout path.

  `init_repo`()

    Initialize the `repo` variable on the browser.

    If local repo exists, use that. If not, clone it.

  `remote_path`
    Return remote path for cloning.
  `setup_repo`()

    Initialize repository for the first time.

    Commands used: hg clone <remote_path> <self.path> hg update <branch>

class `SvnBrowser`(root, name=None, branch=None)

  A browser class for Subversion repositories.

  Note, that compared to the other Browsers, this one is stateless: It doesn’t require a self.repo object or something, since each command can execute without any preparation. For this reason, init_repo is not doing much.

  Subversion homepage: http://subversion.tigris.org/

      >>> b = SvnBrowser(name='test-svn', branch='trunk',
      ... root='http://svn.fedorahosted.org/svn/system-config-language')
      >>> SvnBrowser(root='foo', name='../..', branch='trunk')
      ...
      AssertionError: Unit checkout path outside of nominal repo checkout path.

  `remote_path`
    Calculate remote path using the standard svn layout.

`domain_from_hostname`(hostname)

  Return the 2nd-level domain from a full hostname.

      >>> domain_from_hostname('http://foo.bar.com/')
      'bar.com'
      >>> domain_from_hostname('http://localhost:8000/foo/bar/')
      'localhost'

`need_auth`(fn)
  Decorator for methods needing SVN authentication.