<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">
<sect1 id="tsvn-repository-create">
  <title>Repository Creation</title>
  <indexterm>
    <primary>create repository</primary>
  </indexterm>
  <sect2 id="tsvn-repository-create-commandline">
    <title>Creating a Repository with the Command Line Client</title>
    <indexterm>
      <primary>Create</primary>
    </indexterm>
    <orderedlist>
      <listitem>
        <para>
          Create an empty folder with the name SVN
          (e.g. <filename>D:\SVN\</filename>),
          which is used as root for all your repositories.
        </para>
      </listitem>
      <listitem>
        <para>
          Create another folder
          <filename>MyNewRepository</filename> inside
          <filename>D:\SVN\</filename>.
        </para>
      </listitem>
      <listitem>
        <para>
          Open the command prompt (or DOS-Box), change into
          <filename>D:\SVN\</filename> and type
          <screen>
svnadmin create --fs-type fsfs MyNewRepository
          </screen>
        </para>
      </listitem>
    </orderedlist>
    <para>
      Now you've got a new repository located at
      <filename>D:\SVN\MyNewRepository</filename>.
    </para>
  </sect2>
  <!-- ================================================================= -->
  <sect2 id="tsvn-repository-create-tortoisesvn">
    <title>Creating The Repository With TortoiseSVN</title>
    <indexterm>
      <primary>Create</primary>
      <secondary>TortoiseSVN</secondary>
    </indexterm>
    <?dbhh topicname="HIDD_REPOCREATEFINISHED"?>
    <figure id="tsvn-serversetup-local-dia-1">
      <title>The TortoiseSVN menu for unversioned folders</title>
      <graphic fileref="../images/ContextMenuDirNoControl.png"/>
    </figure>
    <orderedlist>
      <listitem>
        <para>
          Open the windows explorer
        </para>
      </listitem>
      <listitem>
        <para>
          Create a new folder and name it e.g.
          <filename>SVNRepository</filename>
        </para>
      </listitem>
      <listitem>
        <para>
          <action>Right click</action> on the newly created folder
          and select
          <menuchoice>
            <guimenu>TortoiseSVN</guimenu>
            <guimenuitem>Create Repository here...</guimenuitem>
          </menuchoice>.
        </para>
        <para>
          A repository is then created inside the new folder.
          <emphasis>Don't edit those files yourself!!!</emphasis>.
          If you get any errors make sure that the folder is empty
          and not write protected.
        </para>
        <para>
          You will also be asked whether you want to create a directory
          structure within the repository. Find out about layout options
          in <xref linkend="tsvn-repository-layout"/>.
        </para>
        <para>
          TortoiseSVN will set a custom folder icon when it creates a
          repository so you can identify local repositories more easily.
          If you create a repository using the official command line
          client this folder icon is not assigned.
        </para>
      </listitem>
    </orderedlist>
    <tip>
    <para>
        We also recommend that you don't use <literal>file://</literal>
        access at all, apart from local testing purposes. Using a server is
        more secure and more reliable for all but single-developer use.
      </para>
    </tip>
  </sect2>
  <!-- ================================================================= -->
  <sect2 id="tsvn-repository-local-access">
    <title>Local Access to the Repository</title>
    <indexterm>
      <primary>Access</primary>
    </indexterm>
    <indexterm>
      <primary>UNC paths</primary>
    </indexterm>
    <para>
      To access your local repository you need the path to that folder.
      Just remember that Subversion expects all repository paths in the form
      <systemitem class="url">file:///C:/SVNRepository/</systemitem>.
      Note the use of forward slashes throughout.
    </para>
    <para>
      To access a repository located on a network share you can either
      use drive mapping, or you can use the UNC path. For UNC paths,
      the form is
      <systemitem class="url">file://ServerName/path/to/repos/</systemitem>.
      Note that there are only 2 leading slashes here.
    </para>
    <para>
      Prior to SVN 1.2, UNC paths had to be given in the more obscure form
      <systemitem class="url">file:///\ServerName/path/to/repos</systemitem>.
      This form is still supported, but not recommended.
    </para>
  </sect2>
  <sect2 id="tsvn-repository-local-share">
    <title>Accessing a Repository on a Network Share</title>
    <indexterm>
      <primary>Network share</primary>
    </indexterm>
    <para>
      Although in theory it is possible to put a FSFS repository on a network
      share and have multiple users access it using <literal>file://</literal>
      protocol, this is most definitely <emphasis>not</emphasis>
      recommended. In fact we would <emphasis>strongly</emphasis>
      discourage it, and do not support such use for various reasons:
    </para>
    <itemizedlist>
      <listitem>
        <para>
          Firstly you are giving every user direct write access to the
          repository, so any user could accidentally delete the entire repository
          or make it unusable in some other way.
        </para>
      </listitem>
      <listitem>
        <para>
          Secondly not all network file sharing protocols support the locking
          that Subversion requires, so you may find your repository gets corrupted.
          It may not happen straight away, but one day two users will try to access
          the repository at the same time.
        </para>
      </listitem>
      <listitem>
        <para>
          Thirdly the file permissions have to be set just so. You may just about
          get away with it on a native Windows share, but SAMBA is particularly
          difficult.
        </para>
      </listitem>
      <listitem>
        <para>
          If one person installs a newer version of the client which
          upgrades the repository format, then everyone else will be
          unable to access the repository until they also upgrade to the
          new client version.
        </para>
      </listitem>
    </itemizedlist>
    <para>
      <literal>file://</literal> access is intended for local, single-user
      access only, particularly testing and debugging. When you want to share
      the repository you <emphasis>really</emphasis> need to set up a proper server,
      and it is not nearly as difficult as you might think.
      Read <xref linkend="tsvn-serversetup"/> for guidelines on choosing and
      setting up a server.
    </para>
  </sect2>
  <sect2 id="tsvn-repository-layout">
    <title>Repository Layout</title>
    <para>
      Before you import your data into the repository you should
      first think about how you want to organize your data. If you
      use one of the recommended layouts you will later have it much
      easier.
    </para>
    <para>
      There are some standard, recommended ways to organize a
      repository. Most people create a <filename>trunk</filename>
      directory to hold the <quote>main line</quote> of development, a
      <filename>branches</filename> directory to contain branch
      copies, and a <filename>tags</filename> directory to contain
      tag copies. If a repository holds only one project, then
      often people create these top-level directories:
    </para>
    <screen>
/trunk
/branches
/tags
    </screen>
    <para>
      Because this layout is so commonly used, when you create a new
      repository using TortoiseSVN, it will also offer to create the
      directory structure for you.
    </para>
    <para>
      If a repository contains multiple projects, people often
      index their layout by branch:
    </para>
    <screen>
/trunk/paint
/trunk/calc
/branches/paint
/branches/calc
/tags/paint
/tags/calc
    </screen>
    <para>
      ...or by project:
    </para>
    <screen>
/paint/trunk
/paint/branches
/paint/tags
/calc/trunk
/calc/branches
/calc/tags
    </screen>
    <para>
      Indexing by project makes sense if the projects are not closely related
      and each one is checked out individually. For related projects where
      you may want to check out all projects in one go, or where the projects
      are all tied together in a single distribution package, it is often better
      to index by branch. This way you have only one trunk to checkout, and
      the relationships between the sub-projects is more easily visible.
    </para>
    <para>
      If you adopt a top level <filename>/trunk /tags /branches</filename>
      approach, there is nothing to say that you have to copy the entire trunk
      for every branch and tag, and in some ways this structure offers the
      most flexibility.
    </para>
    <para>
      For unrelated projects you may prefer to use separate repositories.
      When you commit changes, it is the revision number of the whole
      repository which changes, not the revision number of the project.
      Having 2 unrelated projects share a repository can mean large gaps
      in the revision numbers. The Subversion and TortoiseSVN projects
      appear at the same host address, but are completely separate
      repositories allowing independent development, and no confusion
      over build numbers.
    </para>
    <para>
      Of course, you're free to ignore these common layouts.  You
      can create any sort of variation, whatever works best for you or
      your team.  Remember that whatever you choose, it's not a
      permanent commitment.  You can reorganize your repository at any
      time.  Because branches and tags are ordinary directories,
      TortoiseSVN can move or rename them however you wish.
    </para>
    <para>
      Switching from one layout to another is just a matter of
      issuing a series of server-side moves; If you don't like the
      way things are organized in the repository, just juggle the
      directories around.
    </para>
    <para>
      So if you haven't already created a basic folder structure inside
      your repository you should do that now. There are two ways to
      achieve this. If you simply want to create a
      <filename>/trunk /tags /branches</filename> structure, you can use
      the repository browser to create the three folders (in three separate
      commits). If you want to create a deeper hierarchy then it is simpler
      to create a folder structure on disk first and import it in a single
      commit, like this:
      <orderedlist>
        <listitem>
          <para>
            create a new empty folder on your hard drive
          </para>
        </listitem>
        <listitem>
          <para>
            create your desired top-level folder structure inside
            that folder - don't put any files in it yet!
          </para>
        </listitem>
        <listitem>
          <para>
            import this structure into the repository via a
            <action>right click</action> on the folder that contains
            this folder structure and selecting
            <menuchoice>
              <guimenu>TortoiseSVN</guimenu>
              <guimenuitem>Import...</guimenuitem>
            </menuchoice>
            In the import dialog enter the URL to your repository
            and click OK.
            This will import your temp
            folder into the repository root to create the basic
            repository layout.
          </para>
        </listitem>
      </orderedlist>
    </para>
    <para>
      Note that the name of the folder you are importing does not appear in
      the repository, only its contents. For example, create the following folder
      structure:
      <screen>
C:\Temp\New\trunk
C:\Temp\New\branches
C:\Temp\New\tags
      </screen>
      Import <filename>C:\Temp\New</filename> into the repository root,
      which will then look like this:
      <screen>
/trunk
/branches
/tags
      </screen>
    </para>
  </sect2>
</sect1>
