RSS

Bazaar Part 3: Repositories

In the third part of this series on Bazaar I’m going to spend some time examining repositories.  The docs seem to indicate that these really facilitate sharing branches.  I was going to cover repositories and push/pull, but this seems like enough for now.

Repositories

According to the bzr documentation a repository is nothing more than the database that holds all of the branch data.  When you run bzr init, you create a repository within your branch (the .bzr directory).  There is also what the manual calls a shared repository, these are created by the bzr init-repository command.  A shared repository allows multiple branches to share the same database.  This can yield some space savings, as well as keeping everything organized.  I suspect that this organization can aid in keeping a sane permissions model.  We’ll look at that in a later post though.  For now, let’s start playing around with repositories.  First I’ll create a repository.  Remember, myRepository can use any of the remote URI specifications that Bazaar supports.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> bzr init-repository –no-trees myRepository
Shared repository (format: pack-0.92)
Location:
shared repository: myRepository

The –no-trees option tells init-repository to not create a working-tree of the branches within the repository.  Since we won’t be working in this directory, the –no-trees option makes a ton of sense.

Looking at the repository directory shows us that it’s empty, aside form our repository database (the .bzr directory)

[andrew karma] /Users/andrew/Development/BZR
>>>>>> ls -al myRepository
total 0
0 drwxr-xr-x  3   andrew  102 Apr 19 15:54 ./
0 drwxr-xr-x  4   andrew 136 Apr 19 15:54 ../
0 drwxr-xr-x  6   andrew  204 Apr 19 15:54 .bzr/

Now, lets add our new project to the repository.  First we need to initialize myProject.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> bzr init myProject
Created a standalone tree (format: pack-0.92)

[andrew karma] /Users/andrew/Development/BZR/myProject
>>>>>> bzr add
adding myDir
adding test1.txt
adding test2.txt
adding test3.txt
adding test5.txt
adding myDir/test4.txt

[andrew karma] /Users/andrew/Development/BZR/myProject
>>>>>> bzr commit -m “Initial Commit”
Committing to: /Users/andrew/Development/BZR/myProject/
added myDir
added test1.txt
added test2.txt
added test3.txt
added test5.txt
added myDir/test4.txt
Committed revision 1.

Now, lets put this branch into the repository.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> bzr branch myProject myRepository/myProject
Branched 1 revision(s).

[andrew karma] /Users/andrew/Development/BZR
>>>>>> ls -al myRepository
total 0
0 drwxr-xr-x  4 andrew   136 Apr 19 16:05 ./
0 drwxr-xr-x  4 andrew   136 Apr 19 16:04 ../
0 drwxr-xr-x  6 andrew   204 Apr 19 16:04 .bzr/
0 drwxr-xr-x  3 andrew   102 Apr 19 16:05 myProject/

At this point myRepository/myProject behaves like a normal branch (see previous post about branching).  You can create a local branch from it, commit to it, checkout from it, etc.

The last thing I want to examine is creating branch hierarchies within the repository.  Let’s see if we can create a sub branch in the repository.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> bzr branch myRepository/myProject myRepository/myProject/myBranch
Branched 1 revision(s).

We’ve just added myBranch as a sub branch of myProject.  Let’s see what myRepository looks like.

[andrew karma] /Users/andrew/Development/BZR
>>>>>> tree myRepository
myRepository
`– myProject
`– myBranch

myBranch is a branch just like any other.  I would imagine that the shared repository is smart enough to merge some of the shared info together to cut down on size and possibly improve performance.  How you organize your repository appears to be a very arbitrary decision.  This is very unlike what I’m used to in CVS land.  The bzr documentation contains a great writeup of some different repository organization schemes.  That’s it for now, in the next post I’ll look at push/pull.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>