19.09.2015 Views

Version Control & Bazaar

Version Control & Bazaar - AdamsInfoServ.com

Version Control & Bazaar - AdamsInfoServ.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Version</strong> <strong>Control</strong> & <strong>Bazaar</strong><br />

• What is version control?<br />

• Examples of basic VC<br />

• History of VC<br />

• VC Systems<br />

• Intro to <strong>Bazaar</strong><br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 1


Shameless Self Promotion<br />

• Principal Consultant @ Adams Information<br />

Services LLC<br />

• http://www.adamsinfoserv.com/<br />

• HLUG member since 2002<br />

• IBM CATE<br />

• Provides Nationwide services and<br />

administration for IBM AIX, pSeries, SAN<br />

Storage, HACMP<br />

• Go Debian!<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 2


What is <strong>Version</strong> <strong>Control</strong><br />

• <strong>Version</strong> <strong>Control</strong> is a method for tracking and<br />

managing changes to a document over time<br />

• <strong>Version</strong> <strong>Control</strong> Software provide common<br />

features to automate the management of<br />

changes over time, potentially across users<br />

and networks<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 3


Manual <strong>Version</strong> <strong>Control</strong><br />

• Most of us do Manual VC naturally<br />

• Backup copies of important documents<br />

• Compare revisions<br />

• Share and merge group efforts<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 4


Manual VC - Backup/Restore/Undo<br />

• Do you often make a backup of a file before<br />

you edit it?<br />

• Story.txt<br />

• Story_backup.txt<br />

• Rename a file prior to editing changes?<br />

• Resume200803.txt<br />

• Resume200808.txt<br />

• This makes it easy to gain access to an older<br />

revision<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 5


Manual VC - Compare<br />

• With multiple copies of files, manually<br />

compare changes<br />

• Arduous, prone to error<br />

• On Linux using diff utility on text files<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 6


Diff Example - Sources<br />

Listing 1: "File.orig"<br />

Fedora<br />

Suse<br />

Gentoo<br />

Debian<br />

Listing 2: "File.txt"<br />

Fedora<br />

Suse<br />

Arch<br />

Gentoo<br />

Ubuntu<br />

Debian<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 7


Diff Example - Diff<br />

Listing 3: "diff File.orig File.txt"<br />

2a3<br />

> Arch<br />

3a5<br />

> Ubuntu<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 8


Diff Example - Unified Diff<br />

Listing 4: "diff -u File.orig File.txt"<br />

−−− F i l e . o r i g 2009−06−13 03:23:25.000000000 −0<br />

+++ F i l e . t x t 2009−06−13 03:17:46.000000000 −0<br />

@@ −1,4 +1 ,6 @@<br />

Fedora<br />

Suse<br />

+Arch<br />

Gentoo<br />

+Ubuntu<br />

Debian<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 9


Manual VC - Sharing/Merging<br />

• Ever try to edit the same file with another<br />

person?<br />

• Name a file by who edited it?<br />

• Article_Alice.txt<br />

• Article_Bob.txt<br />

• How to integrate changes? Painfully!<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 10


Desired VC Features<br />

• Backup / Restore / Undo<br />

• Show Changes / Comparison<br />

• Collaboration / Sharing<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 11


VC Software<br />

• History<br />

• Additional Features<br />

• Multitude of packages<br />

• Centralized vs Distributed<br />

• Server vs Serverless<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 12


Source Code <strong>Control</strong> System (SCCS)<br />

• Now obsolete<br />

• Originally written for mainframes in 70’s<br />

• GNU cloned as CSSC<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 13


Revision <strong>Control</strong> System (RCS)<br />

• Single file<br />

• Common, in most distros<br />

• Simple, compared to later tools<br />

• Written in 80’s<br />

• GNU Project<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 14


Concurrent <strong>Version</strong> System (CVS)<br />

• Client/server<br />

• Centralized repository<br />

• Whole project of multiple files<br />

• Originally used RCS as backend<br />

• Written in 80’s<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 15


VC Software Features<br />

• Ownership<br />

• Logging<br />

• Branching<br />

• Enhanced Networking<br />

• Binary Files<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 16


Modern VC Software<br />

• Git<br />

• SVN<br />

• <strong>Bazaar</strong><br />

• Darcs<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 17


Server vs Serverless<br />

• Server based<br />

• Git/SVN<br />

• Specific daemon configured with<br />

repositories<br />

• Serverless<br />

• Darcs/<strong>Bazaar</strong><br />

• Any Filesystem, HTTP server, SSH<br />

• Reuse common services with little<br />

configuration<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 18


Centralized vs Distributed<br />

• Centralized VC required a central server and<br />

shared resources<br />

• Limited commit access<br />

• Strong separation between branches<br />

(QA/dev/release)<br />

• Historically difficult to branch locally<br />

• Requires network connectivity to commit<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 19


Centralized vs Distributed<br />

• Distributed VC central server is optional<br />

• Developers pass changesets between<br />

themselves<br />

• Easy branching<br />

• Merging key<br />

• Still requires central QA/release<br />

management<br />

• Local commits with future merges<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 20


<strong>Bazaar</strong><br />

• Written and maintained by Canonical<br />

• Ubuntu anyone?<br />

• Distributed VCS<br />

• Serverless<br />

• Grew from TLA Arch<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 21


Vocabulary<br />

• Revision<br />

• A whole set of files from a branch<br />

• Working Copy / Tree / Set<br />

• Your local files where changes are made<br />

• <strong>Version</strong> controlled directory tree<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 22


Vocabulary<br />

• Branch<br />

• A project or set of files with revisions<br />

• Potentially copied from another branch<br />

• Repository<br />

• Where revisions are stored<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 23


Vocabulary<br />

• Checkout<br />

• Create a local working copy from a<br />

repository<br />

• Commit<br />

• Send changes to repository<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 24


Vocabulary<br />

• Merge<br />

• Integrate files with changes from different<br />

sources<br />

• Update<br />

• Pull changes from the repository into your<br />

working copy<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 25


Setting up a Project<br />

$ mkdir ~/myproject<br />

$ cd ~/myproject<br />

$ bzr init<br />

$ ls -a<br />

. .. .bzr<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 26


Adding Files<br />

$ touch file{1,2,3}<br />

$ bzr add<br />

added file1<br />

added file2<br />

added file3<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 27


View Status<br />

$ bzr status<br />

added:<br />

file1<br />

file2<br />

file3<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 28


Committing Changes<br />

$ bzr commit -m ’Look Ma, my first commit<br />

Committing to: ~/myproject/<br />

added file1<br />

added file2<br />

added file3<br />

Committed revision 1.<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 29


Viewing Log<br />

$ bzr log<br />

-----------------------------------------<br />

revno: 1<br />

committer: Russell Adams


Reverting Changes<br />

$ rm *<br />

$ bzr status<br />

removed:<br />

file1<br />

file2<br />

file3<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 31


Reverting Changes<br />

$ bzr revert<br />

N file1<br />

N file2<br />

N file3<br />

$ ls<br />

file1 file2 file3<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 32


Sharing Your Repository<br />

• Post to any http server, or use ssh/sftp<br />

• Same method is used to access any remote<br />

repository<br />

• bzr branch http://myhost/myproject<br />

• bzr branch<br />

sftp://user@host/home/me/myproject<br />

• Launchpad.net Integration<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 33


Updating<br />

• If you suspect the remote repository has<br />

changes<br />

• bzr update<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 34


Committing Upstream<br />

• Email<br />

• bzr send ˜/myproject<br />

–mail-to=email@host.org<br />

• Push<br />

• bzr push<br />

• Works out of the box if you branched a<br />

remote repo<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 35


Other Topics<br />

• Simulating Centralized Development<br />

• Hooks<br />

• Exporting<br />

• File Permissions (exec only)<br />

• Renaming<br />

• Symlinks<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 36


Tortoise BZR<br />

• Windows Frontend<br />

• Integrates with Windows Explorer<br />

• Lacks revert!<br />

• bzr commands still used on command line<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 37


Toroise BZR<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 38


Toroise BZR<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 39


Toroise BZR<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 40


Toroise BZR<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 41


Workflows<br />

Lets not reinvent the wheel. . .<br />

Discuss http://bazaar-vcs.org/Workflows<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 42


Q&A<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 43


Further Reading<br />

http://betterexplained.com/articles/a-visual-guide-to-version-contro<br />

http://en.wikipedia.org/wiki/Revision%5Fcontrol<br />

http://en.wikipedia.org/wiki/Distributed%5Frevision%5Fcontrol<br />

http://en.wikipedia.org/wiki/Comparison%5Fof%5Frevision%5Fcon<br />

http://agave.garden.org/ aaronh/rcs/manual/html/ch05s02.html<br />

http://en.wikipedia.org/wiki/Source%5FCode%5F<strong>Control</strong>%5FSyst<br />

http://bazaar-vcs.org/<br />

http://doc.bazaar-vcs.org/bzr.dev/en/mini-tutorial/index.html<br />

http://bazaar-vcs.org/Workflows<br />

http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html<br />

<strong>Version</strong> <strong>Control</strong> and <strong>Bazaar</strong> – p. 44

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!