One SVN repository or many?

后端 未结 13 1913
耶瑟儿~
耶瑟儿~ 2020-11-30 17:17

If you have multiple, unrelated projects, is it a good idea to put them in the same repository?

myRepo/projectA/trunk
myRepo/projectA/tags
myRepo/projectA/br         


        
13条回答
  •  无人及你
    2020-11-30 17:46

    Similar to Blade's suggestion about sharing files, here is a slightly easier, yet less flexible solution. I setup ours like so:

    • /var/svn/
    • /var/svn/bin
    • /var/svn/repository_files
    • /var/svn/svnroot
    • /var/svn/svnroot/repos1
    • /var/svn/svnroot/repos2
    • ...

    In "bin", I keep a script called svn-create.sh which will do all of the setup work of creating an empty repository. I also keep the backup script there.

    In "repository_files", I keep common "conf" and "hooks" directories that all of the repositories have sym links to. Then, there's only one set of files. This does eliminate the ability to have granular, per-project access without breaking the links, though. That was not a concern where I set this up.

    Last, I keep the main directory /var/svn under source control ignoring everything in svnroot. That way the repository files and scripts are under source control as well.

    #!/bin/bash
    
    # Usage:
    # svn-create.sh repository_name
    
    # This will:
    # - create a new repository
    # - link the necessary commit scripts
    # - setup permissions
    # - create and commit the initial directory structure
    # - clean up after itself
    
    if [ "empty" = ${1}"empty" ] ; then
      echo "Usage:"
      echo "    ${0} repository_name"
      exit
    fi
    
    SVN_HOME=/svn
    SVN_ROOT=${SVN_HOME}/svnroot
    SVN_COMMON_FILES=${SVN_HOME}/repository_files
    NEW_DIR=${SVN_ROOT}/${1}
    TMP_DIR=/tmp/${1}_$$
    
    echo "Creating repository: ${1}"
    
    # Create the repository
    svnadmin create ${NEW_DIR}
    
    # Copy/Link the hook scripts
    cd ${NEW_DIR}
    rm -rf hooks
    ln -s ${SVN_COMMON_FILES}/hooks hooks
    
    # Setup the user configuration
    cd ${NEW_DIR}
    rm -rf conf
    ln -s ${SVN_COMMON_FILES}/conf conf
    
    # Checkout the newly created project
    svn co file://${NEW_DIR} ${TMP_DIR}
    
    # Create the initial directory structure
    cd ${TMP_DIR}
    mkdir trunk
    mkdir tags
    mkdir branches
    
    # Schedule the directories addition to the repository
    svn add trunk tags branches
    
    # Check in the changes
    svn ci -m "Initial Setup"
    
    # Delete the temporary working copy
    cd /
    rm -rf ${TMP_DIR}
    
    # That's it!
    echo "Repository ${1} created. (most likely)"
    

提交回复
热议问题