107
Using TortoiseSVN: A Quick Primer

Tsvn17

Embed Size (px)

DESCRIPTION

TortoiseSVN 1.7 slides

Citation preview

Page 1: Tsvn17

Using TortoiseSVN:A Quick Primer

Page 2: Tsvn17

2

TortoiseSVN

⇨Graphical front end to a Subversion repository— Subversion is a Version Control system

⇨Integrates with Windows Explorer— No separate client application required

⇨All TortoiseSVN functionality present in Windows Explorer's File menu or context menu (obtained by right-clicking within a Windows Explorer window)

Page 3: Tsvn17

3

Infrequent Tasks

⇨Creating a repository— A one-time creation activity, not used often

— Should be created by the repository administrator

— A freshly created repository does not contain any user files

⇨Importing files into a repository— An already existing project that must be placed under version

control must be imported to the repository

⇨Checking out files— Copies files from the repository to a local directory. The

directory stores the working copy

Page 4: Tsvn17

4

Creating Subversion Repositories

Page 5: Tsvn17

5

Creating A Repository-1

The Subversion repository must be created in an empty directory. Right-click anywhere in the Explorer window to obtain the context menu displayed here.

Page 6: Tsvn17

6

Creating A Repository-2

Once the repository is created, it will be maintained by Subversion. Do NOT try to maintain this directory manually. Attempts to create/rename/modify/deletefiles in the repository will corrupt the repository.

Press the |Create folder structure|button to create the default folder structure used by mostprojects, or press |OK| to exit.

Page 7: Tsvn17

7

Populating The Repository With

Existing Non-versioned Files

Page 8: Tsvn17

8

Importing Into A Repository-1

Choose the directory that containsfiles to be placed under versioncontrol. Remove any generated fileslike PDFs, zip or any other archives,prior to this operation. Store only those files that must be versionedin this directory.

Page 9: Tsvn17

9

Importing Into A Repository-2

Specify the URL path to the repository. The URL will provided by the administrator.

Provide an appropriate message here, representing the files being importedinto the repository..

Auto-Properties assigns properties to files. Actual file properties applied depend on properties set by the administrator/developer for various file types.

Commonly a needs-lock property is set for binary files. Do NOT un-check Auto-Properties unless you know what you're doing.

Page 10: Tsvn17

10

Creating A Working Copy From The Subversion Repository

Page 11: Tsvn17

11

Creating A Working Copy-1

Preferably choose an empty directory name within which to extract the working copy.

Page 12: Tsvn17

12

Creating A Working Copy-2

Specify the URL path to the repository. The URL will provided by the administrator.

Specify an empty directory name.

Choose the Revision option only if you need to extract a specific revision from the repository. Usethe |Show Log| button to help determine the revision to extract.

Use Fully Recursive to checkout all files and subdirectoriesrecursively.

Press |Choose items| if you wishto check out only specific directories, instead of the complete directory tree.

Page 13: Tsvn17

13

Creating A Working Copy-3

Pressing |Choose items| displaysthis dialog.Only checked folders will be checkedout.

Page 14: Tsvn17

14

Creating A Working Copy-4

Selected folders are copied from the repository to the working copy.

Page 15: Tsvn17

15

Creating A Working Copy-5

The directory now contains all files extracted from the repository.

Never access the .svn folder.Manually changing the .svn folder can cause a mismatch with the repository, making commits impossible.

All files and directories that areversioned are displayed using an icon overlay – (the greencheck mark within the icon).

Page 16: Tsvn17

16

Daily Usage Cycle

Page 17: Tsvn17

17

Operations For Daily Use

⇨Update the working copy⇨Lock binary files in the working copy

— Text files can also be locked if you need to exclusively work with the file

⇨Edit the files ⇨Commit the changes to the repository

Page 18: Tsvn17

18

Update The Working Copy-1

Page 19: Tsvn17

19

Update The Working Copy-2

Page 20: Tsvn17

20

Lock Files-1

Page 21: Tsvn17

21

Lock Files-2

State why you want to lockthe file(s).

Uncheck filesthat will not be changed in this edit cycle.

Do NOT check thiswithout first consulting the repository administrator.

Page 22: Tsvn17

22

Lock Files-3

Page 23: Tsvn17

23

Edit Files

Edit files using an appropriateapplication. For example,Framemaker for .fm/.book files, OpenOffice for .doc/.xls/.ppt files,or any of your favorite text editors for text files.

Page 24: Tsvn17

24

Commit Files-1

Page 25: Tsvn17

25

Commit Files-2

Specify a suitable log message.

List of changed files. Any new files created are not versioned, since theyare not part of the repository. Checknew files that must be versioned inthis box.

Choose this if you wish to commit files and continue editing the files. Leave this unchecked if the editing work on the filesis complete.

Page 26: Tsvn17

26

⇨Extracting an older version ("Export")⇨Displaying the revision log⇨Releasing a lock⇨Undo changes to the last updated version⇨Rolling back to a previous revision⇨Checking the repository for modifications⇨Viewing the difference between text files⇨Adding/Renaming/Deleting/Moving files in the

repository⇨Ignoring files that should not be stored in the

repository

Common Tasks

Page 27: Tsvn17

27

Extracting An Older Version

Page 28: Tsvn17

28

Exporting An Older Revision-1

Choose an empty directory.

Page 29: Tsvn17

29

If unsure about the required revisionnumber, press the |Show log| button.

Exporting An Older Revision-2

Page 30: Tsvn17

30

Choose the required revision based on the log message, or revision dateor author.

Exporting An Older Revision-3

Page 31: Tsvn17

31

The chosen revision number isfilled in.

Exporting An Older Revision-4

Page 32: Tsvn17

32

Unlike checked-out folders, exported folders do NOT containthe .svn administrative folders. An exported revision is not suitable for modifications.

If you intended to modify the exported revision and commit thechanges to the repository, use thecheckout option instead.

Exporting An Older Revision-5

Page 33: Tsvn17

33

Displaying The Revision Log

Page 34: Tsvn17

34

Displaying Revision Logs-1

This folder must contain a working copy from the repository.

Page 35: Tsvn17

35

Displaying Revision Logs-2

If required, filter log messages displayed by typing a search string.

If required, filter log messages displayed by date using the From and To drop-downs.

Log message for selected revision.

List of files added, or modified, ordeleted in the selected revision.

Page 36: Tsvn17

36

Displaying Revision Logs-3

Filter text applies to log text, author,or filename.

Only logs matching filter displayed.

Matching filter string is shown highlighted.

Page 37: Tsvn17

37

Undoing Changes

(Reverting To The Last Updated Version)

Page 38: Tsvn17

38

Undoing Changes-1

To undo any changes made, use theRevert option. This will revert any changes made after the last Updateoperation.

Page 39: Tsvn17

39

Undoing Changes-2

List of files modified since the last Update operation.

All checked files will be reverted. To prevent a modified file from losing itschanges, un-check the box precedingthe file name.

Page 40: Tsvn17

40

Undoing Changes-3

Page 41: Tsvn17

41

Releasing Locks

Page 42: Tsvn17

42

Releasing Locks-1

Choose the Release lock optionfor files that are locked but that willnot be edited prior to the commit. That is, these files are not subject to changes for this revision.

Page 43: Tsvn17

43

Releasing Locks-2

The icon overlay changes to grayfor unlocked files.

Page 44: Tsvn17

44

Rolling Files Back To An Older Revision

Page 45: Tsvn17

45

Rolling A File Back To An Earlier Revision -1

Display the log windowusing Show log.

Right-click the file that you needto roll back to a previous version.

Page 46: Tsvn17

46

1. Right-click the required version.

2. Select Revert to this revision.

Rolling A File Back To An Earlier Revision -2

Page 47: Tsvn17

47

Rolling A File Back To An Earlier Revision -3

Page 48: Tsvn17

48

If the file was rolled back erroneously, use the Revert procedure described earlier to revertthe file back to the state prior to the roll back.

Rolling A File Back To An Earlier Revision -4

Page 49: Tsvn17

49

Rolling A Directory Back To An Older Revision

Page 50: Tsvn17

50

Display the log windowusing Show log.

Rolling A Directory Back To An Earlier Revision -1

Right-click the directory you need to roll back.

Page 51: Tsvn17

51

Rolling A Directory Back To An Earlier Revision -2

1. Right-click the required version.

2. Select Revert to this revision.

Page 52: Tsvn17

52

!WARNING!========When reverting the complete working directory to older revisions, files that didnot exist in older revisions will be deleted.Recover these files using the procedure toRevert changes as described earlier.

Rolling A Directory Back To An Earlier Revision -3

Page 53: Tsvn17

53

Checking For Modifications

Page 54: Tsvn17

54

Checking For Modifications-1

Check for modifications against thecurrent version and the last updatedrevision (also called working base).

Page 55: Tsvn17

55

Checking For Modifications-2

List of files in the working copy that differ from the files in the working base.

Use this button to check the files in the working copywhich differ from those in the repository. This is a slow operation if you have too many files in the repository.

Page 56: Tsvn17

56

Viewing Version Differences

Between Text Files

Page 57: Tsvn17

57

Viewing Version Differences-1

Page 58: Tsvn17

58

Viewing Version Differences-2

Page 59: Tsvn17

59

Viewing Version Differences

Between Specific Revisions

Page 60: Tsvn17

60

Viewing Version Differences Between Specific Revisions-1

Page 61: Tsvn17

61

To compare revision 245 and 190, control click the revisions, right-click and choose Compare revisions.

Viewing Version Differences Between Specific Revisions-2

Page 62: Tsvn17

62

Lists all files that differ across the selected revisions.Right-click any file and choose Compare revisions toview the difference between the two files. (This will not work if the file is a binary file)

Viewing Version Differences Between Specific Revisions-3

Page 63: Tsvn17

63

Viewing Version Differences Between Specific Revisions-4

Page 64: Tsvn17

64

Adding New Files To The Repository

Page 65: Tsvn17

65

Adding New Files-1

New files or folders are not automatically added.Explictly add new folders and files.

Page 66: Tsvn17

66

Adding New Files-2

Lists files and directories present in the working copy which do not exist in the repository.

Page 67: Tsvn17

67

Adding Files Outside The Working Copy

Page 68: Tsvn17

68

Adding Files Outside The Working copy

⇨To add files from outside your working copy you can use the drag-and-drop handler:— Select the files you want to add

— Right-drag them to the new location inside the working copy

— Release the right mouse button

— Select the context menu option: SVN Copy and Add files to this WCThe files will then be copied to the working copy and added to version control.

Page 69: Tsvn17

69

Renaming and Deleting Files Under Version Control

Page 70: Tsvn17

70

Renaming Objects Under Version Control

Always rename objects under version controlusing the Rename option. Do NOT directlyrename the object using Windows Explorer.

Page 71: Tsvn17

71

Deleting Objects Under Version Control

Always delete objects under version controlusing the Delete option. Do NOT directlydelete the object using Windows Explorer.

Page 72: Tsvn17

72

Moving Objects Within The Repository

⇨To move files inside a working copy, use the drag-and-drop handler again:— Select the files or directories you want to move

— Right-drag them to the new location inside the working copy

— Release the right mouse button

— In the popup menu select SVN Move Versioned Items Here

Page 73: Tsvn17

73

Rename/Move/Delete Procedure

⇨Best way to Rename/Move/Delete files/dirs— Commit all changes

— Release all locks (if any remain after the commit)

— SVN Update

— Verify no locks are held on objects to be renamed/moved/deleted using the Check for modifications dialog to check the repository status

— SVN Rename/Move/Delete

— SVN Commit preferably from the top level folder

— SVN Update

Page 74: Tsvn17

74

Adding Files/Directories To An Ignore List (Method 1)

Page 75: Tsvn17

75

Files added to an Ignore list for the projectare ignored during a commit operation.Use this method for add either individual files or directories to the Ignore list, or groupsof files based on a wildcard value (Like *.bakas shown in the figure).

Adding Files To An Ignore List

Page 76: Tsvn17

76

Adding Files/Directories To An

Ignore List (Method 2)

Page 77: Tsvn17

77

Adding Files/Directories To An Ignore List-1

⇨Right-click the directory containing the files/directories to be ignored for version control

⇨Choose Properties⇨Choose the Subversion Tab

Page 78: Tsvn17

78

Adding Files/Directories To An Ignore List-2

Choose the Subversion tab from the Folder Properties dialog.

Press the |Properties| button.

Page 79: Tsvn17

79

Adding Files/Directories To An Ignore List-3

Press the |New| button.

Page 80: Tsvn17

80

Adding Files/Directories To An Ignore List-4

Choose the Advanced option

Page 81: Tsvn17

81

Adding Files/Directories To An Ignore List-5

Enter the list of files and directories to ignore. Ideally thesefiles/directories are generated automatically using either an editoror some kind of build process.

Choose this at the top-level working directory. Alternately, explicitly set the ignore list for every folder within the working directory.

Page 82: Tsvn17

82

Adding Files/Directories To An Ignore List-6

List of properties that will beset for the folder after pressing the|OK| button

Page 83: Tsvn17

83

Including A Common Sub-project

Page 84: Tsvn17

84

Including A Common Sub-project -1

⇨A folder checked into a Subversion repository may need to be referenced elsewhere— within the same project, or

— within a different project on the same Subversion server

— within a different project on some other Subversion server

⇨These folders can be referenced making use of the svn:externals property— svn:externals property syntax:

⊗ folder [-r revision_number] svn_repository_url

— A subsequent checkout or update automatically creates folder whose contents are obtained from svn_repository_url

Page 85: Tsvn17

85

Including A Common Sub-project -2

⇨Example:— A web-site project stored at the repository URL

http://svnserve/www_pages/ needs to access graphic files available in the repository URL http://svnserve/corp/graphics/ ⊗ To resolve: set the svn:externals property for the www_pages

folder as: http://svnserve/corp/graphics/ graphics

— An application project stored at the repository URL http://svnapps/gendoc/ needs to access templates from revision 103 of the repository http://svnserve/corp/templates ⊗ To resolve: set the svn:externals property for the gendoc folder as:

-r 103 http://svnserve/corp/templates templates

Page 86: Tsvn17

86

Setting svn:externals using TSVN-1

Choose the Subversion tab from the folder property sheet of a folder in the working copy.

Choose the |Properties| button to set the svn:externals property on the working copy folder.

Page 87: Tsvn17

87

Setting svn:externals using TSVN-2

Press the |New| button.

Page 88: Tsvn17

88

Setting svn:externals using TSVN-3

Choose the Externals option.

Page 89: Tsvn17

89

Setting svn:externals using TSVN-4

Type in the folder name to create. In this example, a folder called graphics will be created in the working copy. It's contents are updated based on the contents of the repository URL specified(http://stdoc-web01/.../master/graphics)

Page 90: Tsvn17

90

Setting svn:externals using TSVN-5

The svn:externals property is now set. However it will take effect only on a subsequent SVN Update.

Page 91: Tsvn17

91

Tagging/Branching

A Subversion Repository

Page 92: Tsvn17

92

Tagging/Branching A Subversion Repository

⇨Subversion repository root usually contains:— /trunk/

— /branches/

— /tags/

⇨Use the Subversion copy command to branch/tag the current or main branch— Copy to the /branches/ directory of a repository to create a branch

— Copy to the /tags/ directory of a repository to create a tag

⇨Branched/tagged versions accessible — by checking out the repository with /tag/, or /branch/ as part of the

URL

— by using the Subversion switch command to switch the working copy to/from /trunk/ to /branches/.../ or /tags/.../

Page 93: Tsvn17

93

Tagging/Branching A Subversion Repository

⇨Subversion repository root usually contains:— /trunk/

— /branches/

— /tags/

⇨Use the Subversion copy command to branch/tag the current or main branch— Copy to the /branches/ directory of a repository to create a branch

— Copy to the /tags/ directory of a repository to create a tag

⇨Branched/tagged versions accessible — by checking out the repository with /tag/, or /branch/ as part of the

URL

— by using the Subversion switch command to switch the working copy to/from /trunk/ to /branches/.../ or /tags/.../

Page 94: Tsvn17

94

Branching A Subversion Repository Using TSVN-1

Choose the Branch/tag option from the TortoiseSVN menu after right-clicking the folder to be branched.

Page 95: Tsvn17

95

Branching A Subversion Repository Using TSVN-2

Current repository URL.

URL of new branch. This branch must NOT already exist.

Provide a log message for thebranch/tag.

Check this option to automaticallyswitch the current working copy to thenewly created branch.

Page 96: Tsvn17

96

Branching A Subversion Repository Using TSVN-3

Revision number will beincremented by 1 after the branchis created.

Page 97: Tsvn17

97

Conflict Handling

Page 98: Tsvn17

98

Conflicts

⇨Two types— File conflict

— Tree conflict

Page 99: Tsvn17

99

File Conflict-1

⇨Alice modifies file from revision 32— Text file relnotes-10.2.sth, lines 10-16

— Text file relnotes-10.1.sth, lines 34-40

— Binary file releasenotes.fm

⇨Bob modifies file from revision 32— Text file relnotes-10.2.sth, lines 15-17

— Text file relnotes-10.1.sth, lines 10-19, 20-27, 45-48

— Binary file releasenotes.fm

⇨Alice commits changes resulting in revision 33⇨Bob gets an error on committing. (Working copy

for Bob is rev 32, but latest repository revision for these files is rev 33— Bob must therefore run SVN Update

Page 100: Tsvn17

100

File Conflict-2

⇨Bob runs SVN Update to update the working copy to r33— Alice's changes to relnotes-10.1.sth merge with Bob's

changes successfully.

— Alice's changes to relnotes-10.2.sth and releasenotes.fm conflict with Bob's changes.⊗ Subversion detects text file conflicts and creates

• relnotes-10.2.sth, containing conflict markers)

• relnotes-10.2.mine.sth (this is relnotes-10.2.sth with Bob's changes)

• relnotes-10.2.r32.txt (the original file before any changes)

• relnotes-10.2.r33.txt (this is relnotes-10.2.sth with Alice's changes)

⊗ Subversion detects binary file conflicts and creates

• releasenotes.r32.fm (Original file before any changes)

• releasenotes.r33.fm (this is releasenotes.fm after Alice's changes)

• releasenotes.fm containing Bob's changes is not affected unlike text files. (No concept of .mine for binary files)

Page 101: Tsvn17

101

File Conflict-3

⇨To resolve the conflict:— Compare relnotes-10.2.r33.sth and relnotes-10.2.mine.sth for

changes. Use a guideline to edit relnotes-10.2.sth suitably, removing conflict markers (lines containing <<<<< and >>>>>)

— Compare releasenotes.r33.fm and releasenotes.fm (FrameMaker's File>Utilities>Compare Documents...) and fix releasnotes.fm

— Choose SVN Resolve from the TortoiseSVN menu⊗ relnotes-10.2.r32.sth, relnotes-10.2.r33.sth, relnotes-10.2.mine.sth,

releasenotes.r33.fm, releasenotes.r32.fm will be automatically deleted on resolution

— SVN Commit

Page 102: Tsvn17

102

Tree Conflicts-1

⇨Tree conflict— Different users work with the same set of files and directories,

creating incompatible new tree structures

⇨Tree conflicts arise when the directory structure is changed by one or more users— One user deletes, the other user renames

— One user deletes, the other user modifies

— One user modifies, the other user renames

— One user deletes, the other user copies

— One user renames, the other user renames to something else

— ...

Page 103: Tsvn17

103

Tree Conflicts-2

⇨Tree conflict resolution— Determine the cause

⊗ Right-click the conflicted directory, select svn edit conflicts

— To resolve:⊗ Discard your changes and accept the other users directory changes

⊗ Alternately, communicate with the other user, and accept and commit your changes after arriving at a consensus. Do NOT do this without first communicating your intent with the user who caused the tree conflict.

Page 104: Tsvn17

104

Best Practices-1

⇨Commit should be at a directory level— AVOID commits on files. Stop thinking in terms of files!

⇨Commit from a parent folder that includes all folders affected by a move operation— AVOID committing individual folders affected by a move. This will

mess up the repository for yourself and possibly other users.

⇨Release locks before svn rename/move/delete operations

⇨Treat file content changes and directory changes as mutually exclusive for a commit operation.— File content change => commit

— Dir change (rename/move/delete) ==> commit

— File content + Dir change => Not a good idea

Page 105: Tsvn17

105

Best Practices-2

⇨Commit after finishing a task— Adjust the commits to the content of your work, not to the work

time (every midday, every evening, etc.)

⇨Communicate with each other after a conflict⇨Close files in a working copy before running svn

commit or svn update— Not doing so can cause possible data loss!

Page 106: Tsvn17

106

Best Practices-3

⇨AVOID Committing open files⇨AVOID Updating a working copy containing opened

files⇨AVOID Checkout at root level

— No need of branches, tags, and trunk in working copy

⇨AVOID Commits on or within tags/ folder⇨AVOID Locks in different working copies for the same

repository location— Eg: Working copy on a home PC as well as on the office PC.

⇨AVOID Empty commit messages⇨AVOID Commits which include directory modifications

as well as file modifications

Page 107: Tsvn17

107

Need More Detailed Info? Read the TortoiseSVN manual - http://tghyara-pc.idc.oracle.com/~tghyara/sw/dev/subversion/docs/TortoiseSVN_en.pdf