04.08.2013 Views

Version Control with Subversion - Electrical and Computer ...

Version Control with Subversion - Electrical and Computer ...

Version Control with Subversion - Electrical and Computer ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3 You can always remove the temporary files yourself, but would you really want to do that when <strong>Subversion</strong> can do it for you? We didn't think<br />

so.<br />

Here OLDREV is the revision number of the file in your .svn directory <strong>and</strong> NEWREV is the revision<br />

number of the repository HEAD.<br />

For example, Sally makes changes to the file s<strong>and</strong>wich.txt in the repository. Harry has just changed<br />

the file in his working copy <strong>and</strong> checked it in. Sally updates her working copy before checking in <strong>and</strong><br />

she gets a conflict:<br />

$ svn update<br />

C s<strong>and</strong>wich.txt<br />

Updated to revision 2.<br />

$ ls -1<br />

s<strong>and</strong>wich.txt<br />

s<strong>and</strong>wich.txt.mine<br />

s<strong>and</strong>wich.txt.r1<br />

s<strong>and</strong>wich.txt.r2<br />

At this point, <strong>Subversion</strong> will not allow you to commit the file s<strong>and</strong>wich.txt until the three temporary<br />

files are removed.<br />

$ svn commit --message "Add a few more things"<br />

svn: Commit failed (details follow):<br />

svn: Aborting commit: '/home/sally/svn-work/s<strong>and</strong>wich.txt' remains in conflict<br />

If you get a conflict, you need to do one of three things:<br />

• Merge the conflicted text “by h<strong>and</strong>” (by examining <strong>and</strong> editing the conflict markers <strong>with</strong>in the file).<br />

• Copy one of the temporary files on top of your working file.<br />

• Run svn revert to throw away all of your local changes.<br />

Once you've resolved the conflict, you need to let <strong>Subversion</strong> know by running svn resolved. This removes<br />

the three temporary files <strong>and</strong> <strong>Subversion</strong> no longer considers the file to be in a state of conflict. 3<br />

$ svn resolved s<strong>and</strong>wich.txt<br />

Resolved conflicted state of 's<strong>and</strong>wich.txt'<br />

Merging Conflicts by H<strong>and</strong><br />

Guided Tour<br />

Merging conflicts by h<strong>and</strong> can be quite intimidating the first time you attempt it, but <strong>with</strong> a little practice,<br />

it can become as easy as falling off a bike.<br />

Here's an example. Due to a miscommunication, you <strong>and</strong> Sally, your collaborator, both edit the file<br />

s<strong>and</strong>wich.txt at the same time. Sally commits her changes, <strong>and</strong> when you go to update your working<br />

copy, you get a conflict <strong>and</strong> we're going to have to edit s<strong>and</strong>wich.txt to resolve the conflicts.<br />

First, let's take a look at the file:<br />

34

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!