Unfortunately for poor Barry, one of his ten users has complained about a bug that has been in his code for the last couple features. This bug wasn't complicated, but was spread throughout the code in lots of little pieces that made it difficult for Barry to track down. Barry, realizing that he doesn't want to repeat this type of effort again, decides to move to using a revision control system.
Barry wanted to get his code controlled as easily as possible. He wanted all of the bells and whistles of a RCS system, but didn't want to pay the cost of setting up RCS servers. Thusly, he chose Bazaar-NG. Barry decided to start controlling a project that he forked years ago, something called Tuxpuck.
The first thing that Barry did was to get a copy of his own sources, which he put into a directory named tuxpuck (if you are following along with bzr yourself, feel free to import something you've got, perhaps by running cp -a /etc/init.d ~/tuxpuck). He then performed the following actions:
代码: 全选
~$ cd tuxpuck
~/tuxpuck$ bzr init
~/tuxpuck$ echo "I have become truely omnimematic" > my_brag
~/tuxpuck$ bzr add my_brag
added my_brag
~/tuxpuck$ bzr commit -m"Started up"
代码: 全选
~/tuxpuck$ echo "Don't brag. I guess I'm not omnimematic" > my_brag
~/tuxpuck$ bzr commit -m"Bragging is bad"
modified my_brag
代码: 全选
~/tuxpuck$ bzr log
------------------------------------------------------------
revno: 2
committer: James Blackwell <jblack@merconline.com>
timestamp: Wed 2005-09-07 01:09:14 -0400
message:
Bragging is bad
------------------------------------------------------------
revno: 1
committer: James Blackwell <jblack@merconline.com>
timestamp: Wed 2005-09-07 01:08:42 -0400
message:
Started up
However, this doesn't please Barry for too long; he wants more than just to be able to to save changes. What he'd really like to do is to work on two things at the same time, so that he get a feel for branching:
代码: 全选
~/tuxpuck$ cd
~$ bzr branch tuxpuck newpuck
This is cool and all, but what's the point of having a two branches that are exactly the same? Thusly, Barry makes some changes to newpuck:
代码: 全选
~$ cd newpuck
~/newpuck$ echo "Don't brag. I guess I don't remember all" > my_brag
~/newpuck$ bzr commit -m"Variation in humility"
modified my_brag
代码: 全选
~/tuxpuck$ bzr diff -r branch:../newpuck
[a lot of output from diff]
Note: The branch: revision specifier is available on 0.7 and later versions. If Barry were using 0.6 or earlier, he'd need to do something like:
代码: 全选
~/tuxpuck$ cd
~$ diff -ruN -x .bzr tuxpuck newpuck
[a lot of output from diff]
Barry decides that he likes the changes that he did to the newpuck branch the other day and decides to merge it into his main tuxpuck branch. Thusly, he ran the following:
代码: 全选
~$ cd tuxpuck
~/tuxpuck$ bzr merge ../newpuck/
0 conflicts encountered.
~/tuxpuck$ cat my_brag
Don't brag. I guess I don't remember all
代码: 全选
~/tuxpuck$ cat << EOF > my_brag
> This stuff seems to
> be working pretty good so farr.
>
> I wonder if it will kepe working
> EOF
~/tuxpuck$ bzr commit -m"Making a longer example"
modified my_brag
~/tuxpuck$ cd ../newpuck
~/newpuck$ bzr merge ../tuxpuck
0 conflicts encountered.
~/newpuck$ bzr commit -m"Catching newpuck up with tuxpuck"
modified my_brag
代码: 全选
~/newpuck$ sed -i s/kepe/keep/ my_brag
~/newpuck$ bzr commit -m "I fixed the mispelled keep"
modified my_brag
~/newpuck$ cd ../tuxpuck
~/tuxpuck$ sed -i s/farr/far/ my_brag
~/tuxpuck$ bzr commit -m "I fixed the mispelled farr"
代码: 全选
~/tuxpuck$ bzr merge ../newpuck/
0 conflicts encountered.
~/tuxpuck$ cat my_brag
This stuff seems to
be working pretty good so far.
I wonder if it will keep working
~/tuxpuck$
代码: 全选
~/tuxpuck$ bzr commit -m"Merged in from newpuck"
modified my_brag
~/tuxpuck$ cd ../newpuck
~/newpuck$ bzr merge ../tuxpuck/
0 conflicts encountered.
代码: 全选
~/newpuck$ bzr commit -m"Saving the merge from tuxpuck"
modified my_brag
This wraps up the first chapter of the Bzr chronicles. In this chapter you learned, by actually performing, the following things:
* How to import a new project into bazaar-ng
* How to branch in bazaar-ng
* How to check the differences between two branches in bazaar-ng
* How to merge between two branches in bazaar-ng