Introduction
This is the porting of the mercurial web interfaces to bazaar-ng; todate the porting is implemented as plugin.
Index
Featuresbzr webserve --port=9099 "Official repository" http://bazaar-vcs.org/bzr/bzr.devand go to http://127.0.0.1:9099....
$ bzr webserve --fileserver "Bazaar-NG" bzr.dev $ cd /tmp $ bzr pull http://127.0.0.1:8088 $ Branched 6700 revision(s).
The web interface can be started via the 'bzr webserve' command
$ bzr webserve --help usage: webserve [NAME] [ROOTREPOSITORY] Start the webserver options: --templates --address --port --ipv6 --acceslog --errorlog --lock --profile --tararchivewhere
NAME -> name of the repository ( default the current dir ) ROOTREPOSITORY -> repository directory ( default the current dir ) or an URL ( currently only http:// transport is supported ) --templates -> set the template directory ( default the ROOTREPOSITORY ) --address -> interface to listen --port -> port to listen ( default 8088 ) --ipv6 -> ipv6 enable/disable ( untested ) --accesslog -> accesslog file ( default stderr ) --errorlog -> errorlog file ( default stderr ) --lock -> enable the locking of the repository when a request is performed --profile -> show the profile info at the bottom of page --tararchive -> permit the download of the archive as a tar.gz file --fileserver -> permit to provide the archive for pulling/branching
After the start of the server with the default parameters ( bzr webserve ), you can browse the repository at the address: 'http://127.0.0.1:8088/'
In the next section, you can see how configure webserve as cgi.
The webserve can be configured to work as cgi under apache. That can be useful if you want to provied access via internet to several repositories in a more robust way. The cgi script are two (webserve.cgi and webserve-dir.cgi), and are place under the script directory. Under the docs directory you can see an example of configuration file.
The configuration of has to cover three aspects:
This configuration is better covered in the apache manual.
However below you can see a simple example of apache configuration.
Supposing that your cgi script is
/home/test/bazaar/webserve-dir.cgiyou have to add the following directives to the apache configuration file
Alias /bazaar /home/test/bazaar/webserve-dir.cgi <Directory /home/test/bazaar/> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Indexes Order allow,deny Allow from all AddHandler cgi-script .cgi </Directory>When the URL /bazaar ( and the /bazaar/<somethingelse> ) is ivoked, the cgi /home/test/bazaar/webserve.cgi is started. The first line links the url (/bazaar) to the cgi (/home/test/bazaar/webserve.cgi); the <Directory...> directive permits the cgi execution under the directory /home/test/bazaar/.
Apache has to grant the acces to the .bzr directory inside a
branch; and if you want to serve multiple branches inside a repository,
apache has to be configured to serve also the .bzr directory of the
repository.
The webserve interface can be started as cgi in two modes:
The directive Alias has to refer to the webserve.cgi script.
The script has to be customized inserting the path of bazaar. Supposing that webserve is installed under bzrlib/plugins/webserve you have to change the line
sys.path.insert(0,"/path/to/bazaar")replacing "/path/to/bazaar" with the path where bazaar is installed.
In the script you have to set also the title, the path where the template is installed ( usually bzrlib/plugins/webserve/templates ), and the branch path. The title the template path and the branch path can be customized via the SetEnv apache directive:
SetEnv BAZAAR_WEBSERVE_TITLE "title of the branch" SetEnv BAZAAR_WEBSERVE_TEMPLATES "path/of/the/template/directory" SetEnv BAZAAR_WEBSERVE_BRANCH_PATH "path/of/the/branch/directory"
NOTE:As default it is suppose that the cgi script is installed in the branch which you want to provide.
The directive Alias has to refer to the webserve-dir.cgi script.
The script has to be customized inserting the path of bazaar. Supposing that webserve is installed under bzrlib/plugins/webserve you have to change the line
sys.path.insert(0,"/path/to/bazaar")replacing "/path/to/bazaar" with the path where bazaar is installed.
In the script you have to set also the path of the configuration file, changing the value of the config variable. This value can be set also via the SetEnv apache directive:
SetEnv BAZAAR_WEBSERVE_CONFIG "path/of/the/config/file"
Below there is an example of a config file:
[DEFAULT] ; if 1, it is allowable to download a tar of the archive tararchive = 1 ; if 1, the bottom of the page contains the profiling informations profile = 0 ; if 1, during a command a read_lock is performed lock = 0 ; directory to find the templates in template = /usr/share/bazaar-webserve/templates [repositories1] author = Goffredo Baroncelli name = repo1 description = bazaar-ng stable branch email = email@email.email path = BlaBlaBla/BlaBlaBla/bzr/repo1 repo = url of files in repository (if not set an address will be created from path) [repositories2] author = Goffredo Baroncelli name = repo2 description = bazaar-ng branch two email = email@email.email path = BlaBlaBla/BlaBlaBla/bzr/repo2 [repositories3] author = Goffredo Baroncelli name = repo2 description = remote bazaar-ng branch three email = email@email.email path = http://BlaBlaBla/BlaBlaBla/bzr/repo2 tararchive = 0
For every repository a section named <repoid> has to be specified. Inside this section, we have the following fields to set:
The [DEFAULT] section contains the default set for the options.
The (optional) [MAIN] section permits to refactorize the repositories. If this section isn't present the repositories are shown in a non predicible order. The MAIN section contains the parameter "groups_list" which lists the repositories groups, and decide in which order the repositories group are show.
A repositories groups is a section which contains the following parameters:
Note If a section MAIN is included, only the repositories included in the groups are shown. If the section MAIN is omitted, all repositories are shown, but the order is random.
[MAIN] ; the group order groups_list=group1, group2 [group1] title=Title of the group1 description=descritpion of the group1 repositories=repository1, repository2 [group2] ; if title is omitted, the name of section is used title=Title of the group2 ; if description is omitted, no description is shown description=descritpion of the group2 ; the repositories parameter is mandatory repositories=repository3
Note: the branch can be placed anywhere because you can set the path both in the config file ( path and repo settings ) and in the apache config file via alias directive. For example, supposing that the url which you want to serve is /bazaar/<project-name>, in the webserve config file you can set the path where you want, and in the apache config file you can set an alias as:
Alias /bazaar/<project-name>/.bzr physical/path/of/the/project/.bzrWhen bazaar access to an url, it access only at the .bzr directory, which you can redirect where you want.
The code of the web interface is based on expansion of a template files. Under the directory templates/ there are files which are the skeleton of the html pages. These files have field like '#<field name>#' which the code expand with a value or with another template expansion....
In code:
$ cat templatefile <html> <body> <table> #rows# </table> </body> </html> $ cat templaterows <tr> <td>#tag# $ [...] t = templater("mapfile") def func( ): for i in range(1,10): yield t("templaterows", tag = str(i) ) write(t("templatefile", rows = func( ) )) [...]
the code above, takes the contents of the file "templatefile" and replace every string '#tag#' with the value(s) returned by the function func( ).
The function func( ) return 9 times the content of the file "templaterows", replacing the field '#tag#' with a value between 1 and 9.
Because the function 'func( )' return 9 different values, the unique field '#rows#' is expanded 9 times. The 'mapfile' file contains the mapping between the name of the template name and the template filename...
The goal is to separate the html code to the python code. In fact the template contains the major part of the html code, only the dynamic part are generated by the python code, tipically on the basis of another template; an example is the changelog web page: the main page is a template, where the table rows are an another template expansion...
In order to download the plugin you can
download a tar archive of the plugin at the following address: http://goffredo-baroncelli.homelinux.net/bazaar/tar.
You can pull the source at the following address:
bzr pull http://goffredo-baroncelli.homelinux.net/bazaar/bazaar-webserve
get the latest version at the following url
http://goffredo-baroncelli.homelinux.net/bazaar/bazaar-webserve?cmd=export;rev=;path=;mode=tgz
After the download of the plugins, you have to move the file under a directory named
webserve
on one of the following places
<bazaar-root>/bzrlib/plugins
~/.bazaar/plugins/
See http://bazaar.canonical.com/BzrPlugins for more information