Differences between revisions 2 and 3
Revision 2 as of 2007-03-01 20:24:17
Size: 3641
Comment:
Revision 3 as of 2007-03-01 20:41:27
Size: 3879
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
We are using Bazaar to track files in ``/etc`` on python.org machines. We are using Bazaar to track files in `/etc` on python.org machines.
Line 10: Line 10:
XXX 'bzr whoami' XXX 'bzr whoami' -- setting it
Line 14: Line 14:
Its command-line interface resembles that of CVS,
but using the ``bzr`` executable instead.
The command-line interface resembles that of CVS,
but the executable is named `bzr`.
Line 19: Line 19:
To get a list of available subcommands, run ``bzr help``. To get a list of available subcommands, run `bzr help`.
Line 21: Line 21:
To get more details about one particular subcommand, run ``bzr help <command-name>``. To get more details about one particular subcommand, run `bzr help <command-name>`.
Line 27: Line 27:
If you omit the path name, committing takes the current working directory as its starting point, so you don't need to supply the path if you're currently in ``/etc``. It's OK to commit only a portion of the tree; if you're in ``/etc/apache2`` and do a commit without specifying the path, you'll only commit changes in ``/etc/apache2`` and its subdirectories. If you omit the path name, committing takes the current working directory as its starting point, so you don't need to supply the path if you're currently in `/etc`. It's OK to commit only a portion of the tree; if you're in `/etc/apache2` and do a commit without specifying the path, you'll only commit changes in `/etc/apache2` and its subdirectories.

To back out a change: {{{bzr revert /etc/database.conf}}}
restores the last committed version of the file.

The `revert`` subcommand works recursively on directories,
so `bzr revert /etc` will undo all the changes you've made to the configuration files.
Line 31: Line 37:
``bzr status`` lists the names of files that are different from `bzr status` lists the names of files that are different from
Line 43: Line 49:
To get a diff-style display of changes, use ``bzr diff``: {{{ To get a diff-style display of changes, use `bzr diff`: {{{
Line 71: Line 77:
The ``--diff-options`` switch can be used to change the output of the underlying ``diff`` program. The `--diff-options` switch can be used to change the output of the underlying `diff` program.
Line 82: Line 88:
If you delete a tracked file using ``rm``, Bazaar will If you delete a tracked file using `rm`, Bazaar will
Line 97: Line 103:
The ``bzr rm`` subcommand stops tracking a file, but does **not**
remove the working copy in ``/etc``.
The `bzr rm` subcommand stops tracking a file, but does **not**
remove the working copy in `/etc`.
Line 105: Line 111:
1. Initialize the ``/etc`` directory as a Bazaar repository. {{{ 1. Initialize the `/etc` directory as a Bazaar repository. {{{
Line 109: Line 115:
This will create a directory called ``/etc/.bzr/`` that stores This will create a directory called `/etc/.bzr/` that stores
Line 116: Line 122:
This prevents a stray ``bzr add`` lacking arguments This prevents a stray `bzr add` lacking arguments

Configuration File Version Control

Bazaar Overview

We are using Bazaar to track files in /etc on python.org machines. Bazaar, also known as BZR, is a version-control system written in Python.

The home page for Bazaar is at http://bazaar-vcs.org/.

XXX 'bzr whoami' -- setting it

Bazaar cheatsheet

The command-line interface resembles that of CVS, but the executable is named bzr.

A more detailed introduction to Bazaar's basic features is part of the docs: http://doc.bazaar-vcs.org/bzr.dev/tutorial.htm

To get a list of available subcommands, run bzr help.

To get more details about one particular subcommand, run bzr help <command-name>.

Making changes

To commit a change: bzr commit -m "Add new virtual host" /etc

If you omit the path name, committing takes the current working directory as its starting point, so you don't need to supply the path if you're currently in /etc. It's OK to commit only a portion of the tree; if you're in /etc/apache2 and do a commit without specifying the path, you'll only commit changes in /etc/apache2 and its subdirectories.

To back out a change: bzr revert /etc/database.conf restores the last committed version of the file.

The revert` subcommand works recursively on directories, so bzr revert /etc will undo all the changes you've made to the configuration files.

What have I changed?

bzr status lists the names of files that are different from the last committed version:

root@matterhorn:/etc# bzr status
removed:
  nanorc
added:
  vnc.conf
modified:
  syslog.conf
root@matterhorn:/etc#

To get a diff-style display of changes, use bzr diff:

root@matterhorn:/etc# bzr diff |less
=== removed file 'nanorc'
--- nanorc
+++ /dev/null
@@ -1,314 +0,0 @@
-## Sample initialization file for GNU nano
 ...
=== modified file 'syslog.conf'
--- syslog.conf
+++ syslog.conf
@@ -56,16 +56,3 @@
 #      *.=debug;*.=info;\
 #      *.=notice;*.=warn       /dev/tty8

-# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
-# you must invoke `xconsole' with the `-file' option:
-#
-#    $ xconsole -file /dev/xconsole [...]
-#
-#
-daemon.*;mail.*;\
-       news.crit;news.err;news.notice;\
-       *.=debug;*.=info;\
-       *.=notice;*.=warn       |/dev/xconsole
-

The --diff-options switch can be used to change the output of the underlying diff program.

Adding/removing files

To begin tracking a new configuration file, it must be added to the repository and then committed:

bzr add /etc/database.conf
bzr commit -m "Add database config" /etc/

If you delete a tracked file using rm, Bazaar will notice it's gone and remove it from the repository when you commit:

root@matterhorn:/etc# rm database.conf
root@matterhorn:/etc# bzr status
removed:
  database.conf
root@matterhorn:/etc# bzr commit -m "Remove file"
missing database.conf
deleted database.conf
Committed revision 9.
root@matterhorn:/etc#

The bzr rm subcommand stops tracking a file, but does **not** remove the working copy in /etc.

Initializing a new machine

Here's how to set up the version control on a new system.

1. Initialize the /etc directory as a Bazaar repository.

bzr init /etc

This will create a directory called /etc/.bzr/ that stores the history of changes.

2. Make the 'add' and 'status' subcommands ignore all files by default.

bzr ignore '*'

This prevents a stray bzr add lacking arguments from adding lots and lots of files.

3. Manually add the files you want to track:

bzr add /etc/network/interfaces
bzr add /etc/apache2/httpd.conf
 ...

4. Commit for the first time:

cd /etc
bzr commit -m "Record configuration files"

Admin/VersionControl (last edited 2013-11-20 10:52:48 by MarcAndreLemburg)

Unable to edit the page? See the FrontPage for instructions.