Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 0b38be552745286620faf2138b9468d0 > files > 53

subversion-doc-1.4.6-5.1mdv2008.1.x86_64.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Tags</title><link rel="stylesheet" href="styles.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="Version Control with Subversion" /><link rel="up" href="svn.branchmerge.html" title="Chapter 4. Branching and Merging" /><link rel="prev" href="svn.branchmerge.switchwc.html" title="Traversing Branches" /><link rel="next" href="svn.branchmerge.maint.html" title="Branch Maintenance" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Tags</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="svn.branchmerge.switchwc.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Branching and Merging</th><td width="20%" align="right"> <a accesskey="n" href="svn.branchmerge.maint.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="svn.branchmerge.tags"></a>Tags</h2></div></div></div><p>Another common version control concept is a
      <em class="firstterm">tag</em>.  A tag is just a
      “<span class="quote">snapshot</span>” of a project in time.  In Subversion,
      this idea already seems to be everywhere.  Each repository
      revision is exactly that—a snapshot of the filesystem
      after each commit.</p><p>However, people often want to give more human-friendly names
      to tags, like <code class="literal">release-1.0</code>.  And they want to
      make snapshots of smaller subdirectories of the filesystem.
      After all, it's not so easy to remember that release-1.0 of a
      piece of software is a particular subdirectory of revision
      4822.</p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.tags.mksimple"></a>Creating a Simple Tag</h3></div></div></div><p>Once again, <span class="command"><strong>svn copy</strong></span> comes to the
        rescue.  If you want to create a snapshot of
        <code class="filename">/calc/trunk</code> exactly as it looks in the
        <code class="literal">HEAD</code> revision, then make a copy of it:</p><pre class="screen">
$ svn copy http://svn.example.com/repos/calc/trunk \
           http://svn.example.com/repos/calc/tags/release-1.0 \
      -m "Tagging the 1.0 release of the 'calc' project."

Committed revision 902.
</pre><p>This example assumes that a
        <code class="filename">/calc/tags</code> directory already exists.  (If
        it doesn't, you can create it using <span class="command"><strong>svn
        mkdir</strong></span>.)  After the copy completes, the new
        <code class="filename">release-1.0</code> directory is forever a
        snapshot of how the project looked in the
        <code class="literal">HEAD</code> revision at the time you made the
        copy.  Of course you might want to be more precise about
        exactly which revision you copy, in case somebody else may
        have committed changes to the project when you weren't
        looking.  So if you know that revision 901 of
        <code class="filename">/calc/trunk</code> is exactly the snapshot you
        want, you can specify it by passing <code class="option">-r 901</code> to
        the <span class="command"><strong>svn copy</strong></span> command.</p><p>But wait a moment: isn't this tag-creation procedure the
        same procedure we used to create a branch?  Yes, in fact, it
        is.  In Subversion, there's no difference between a tag and a
        branch.  Both are just ordinary directories that are created
        by copying.  Just as with branches, the only reason a copied
        directory is a “<span class="quote">tag</span>” is because
        <span class="emphasis"><em>humans</em></span> have decided to treat it that way:
        as long as nobody ever commits to the directory, it forever
        remains a snapshot.  If people start committing to it, it
        becomes a branch.</p><p>If you are administering a repository, there are two
        approaches you can take to managing tags.  The first approach
        is “<span class="quote">hands off</span>”: as a matter of project policy,
        decide where your tags will live, and make sure all users know
        how to treat the directories they copy in there.  (That is,
        make sure they know not to commit to them.)  The second
        approach is more paranoid: you can use one of the
        access-control scripts provided with Subversion to prevent
        anyone from doing anything but creating new copies in the
        tags-area (See <a class="xref" href="svn.serverconfig.html" title="Chapter 6. Server Configuration">Chapter 6, <i>Server Configuration</i></a>.)  The paranoid
        approach, however, isn't usually necessary.  If a user
        accidentally commits a change to a tag-directory, you can
        simply undo the change as discussed in the previous section.
        This is version control, after all!</p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="svn.branchmerge.tags.mkcomplex"></a>Creating a Complex Tag</h3></div></div></div><p>Sometimes you may want your “<span class="quote">snapshot</span>” to be
        more complicated than a single directory at a single
        revision.</p><p>For example, pretend your project is much larger than our
        <code class="filename">calc</code> example: suppose it contains a
        number of subdirectories and many more files.  In the course
        of your work, you may decide that you need to create a working
        copy that is designed to have specific features and bug fixes.
        You can accomplish this by selectively backdating files or
        directories to particular revisions (using <span class="command"><strong>svn update
        -r</strong></span> liberally), or by switching files and directories
        to particular branches (making use of <span class="command"><strong>svn
        switch</strong></span>).  When you're done, your working copy is a
        hodgepodge of repository locations from different revisions.
        But after testing, you know it's the precise combination of
        data you need.</p><p>Time to make a snapshot.  Copying one URL to another won't
        work here.  In this case, you want to make a snapshot of your
        exact working copy arrangement and store it in the repository.
        Luckily, <span class="command"><strong>svn copy</strong></span> actually has four
        different uses (which you can read about in <a class="xref" href="svn.ref.html" title="Chapter 9. Subversion Complete Reference">Chapter 9, <i>Subversion Complete Reference</i></a>), including the ability to copy a
        working-copy tree to the repository:</p><pre class="screen">
$ ls
my-working-copy/

$ svn copy my-working-copy http://svn.example.com/repos/calc/tags/mytag

Committed revision 940.
</pre><p>Now there is a new directory in the repository,
        <code class="filename">/calc/tags/mytag</code>, which is an exact
        snapshot of your working copy—mixed revisions, URLs,
        and all.</p><p>Other users have found interesting uses for this feature.
        Sometimes there are situations where you have a bunch of local
        changes made to your working copy, and you'd like a
        collaborator to see them.  Instead of running <span class="command"><strong>svn
        diff</strong></span> and sending a patch file (which won't capture
        tree changes, symlink changes or changes in properties), you can
        instead use <span class="command"><strong>svn copy</strong></span> to “<span class="quote">upload</span>”
        your working copy to a private area of the repository.  Your
        collaborator can then either check out a verbatim copy of your
        working copy, or use <span class="command"><strong>svn merge</strong></span> to receive
        your exact changes.</p><p>While this is a nice method for uploading a quick snapshot
        of your working copy, note that this is <span class="emphasis"><em>not</em></span>
        a good way to initially create a branch.  Branch creation should
        be an event onto itself, and this method conflates the creation
        of a branch with extra changes to files, all within a single revision.
        This makes it very difficult (later on) to identify a single
        revision number as a branch point.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="svn.branchmerge.switchwc.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="svn.branchmerge.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="svn.branchmerge.maint.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Traversing Branches </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Branch Maintenance</td></tr></table></div></body></html>