apache subversion™ tutorial -...

25
Apache Subversion™ Tutorial Diana Machado Raul Garcia Dr. Shu-Ching Chen Florida International University – Computer Science Computer Science Standard C-6.C 2/22/2014

Upload: phamdien

Post on 02-Apr-2018

231 views

Category:

Documents


2 download

TRANSCRIPT

Apache Subversion™ Tutorial

Diana Machado Raul Garcia

Dr. Shu-Ching Chen Florida International University – Computer Science

Computer Science Standard C-6.C

2/22/2014

What is Subversion (SVN)? �  A free and open source version control system (VCS)

(i.e., a piece of software to manage files and the changes made to them over time).

�  Like a “time machine” that helps users �  Build a central storehouse of versioned data.

�  Keep track of the changes made to files. �  Examine lifecycle of individual files. �  Avoid data loss (work is versioned and changes can

be undone).

2

What SVN is not

�  It is not a generic distribution system, i.e., it is not to be used to merely share data (e.g., photos, digital music, software packages) among people.

�  data collection grows over time, but individual files usually remain unchanged.

3

Three Important Concepts �  Repository

�  A central database which contains all the version-controlled files with their complete history.

�  Normally resides on a server running the Subversion server program, which supplies content to Subversion clients on request.

�  Working copy �  A local copy of a particular version of a user's VCS-

managed data. �  Allows users to begin working on the data in a versioned

fashion. �  Metadata stored in administrative directory (.svn) to

manage the working copy.

�  Revision �  A particular state of the entire repository identified by a

natural number. �  Each commit creates a new state (revision). 4

Most Common Operations - I Files in the working copy can be edited at will, but users must tell SVN of everything else that is done (use client-provided commands instead of OS-provided commands).

�  Checkout: create a working copy.

�  Commit: publish local changes to the repository.

�  Update: integrate public changes into the working copy.

�  Add: schedule a file for addition in the next commit.

�  Delete: schedule a file for deletion in the next commit.

5

Most Common Operations - II �  Import: import a directory hierarchy into the repository.

Does not create a working copy.

�  Export: create a non-versioned copy of the working copy or repository.

�  Copy, Move, Rename files.

�  Revert changes: discard all changes up to last update.

�  Roll back to a specific revision.

6

Basic Work Cycle 1.  Update working copy

�  Bring your working copy into sync with the latest revision in the repository.

2.  Make local changes �  Usually file edits, but sometimes tree changes.

3.  Review local changes �  Examine both overall changes and the details of the changes.

4.  Fix mistakes �  Discard all changes (start from scratch may be easier).

5.  Merge others’ changes �  May involve resolving conflicts.

6.  Commit your changes �  Make changes available to others.

7

States of a Working File �  Unchanged and current

�  A commit of the file will do nothing. �  An update of the file will do nothing.

�  Locally changed and current �  A commit of the file will publish the changes. �  An update of the file will do nothing.

�  Unchanged and out of date �  A commit of the file will do nothing. �  An update of the file will incorporate the latest changes.

�  Locally changed and out of date �  A commit fails with an “out-of-date” error. The file should

be updated first. �  An update will attempt to merge both the public and local

changes.

8

The FPHLM Repository �  Repository URL: svn://king.cs.fiu.edu/fphlm/

�  Under this path, there is one directory for each team: act/, cs/, eng/, met/, stat/.

�  Under each team's directory, there are two directories: common and private. E.g.,

|eng/ |--------- common/ |--------- private/

�  common directory accessible to all other teams.

�  private directory accessible to only the corresponding team members.

�  In all cases, access allowed only to authenticated users.

9

SVN Client �  An SVN client allows users to interact with the

Subversion repository.

�  There are GUI clients and command-line clients (less user friendly)

�  One of the most popular clients: TortoiseSVN �  Developed for Windows operating system. �  Provides easy access to most common operations. �  It is a shell extension, i.e., it integrates into the

Windows Explorer application.

10

Installing TortoiseSVN

1.  Download installer from here �  Choose either 32-bit or 64-bit OS version.

2.  Double-click the installer to run it.

3.  Follow the instructions of the Setup Wizard �  Always “Next”, then “Install.”

4.  Reboot.

11

“Configuring” TortoiseSVN* 1.  Open Windows Explorer and create a directory,

e.g., fphlm_svn (the working copy).

2.  Right click on it and select “Checkout.” Repository URL: ���svn://king.cs.fiu.edu/fphlm/<team>/

where <team> is one of {cs, eng, act, stat, met}

3.  Enter the username and password.

4.  Check the “Save Authentication” checkbox.

5.  Click “OK.”

*Internet connection necessary.

12

Meaning of Some Status Icons

13

Icon Meaning

Normal status. Local copy in sync with repository.

Modified status. Local copy has been changed since the last update and changes need to be committed.

Conflict status. There is a conflict between the local copy of a file and the copy of the file in the repository during an update. A file conflict occurs when two (or more) users have changed the same few lines of a file.

Scheduled deletion status. Some files inside the current folder have been scheduled to be deleted from version control, or a file under version control is missing in a folder.

Scheduled addition status. A file or folder has been scheduled to be added to version control.

Non-versioned status. It shows files and folders that are not under version control and are not ignored.

Using TortoiseSVN - I �  Commit a local change to the repository

1.  Right click on modified file.

2.  Select “SVN Commit.” 3.  Enter a descriptive message.*

4.  Verify that file to be committed is selected. 5.  Click “OK.”

*Messages help keep track of the rationale of the changes. They are required to meet the C-6 CS Standard.

14

Using TortoiseSVN - II �  Sync the working copy with the repository

�  Right click on file/directory to be updated.

�  Select “SVN Update.”

- Now all files in working copy are at the revision number the repository is at the time of the update.

- An update may result in conflicts that need to be resolved manually as SVN knows nothing of the project.

15

Using TortoiseSVN - III �  Solve a file conflict

�  Right click on file marked with the conflict status.

�  Select “TortoiseSVN.” �  Select “Edit conflicts” to launch the built-in merge

tool TortoiseMerge. �  Do any necessary changes and save them.

�  “Theirs” file (top left): file as it is in the repository.

�  “Mine” file (top right): local file with your latest changes.

�  “Merged” file (bottom): file with the conflict resolved.

�  Mark conflict as resolved.

�  Commit changes.

16

Using TortoiseSVN - IV �  Delete a file from version control

�  Right click on a file in the working copy.

�  Select “TortoiseSVN” --> “Delete” The file has been scheduled to be deleted in the next commit.

�  Add a file to version control �  Create a file in the working copy. �  Right click on the file.

�  Select “TortoiseSVN” --> “Add” The file has been scheduled to be added in the next commit.

17

Using TortoiseSVN - V �  Import a directory tree into the repository

�  Right click on directory --> “TortoiseSVN” �  Select “Import” �  Specify destination directory. �  Enter a descriptive message.

�  Export a working tree directly from the repository �  Right click anywhere on working copy �  Select “TortoiseSVN” --> “Repo-browser” �  Navigate to file/directory. Right click on it -->

“Export” �  Browse to export directory �  Click “OK”

18

Using TortoiseSVN - VI �  Copy/Move a versioned file

�  Standard Windows copy/cut of the file.

�  Select “TortoiseSVN” --> “Paste”

�  Rename a versioned file �  Right click on the file

�  Select “TortoiseSVN” --> “Rename”

19

Using TortoiseSVN - VII �  Review the history of a versioned file

�  Right click on the file.

�  Select “Properties” --> “Subversion” tab --> “Show log”

�  Review the working copy and remote modifications �  Right click on the working copy directory �  Select “TortoiseSVN” --> “Check for modifications” �  Click on “Check repository” button to fetch the

remote status.

20

Using TortoiseSVN - VIII �  Examine the local changes of a file in detail

�  Right click on the file.

�  Select “TortoiseSVN” --> “Diff” (with respect to the base revision)

�  Discard all local changes made to a file �  Right click on the file �  Select “TortoiseSVN” --> “Check for modifications” �  Right click on the file --> “Revert”

21

Using TortoiseSVN - IX �  Compare two revisions of a file

�  Right click anywhere in working copy. �  Select “TortoiseSVN” --> “Show log” to display the list

of revisions of the file. �  Select the two revisions (Hold down CTRL key) �  Right click on one of them --> “Compare revisions”

�  Roll back to a previous revision �  Right click on top level directory. �  Select “TortoiseSVN” --> “Show log” �  Right click on target revision --> “Revert to this

revision”

22

Using TortoiseSVN - X �  A tag is a snapshot of a project in time.

�  Concept intrinsic to a version control system since each revision is a snapshot of the file system after each commit.

�  Tags are used to mark a particular revision and are given user-friendly names.

�  For SVN, a tag is just an ordinary directory. A directory is a tag because users have decided to treat it that way (no user should ever commit to it).

23

Using TortoiseSVN - XI �  Create a tag

�  Right click on directory in working copy.

�  Select “TortoiseSVN” --> “Branch/Tag” �  Select destination path (include name of tag).

�  Enter descriptive message. �  Choose the tag source:

�  Head revision in repository (latest revision in repository)

�  Specific revision in repository

�  Working copy

�  Click “OK.”

24

References �  Version Control with Subversion (free book)

�  http://svnbook.red-bean.com/en/1.7/svn-book.pdf

�  TortoiseSVN (a Subversion client for Windows) �  Can be downloaded from here

�  TortoiseSVN User’s Guide �  http://tortoisesvn.net/docs/release/TortoiseSVN_en/

index.html

�  TortoiseSVN FAQ �  http://tortoisesvn.tigris.org/faq.html#ovllostonupgrade

25