Simple VCS

Django pluggable appliation build on top of vcs.

Models

class vcs.web.simplevcs.models.Repository(*args, **kwargs)

Repository(id, alias, path)

class vcs.web.simplevcs.models.RepositoryInfo(*args, **kwargs)

RepositoryInfo(id, repository_id, clone_count, push_count, size)

get_repo_size()

Returns current size of repository directory.

Views

vcs.web.simplevcs.views.browse_repository(request, template_name, repository=None, repository_path=None, repository_alias=None, revision=None, node_path='', extra_context={})

Generic repository browser view.

Required arguments:

  • Either repository or (repository_path and repository_alias is required
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • revision: object with which backend may identify changeset. In example, mercurial backend recognizes hex or short strings, revision numbers (given as integer or string) or tip string. If none specified, most recent changeset (sometimes called tip) is taken.
  • node_path: relative location of the node in the repository (location to file or directory). By default this is an empty string which would retrieve root node from repository.
  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • changeset: based on the given revision or tip if none given
  • root: repository’s node on the given node_path
  • readme_node: FileNode instance if returning root is a DirNode and a readme file can be found at it’s file listing (can be a file which name starts with README, with or without any extension, case is irrelevant); if no readme file could be found, None is returned
vcs.web.simplevcs.views.diff_file(request, file_path, template_name, repository=None, repository_path=None, repository_alias=None, revision_old=None, revision_new=None, extra_context=None)

Generic repository browser view showing diff of specified file.

Required arguments:

  • Either repository or (repository_path and repository_alias is required
  • file_path: relative location of the file node in the repository.
  • revision_old: object identifying changeset at backend.
  • revision_new: object identifying changeset at backend.
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • file_old: FileNode retrieved by backend for given revision_old param
  • file_new: FileNode retrieved by backend for given revision_new param
  • diff_content: unified diff for retrieved file_old and file_new contents
vcs.web.simplevcs.views.diff_changeset(request, template_name, repository=None, repository_path=None, repository_alias=None, revision=None, extra_context=None)

Generic repository browser view showing diffs for given revision.

Required arguments:

  • Either repository or (repository_path and repository_alias is required
  • revision: object identifying changeset at backend.
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • changeset: Changeset retrieved by backend for given revision param; nodes from added and changed attributes of the changeset have one extra attribute: diff which is instance of vcs.utils.diffs.DiffProcessor
vcs.web.simplevcs.views.hgserve(request, repo_path, login_required=True, auth_callback=None)

Returns mimic of mercurial response. Would raise NotMercurialRequest if request is not recognized as one comming from mercurial agent.

Parameters:
  • repo_path – path to local mercurial repository on which request would be made
  • login_required=True – if set to False, would not require user to authenticate at all (with one exception, see note below)

Note

by default VCS_ALWAYS_REQUIRE_LOGIN is set to True and if not changed, would cause this function to require authentication from all requests (and login_required would NOT be checked). If, on the other hand, settings are configured that VCS_ALWAYS_REQUIRE_LOGIN is False, then authorization would be required only if login_required is True.

Parameters:
  • auth_callback=None – callable function, may be passed only if login_required was True; would be called after authorization, with user as parameter; may be used i.e. for permission checks

Semi generic views which helps to reponse for requests comming from specific SCM clients.

vcs.web.simplevcs.views.hg.hgserve(request, repo_path, login_required=True, auth_callback=None)

Returns mimic of mercurial response. Would raise NotMercurialRequest if request is not recognized as one comming from mercurial agent.

Parameters:
  • repo_path – path to local mercurial repository on which request would be made
  • login_required=True – if set to False, would not require user to authenticate at all (with one exception, see note below)

Note

by default VCS_ALWAYS_REQUIRE_LOGIN is set to True and if not changed, would cause this function to require authentication from all requests (and login_required would NOT be checked). If, on the other hand, settings are configured that VCS_ALWAYS_REQUIRE_LOGIN is False, then authorization would be required only if login_required is True.

Parameters:
  • auth_callback=None – callable function, may be passed only if login_required was True; would be called after authorization, with user as parameter; may be used i.e. for permission checks

Table Of Contents

Previous topic

Web

This Page