-----------------------
Version Control Systems
-----------------------

:For: VAGUE <http://uvm.org/vague>
:Date: 2007-03-20
:Authors: Forest Bond, Paul Flint, Josh Sled, Andrew Tomczak
:Hosted By: `ClearBearing <http://www.clearbearing.com/>`_

.. footer:: 2007-03-20 — VAGUE

Version Control Systems
-----------------------

- Track a set of changes to directories of files.

  - Files/directory names, contents.
  - Textual, line-oriented changes
  - Metadata

    - Authorship, timestamp, history, change logs/descriptions
    - Filesystem Permissions
  - Branches: separate, named unrelated sets of changes.
  - Integration of changes from other sources.

Core Concepts
-------------

- *repository*
- *commit* the current state of a set of files/directories

  - including metadata
- view *history*; retreive a previous version
- *extract* changes for exchange

Good for?
---------

- source code
- markup

  - documentation (html, DocBook, text)
  - web sites

- configuration
- text files
- binary object history

  - Images (Gimp, P'shop, Inkscape/SVG, ...)
  - Microsoft Word^W^W opaque document formats
  - ...?

Distributed vs. Centralized
---------------------------

- Centralized
  
  - The One True Repository.
  - The "commit" operation is done synchronously against that repository.
  - Checkouts usually only have local/*very* partial state.
  - Some history operations probably aren't possible without the repository.

- Distributed

  - There are multiple independently complete repositories.
  - Commits are usually local and independent.
  - Synchronization is done via patch exchange.
  - Authority is social, not technical.


Presentations
-------------

- Subversion (svn) — Andrew Tomczak
- `SVK <http://www.alittletooquiet.net/slides/svk.html>`_ — Forest Bond
- git — Josh Sled
- `Mercurial <http://www.alittletooquiet.net/slides/mercurial.html>`_ (hg) — Forest Bond
- darcs — Josh Sled
- Bazzar (bzr) — Paul Flint
- discussion; next meeting planning

Subversion (svn)
----------------

Andrew...

git and git-svn
---------------

:Author: jsled <http://asynchronous.org/jsled>
:Date: 2007-03-20

Overview
--------

`git`_

- Created by Linus Torvalds

  - After "The BitKeeper Debacle".
  - Borne of handling patches for the kernel
  - Monotone = good but slow
  - Inspiration from BK, Monotone, quilt
  - pragmatically tuned

    - BK = 10-15 seconds/patch
    - git = 6.7 patches/second

- maintained by Junio C. Hamano, a development-phase contributor

.. _git: http://git.or.cz/

.. container:: handout

   Other resources:
   - <http://www.kernel.org/pub/software/scm/git/docs/everyday.html>

Basic theory of operation
-------------------------

- tool for the application of many coherent patches

- major parts

  - working copy
  - index ("cache")
  - database repository

- toolkit design: many small, single-purpose applications

- plumbing

  - very low level operations

- porcelains

  - front-ends, higher-level operation

The primary commands
--------------------

::

    $ git clone git://project.org/pub/project.git
    $ cd project.git
    # edit files...
    $ git-add new-stuff
    $ git-pull
      # get updates: git-fetch + git-merge
    $ git-format-patch -stdout \
        | sendmail maintainer@project.org
    (or) $ git-push

Commands: core
--------------

::

    $ git init-db
      # create a working copy + repository
    $ git-clone
      # copy existing wc + repository
    $ git-{add, rm, mv}
    $ git-status
    $ git-commit -a

- Changed files aren't picked up automatically.  Content is the focus, not
  the files.

Commands: patches
-----------------

::

    $ git-format-patch

- lots of options for formatting email for kernel (general project) patch submission
- "[PATCH [n/m]]" subject line, "Signed-off-by: " lines, &c.

::

    $ git-am
    $ git-applymbox

- Apply patches from a mailbox.

::

    $ git-revert

- Create an anti-patch.

Commands: patches
-----------------

::

    $ git-fetch
    $ git-merge

- plugable merge strategies

  - resolve: standard 3-way merge
  - recursive: enhanced 3-way merge
  - octopus: N-way merge; refuses to do complex merge
  - ours: merge, but always use current branch.

::

    $ git-pull

- equivalent to ``git-fetch; git-merge``

Commands: network
-----------------

::

    $ git-daemon

- Create a server

::

    $ git-push

- Send changes upstream, using a given protocol.

  - rsync, ssh, http(s)/dav, git

Commands: status/state
----------------------

::

    $ git-reset (--{soft,hard})

- This lets you ammend/re-record a commit or throw away local changes.

::

    $ git-log
    $ git-diff
    $ git-show {guid(partial), HEAD[^|^^|~n|^n], branch]

- History overview and view.

  - ``HEAD``, ``HEAD^`` parent, ``HEAD^^`` grandparent, ``HEAD~4`` great-great grand-parent
  - ``HEAD^n``: first/second/... parent

::

    $ git-tag

- Creates a GPG-signed object in the database

Commands: branches
------------------

::

    $ git-branch mybranch
    $ git-checkout mybranch
    $ git-rebase


           A---B---C topic
          /
      D---E---F---G master


                    A’--B’--C’ topic
                   /
      D---E---F---G master

Commands: misc
--------------

::

    $ git-prune

- Clean up git garbage

::

    $ git-repack

- Delta-encode repository content.

Commands: git-bisect
--------------------

::

    $ git-bisect start
    $ git-bisect bad   # current
    $ git-bisect good «rev»
    500 revisions remain
    # test
    $ git-bisect {good, bad}
    250 revisions remain
    # test ...    

Interesting/unique apsects
--------------------------

- Changed files aren't picked up automatically (``git-commit -a``)

- front-ends/integration (more "porcelains")

  - cogito (cg)
  - StGIT
  - gitk (tk frontend for browsing git ancestory)
  - git-gui (tk)

- windows portability

  - uses file system ops that aren't fast on windows
  - mmap; fork
  - end of line conventions
  - permissions model

- CVS server emulator

git and svn
-----------

.. container:: handout

   Resources:

   - <http://www.thened.net/tags/subversion>
   - <http://tw.apinc.org/weblog/2007/01/03/subverting-git>

- ``git-svnimport``: import an entire svn repository history into git
- ``git-svn``: bidirectional tracking of a single svn branch
- branch-focused

  - pulls SVN repo into ``remote/git-svn``

    - ``remotes/${GIT_SVN_ID:-git-svn}``, really

  - you then branch locally from that

Example
-------

::

    $ git-svn init http://svn.project.org/repo/proj/trunk
    $ git-svn fetch -r12345    # start at a recent revision
    $ git-svn fetch    # fetch everything (since previous)
    $ git checkout -b local remotes/git-svn
      # create local branch
    $ git repack -d    # delta-encode state, compress.
    # hack hack hack
    $ git commit -a
    # more hacking
    $ git commit -a
    $ git-svn fetch    # updates remote/git-svn
    $ git rebase remotes/git-svn
      # sync remote changes with local
    $ git-svn dcommit    # push changes to svn, rebase
    # This will send two commits upstream.

git and git-svn
---------------

*(fin)*

darcs
-----

:Author: jsled <http://asynchronous.org/jsled>
:Date: 2007-03-20

Overview
--------

`darcs`_

- Announced Wed, 9 Apr 2003 on the haskell-cafe mailing list.
- Written by Physicist David Roundy.

.. _darcs: http://abridgegame.org/darcs/

.. container:: handout

   Resources

   - <http://abridgegame.org/darcs/>
   - <http://darcs.net/>
   - <http://darcs.net/DarcsWiki>
   - <http://en.wikibooks.org/wiki/Understanding_darcs>

Basic theory of operation
-------------------------

- local repository

  - pristine copy, working copy, history

- algebra of patches

  - commutation of unrelated patches
  - implicit dependency determination
  - explicit dependency specification

The primary commands
--------------------

::

    $ darcs get http://project.org/repos/project
    # edit; create new file
    $ darcs add
    $ darcs whatsnew [--summary]
    $ darcs pull    # update
    $ darcs record
    $ darcs send
    (or) darcs push

Commands: core
--------------

::

    $ darcs init

- Create a working copy + repository
- Uses ``_darcs`` dir.  WTF?

::

    $ darcs get

- copy the history of an existing repository

::

    $ darcs {add, remove, mv}
    $ darcs whatsnew [--summary]

- list unrecorded changes

::

    $ darcs record

Commands: patches
-----------------

::

    $ darcs send | darcs apply
    $ darcs pull
    $ darcs push

    $ darcs diff

- standard/simple diff; '-u' for unified

::

    $ darcs whatsnew

- hunks: diff++
- context-sensitive

  - supports adding/removing files

Commands: patch management
--------------------------

::

    $ darcs revert

- remove new changes; restore your WC to the recorded copy.

::

    $ darcs unrevert

- "oh s#%t!!" undo of revert ... iff nothing has changed.


Commands: patch management (cont'd)
-----------------------------------

::

    $ darcs unrecord

- undo a record, leaving the changes in the WC.

::

    $ darcs ammend-record

- append to the previous recorded record

Commands: patch management (cont'd)
-----------------------------------

::

    $ darcs {unpull, obliterate}

- unrecord changes and revert

::

    $ darcs rollback

- generates an anti-patch

Commands: status/state
----------------------

::

    $ darcs changes

- changelog-style, history of commits

::

    $ darcs tag

- no version numbers
- create names for states with tag

::

    $ darcs resolve

- conflict resolution

Commands: branches
------------------

::

    $ cp repo-trunk repo-branch

- sync patches between branches manually

Unique apsects: good
--------------------

- explicit dependency specification

- "spontaneous branches"

  - patch records named with prefixes of "RT#123"
  - subsequent ops can give "-p 'RT#123'".

- interactive operation (good?)

Unique apsects: bad
-------------------

- file metadata/permissions not supported

  - <http://darcs.net/DarcsWiki/GettingStarted> mentions "/etc"
    - FAQ says "don't use it for /etc".

- no binary-delta support

  - the FAQ encourages you to use xdelta manually and track the parts via
    files. :/

- no symlink support

- no partial checkout (sub-directory) support

- no good charset support

  - ^Z, \0 -> binary

- auto{conf,make} will trash a darcs repo

  - Because of ``_darcs/current/configure.in``

darcs
-----

*fin*

