svn checkout options. SVN is a centralized version control system. Remote access via SSH protocol

Subversion (SVN - Concurrent Versions System) is a centralized version control system. Designed as a replacement for CVS, has the same functionality, but is devoid of many of its shortcomings. See also: SVN book .

Setting up an SVN server

SVN repository, quite simply, in this example, a directory, /home/svn/, must exist: # svnadmin create --fs-type fsfs /home/svn/project1 You can connect to the repository in the following ways:

  • file://- Direct access through the file system using SVN client. Privileges must be correctly configured on the local file system.
  • svn:// or svn+ssh://- Remote access to SVN server (also according to the protocol SSH). Permissions are required in the local file system, the default port is: 2690/tcp.
  • http:// Remote access via webdav using apache. This method does not require local users.
Importing and checking an existing project through the local file system. It is not necessary to enter the working directory, you can just specify the full path: # svn import /project1/ file:///home/svn/project1/trunk -m "Initial import" # svn checkout file:///home/svn/project1

Remote access via SSH protocol

Remote access by protocol SSH does not require any additional settings, just replace file:// on the svn+ssh/hostname. For example: # svn checkout svn+ssh://hostname/home/svn/project1 As with local access, the user must have an account to access the protocol SSH to the server, and correctly configured read/write permissions. This method can be suitable for small groups of users, the users in the group are the owners of the repository, for example: # groupadd subversion # groupmod -A user1 subversion # chown -R root:subversion /home/svn # chmod -R 770 /home/svn

Remote access via HTTP (apache)

Remote access via http(HTTPS), a suitable solution for remote user groups. This method uses web server authorization Apache(not local accounts). Here is a typical configuration : LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so # Only for access control DAV svn # URL "/svn/foo" will be mapped to repository path /home/svn/foo SVNParentPath /home/svn AuthType Basic AuthName "Subversion repository" AuthzSVNAccessFile /etc/apache2/svn.acl AuthUserFile /etc/apache2/svn- passwd Require valid-user Server Apache must have full access to the repository: # chown -R www:www /home/svn Create a user with htpasswd: # htpasswd -c /etc/svn-passwd user1 #-c Create file

svn.acl access control example

# Default read access. "*=" will not have access by default[/] * = r project1-developers = joe, jack, jane # Give write permissions to developers@project1-developers=rw

Some commands for managing an SVN repository

See also Subversion Quick Reference Card . Tortoise SVN, nice Windows interface.

Import

You can import a new project containing directories and files into the repository using the command import. The same command is also used to add a directory with its contents to an existing project. # svn help import # Help on command # Add a new directory and its contents to the src directory of project1.# svn import /project1/newdir http://host.url/svn/project1/trunk/src -m "add newdir"

Typical SVN Commands

# svn co http://host.url/svn/project1/trunk # Checkout the latest version # Tags and branches are created by copying# svn mkdir http://host.url/svn/project1/tags/ # Create a tags directory# svn copy -m "Tag rc1 rel." http://host.url/svn/project1/trunk \ http://host.url/svn/project1/tags/1.0rc1 # svn status [--verbose] # Check the status of files in the working directory# svn add src/file.h src/file.cpp # Add two files# svn commit -m "Added new class file" # Send changes by message# svn ls http://host.url/svn/project1/tags/ # List of all tags# svn move foo.c bar.c # Move (rename) files# svn delete some_old_file # Delete files

Extract

Svn checkout [-depth ARG] [--ignore-externals] [-r rev] URL PATH

If the checkbox is checked Skip external

If you are checking out a specific revision, specify it after the URL with the -r option.

Refresh

svn info working_copy_url svn update [-r rev] PATH

Updating multiple items is currently not an atomic operation in Subversion. Therefore, TortoiseSVN first finds the head revision (HEAD) in the repository and then updates all items to that revision to avoid creating a working copy with mixed revisions.

If only one item is selected to update, or if the selected items are not all from the same repository, TortoiseSVN simply updates to the top revision.

Command line options are not used here. Update to revision also implements the update command, but offers more options.

Update to revision

svn info working_copy_url svn update [-r rev] [-depth ARG] [--ignore-externals] PATH

The depth combo box items relate to the -depth argument.

If the checkbox is checked Skip external, use the --ignore-externals option.

Fix

In TortoiseSVN, the commit dialog uses several Subversion commands. The first stage is the status check, which determines the elements of your working copy that could potentially be committed. You can browse this list, compare the files against their base, and select the items you wish to include in the commit.

svn status -v PATH

If the checkbox is checked

If you mark any unversioned files and folders, those items will be added to your working copy first.

svn add PATH...

When you click OK, Subversion starts executing the commit. If you left all file flags in their default state, TortoiseSVN uses one recursive working copy commit. If you have unmarked some files, then a non-recursive commit (-N) must be used, and each path must be specified individually on the commit command line.

Svn commit -m "LogMessage" [-depth ARG] [--no-unlock] PATH...

The LogMessage here is the contents of the log message input box. It may be empty.

Difference

svn diff PATH

If you use the "Differences" command from the main context menu, you are comparing the changed file to its base revision. The output from the ICS of the above command also does this and produces output in the combined diff format. However, TortoiseSVN does not use this. TortoiseSVN uses TortoiseMerge (or a diff program of your choice) to graphically display the differences between text files, so there is no direct equivalent to ICS.

You can also compare any two files with TortoiseSVN, whether or not they are under version control. TortoiseSVN simply feeds these two files into the chosen diff program and lets it determine where the differences are.

Magazine

svn log -v -r 0:N --limit 100 [--stop-on-copy] PATH or svn log -v -r M:N [--stop-on-copy] PATH

By default, TortoiseSVN tries to extract 100 log messages using the --limit method. If the installations force the use of the old APIs, then the second form is used to get log messages for 100 revisions from the repository.

If the checkbox is checked Stop on copy/rename, use the --stop-on-copy option.

Checking for Changes

svn status -v PATH or svn status -u -v PATH

The initial status check only looks at your working copy. If you click on Check storage, then the repository is also checked to see what files will be changed by the upgrade, and this requires the -u option.

If the checkbox is checked Show unversioned files, TortoiseSVN will also show unversioned files and folders in the working copy hierarchy, given the ignore rules. This particular property has no direct equivalent in Subversion because the svn status command does not go into unversioned folders.

Revision graph

The revision graph is a feature provided only by TortoiseSVN. There is no analogue in the command line client.

What TortoiseSVN does:

svn info working_copy_url svn log -v URL

where url is root storage, and then parses the returned data.

Storage Explorer

svn info working_copy_url svn list [-r rev] -v URL

You can use svn info to determine the root of the repository: this is the top level shown in the repository browser. You cannot move above this level. Also, this command returns all lock information displayed in the repository browser.

Calling svn list will list the contents of the folder, for the specified URL and revision.

Edit Conflicts

This command has no equivalent in X. It calls TortoiseMerge or an external three-way diff/merge tool to look at the files involved in the conflict and select the lines that should be used.

Settled

svn resolved PATH

Rename

Svn rename CURRENT_PATH NEW_PATH

Delete

svn delete PATH

Remove changes

svn status -v PATH

The first stage is a status check that identifies items in your working copy that could potentially be retracted. You can view the list, compare the files with the base and select the elements in which you want to remove the changes.

When you click OK, Subversion will remove the changes. If you left all file selection flags in their default state, TortoiseSVN uses a single recursive (-R) revert to the working copy. If you unmark some files, then each path must be specified individually on the command line to remove the changes.

Svn revert [-R] PATH...

cleaning

svn cleanup PATH

block

svn status -v PATH

The first stage is a status check that identifies files in your working copy that could potentially be locked. You can select the elements you wish to block.

Svn lock -m "LockMessage" [--force] PATH...

The LockMessage is the contents of the lockmessage field. It may be empty.

If the checkbox is checked Intercept locks, use the --force option.

Unlock

svn unlock PATH

Branch/Label

Svn copy -m "LogMessage" URL URL or svn copy -m "LogMessage" or svn copy -m "LogMessage" URL PATH

The Branch/Label dialog performs a copy to the repository. There are 3 toggle buttons:

  • Head revision in repository (HEAD)
  • The specified revision in the repository
  • working copy

which correspond to the three command line options above.

This series of articles is devoted to the introduction to the use SVN, from the point of view of an ordinary user. The article was written to help my colleagues to quickly learn and use SVN. So let's start with the basics.

Introduction

subversion ( SVN) is a free and open source version control system. SVN allows you to manage files and directories, as well as changes made to them over time. SVN provides the following options:

  1. Directory change control. SVN uses a "virtual" file system with versioning capabilities that is able to track changes over time to entire directory structures
  2. Real version history. SVN makes it possible to add, delete, copy and rename both files and directories. At the same time, each newly added file starts life from scratch, keeping its own history of changes.
  3. Atomic commit. Each set of changes either goes into the repository in its entirety, or does not go there at all. Those. if an error occurred while processing the file while committing project changes, then changes to the entire project will not be committed
  4. versioned metadata. Each file and directory has its own set of properties, represented as a name and value. You can create and save any pair of property names and values ​​you need. File properties are just as much versioned as their content.
  5. One way to work with data. SVN detects differences between files using a special binary algorithm that works equally with both text and binary files. Files are written to storage in a compressed form, regardless of their type, and differences between individual versions can be transferred over the network in both directions
  6. Effective branches and tags. SVN creates branches and tags by simply copying the project, using a mechanism similar to hard links in filesystems. Thanks to this, operations for creating branches and tags take a little time.


List of basic terms

  1. repository(repository) is a centralized repository of source codes, working materials and documentation. Any number of clients connect to the storage and read or write these files
  2. working copy/working copy(WC) is an ordinary directory tree on a computer containing a set of files for working on a project. Changes in the working copy are not available to other users of the repository until they are committed.
  3. Trunk— the main direction of development
  4. branch("Branch") - a development direction that exists independently of another direction, but has a common history with it. A branch always starts as a copy of something and moves from that point, creating its own history.
  5. Tag(""Label"") - the version of the project files at a certain point in time, explicitly selected by creating a separate folder.
  6. revision— revision number of the repository, within the repository the revision number is a unique value
  7. checkout- a command that performs the initial checkout of a project from a repository in WC.
  8. Commit- a command that commits changes to project files in WC to the Repository.
  9. update- a command that updates the project files in WC from the repository
  10. Revert- a command that undoes any changes to the project files in WC based on the revision number of the repository.
  11. Merge- a command that merges files from different branches of the project and places the result of the merge in WC.
  12. Conflict- a situation that occurs when committing changes, when the same files were changed by several developers.
  13. Resolve- a set of rules for resolving emerging conflicts.
  14. Import- command to quickly copy a tree of files to the Repository.
  15. Export- the command for exporting a project differs from checkout in that it does not create service information in the project folders.
  16. switch- a command that switches WC to another development branch.
  17. Create, Add, Delete, Copy, move, Rename- commands for managing files and folders in a repository or WC.

Software

Working with the repository SVN reviewed based on software TortoiseSVN

Introduction

The help function of Subversion ( svn help) provides a summary of the available commands. More detailed information is available from the Subversion on-line book available at http://svnbook.red-bean.com/en/1.2/index.html . Chapter 3 is especially helpful.

The following is a basic set of commands which all editors will use frequently. Some commands have two forms, the long and the short. Both are listed in the description.

svn diff. This is useful for two different purposes. First, those without write access to the BLFS SVN server can use it to generate patches to send to the BLFS-Dev mailing list. To do this, simply edit the files in your local sand box then run svn diff > FILE.patch from the root of your BLFS directory. You can then attach this file to a message to the BLFS-Dev mailing list where someone with editing rights can pick it up and apply it to the book. The second use is to find out what has changed between two revisions using: svn diff -r revision1:revision2 FILENAME . For example: svn diff -r 168:169 index.xml will output a diff showing the changes between revisions 168 and 169 of index.xml .

add - Adds files, directories, and symlinks, marking them for later inclusion in the repository. Once tagged, they are downloaded and added to the repository the first time the changes are committed. If you added something, but then changed your mind before sticking, then you can remove the add mark with the svn revert subcommand.
svn add PATH…
$ svn add testdir

blame (praise, annotate, ann) - Displays the author and revision line by line for the specified files or URLs. Each line of text begins with the author's name (username) and revision number. Thus, it is indicated who and when changed this line last time.
svn blame TARGET[@REV]…
$ svn blame http://svn.red-bean.com/repos/test/readme.txt

cat - Displays the contents of the specified files or URLs. Use svn list to list the contents of directories.
svn cat TARGET[@REV]...
$ svn cat http://svn.red-bean.com/repos/test/readme.txt

checkout (co) - Creates a working copy based on the data in the repository. If PATH is omitted, the base name of the URL will be used as the name for the working copy directory. If multiple URLs are given, corresponding copies will be made in the PATH subdirectory, each in its own directory formed from the base name of the URL.
svn checkout URL[@REV]…
svn checkout svn://svn.ru2web.ru/ru2web/branches/www-01/ /usr/home/vasia/ru2web.ru/app/

cleanup - Cleans up the working copy recursively, removing locks left over from pending operations. As soon as you encounter a "working copy locked" error, run this subcommand to remove old locks and bring your working copy back to a healthy state.

If for some reason the operation of the svn update command failed due to problems with the running external diff program (for example, something was pressed in it wrong or there was a network failure), you need to specify the –diff3-cmd parameter to allow cleaning the copy to complete all joins using an external diff program. You can also specify a configuration directory with the --config-dir option, but try not to overuse these options.

commit (ci) - Sends the changes you made to the working copy to the repository to be saved there. If you don't use either the --file or --message option, svn will launch an external editor to compose the comment. Read the description of the editor-cmd option in "Config".
svn commit will send all recursively found lock marks to the repository and unlock the resources corresponding to these marks, unless the --no-unlock option was specified. The "search area" is specified by specifying PATH.
svn commit

copy (cp) - Copies a file to the working copy or vault. SRC and DST can be either paths within the working copy or URLs within the repository.
svn copy SRC DST

delete (del, remove, rm) - Remove an item from the working copy or repository.
svn delete PATH…
svn delete url...

diff (di) - Shows the differences between the working copy and the repository.
$ svn diff http://svn.collab.net/repos/svn/trunk/ [email protected] http://svn.collab.net/repos/svn/trunk/ [email protected]

export - Export a pure directory tree (without .svn folders).

help (?, h) - Help.

import - Commit an unversioned file or tree to the repository.
svn import URL

info - Display information about the local or remote element.
svninfo

list (ls) - List of directories in the repository.
svnlist ...]
$ svn list http://svn.red-bean.com/repos/test/support

lock - Lock the working copy in the repository so that no other user can make changes to the given path.
svn lock TARGET…
$ svn lock tree.jpg house.jpg

log - Show log messages.
svnlog
svnlog URL
$ svnlog

merge - Apply differences between two sources.
$ svn merge -r 250:HEAD http://svn.red-bean.com/repos/branches/my-branch

mkdir - Create a directory in a versioned repository.
$ svn mkdir newdir

move (mv, rename, ren) - Move a file or directory.
svn move SRC DST

propdel (pdel, pd) - Remove properties from files, directories, or revisions.
svn propdel PROPNAME
svn propdel PROPNAME --revprop -r REV

propedit (pedit, pe)
propget (pget, pg)
proplist (plist,pl)
propset (pset, ps)

resolved - Remove "conflicts" on the working copy of files or directories.
svn resolved PATH…

revert - Revert all local changes.
$ svn revert myprj.phtml

status (stat, st) - The status of the working copy of the files or directories.
$ svn status wc

switch (sw) - Update the working copy to a different URL.

unlock - Unlock the working copy.

update (up) - Update your working copy.