Question branch SVN

When creating a branch, what are the consequences of choosing the next?

Create a copy in the repository from:

  • HEAD revision in the repository
  • Concrete repository revision
  • Working copy
+4
source share
4 answers

In short:

  • Creating from a HEAD revision creates a branch starting with "now", where "now" is the latest version bound to the repository
  • Creating from a specific revision creates a branch starting at a point in the past (indicated by its revision number).
  • Creating from a working copy is like creating a branch starting at a point in the future (your working copy is not completed yet).

Depending on the purpose of creating the branch, you usually choose one of the first two options. The third option is probably less commonly used.

You must go from HEAD if you want to do some research for a specific purpose, or want to start creating another version for a specific client or something like that. You should have gone from the past if you needed to patch a previously released version of your software.

+4
source

The HEAD revision in the SVN repository takes Revision with the highest number, such as the one that was last downloaded.

Specific revision of the repository You can select the version you want to receive.

Working copy A version like this is located right now in your local workspace (not completed).

+1
source

HEAD will cause the branch to become a copy of the last completed version of the repository.

A specific revision will cause the branch to be a copy at a certain point in time in the repository.

A working copy creates a branch based on the latest version of your working copy, and then commits all your changes in the process.

EDIT: An example of selecting a working copy.

You are updating your working copy with the latest version of the trunk to begin making minor changes.

After a few hours, you realize that the work was more than you expected, and you must create a branch.

By creating a branch from the working copy at this point, it effectively creates the branch as if you had done it at the beginning.

+1
source

Creating a branch in svn really just makes a copy of some subset of your repository. In fact, the chapter of the SVN book in the branching section says the same .

If your directory structure looks like this ...

  • Project
    • trunk
    • branches
    • tags

and your url for the trunk: http://example.com/repos/project/trunk , you should:

  • create a new branch named beta from HEAD as follows:

     svn copy http://example.com/repos/project/trunk http://example.com/repos/project/branches/beta 

    This will instantly create a new branch in the repository and will do nothing with your local copy.

  • create a new branch named ancient from the old version of n like this:

     svn copy -rn http://example.com/repos/project/trunk http://example.com/repos/project/branches/ancient 

    This is exactly the same as 1 , but uses a specific revision.

  • create a branch named alpha from your local copy if your current trunk directory is:

     cd ../ svn cp trunk branches/alpha 

    This will make the copy you requested but make it locally. According to the SVN book, this is discouraging because it takes a lot longer than copying to the repository server (where the copy operation is essentially free).

    This disclaimer is also indicated when entering svn help copy :

    WARNING. For compatibility with previous versions of Subversion, copies made using two working copies (WC β†’ WC) will not go to the repository. Therefore, by default they cannot distribute merge tracking information from the copy source to the destination.

In my experience, 1 is commonly used. 2 is used in some rare cases involving complex fixes for earlier branches, and 3 is never useful (and, according to the documentation, slow and possibly dangerous). Therefore, stick to 1 unless you have a good reason to use one of the other two.

+1
source

Source: https://habr.com/ru/post/1311602/


All Articles