PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION

You may wish to know which files have changed before you incorporate differences locally. You can
do this with the status subcommand.


$ svn status --show-updates


That gives you a list of files that an update would touch locally.
Whichever subcommand I chose, I can now go ahead and commit my changes:


$ svn commit quizobjects/User.php -m 'added doc level comment'


Sending quizobjects/User.php
Transmitting file data.


I use the commit subcommand to check new data into the Subversion repository. Notice that I used
the -m switch to add a message on the command line, rather than via an editor.
Now it’s Bob’s turn to update and commit:


$ svn update quizobjects/User.php


Conflict discovered in 'quizobjects/User.php'.
Select: (p) postpone, (df) diff-full, (e) edit,
(mc) mine-conflict, (tc) theirs-conflict,
(s) show all options:


Subversion will happily merge data from two sources into to the same file so long as the changes
don’t overlap. Subversion has no means of handling changes that affect the same lines. How can it
decide what is to have priority? Should the repository overwrite Bob’s changes, or the other way around?
Should both changes coexist? Which should go first? Subversion has no choice but to report a conflict
and let Bob sort out the problem. When a conflict is encountered, Bob is presented with a bewildering
seeming array of options. In Subversion itself explains the choices. If Bob hits 's'


(s) show all options: s
(e) edit - change merged file in an editor
(df) diff-full - show all changes made to merged file
(r) resolved - accept merged version of file
(dc) display-conflict - show all conflicts (ignoring merged version)
(mc) mine-conflict - accept my version for all conflicts (same)
(tc) theirs-conflict - accept their version for all conflicts (same)
(mf) mine-full - accept my version of entire file (even non-conflicts)
(tf) theirs-full - accept their version of entire file (same)
(p) postpone - mark the conflict to be resolved later
(l) launch - launch external tool to resolve conflict
(s) show all - show this list


When you get a conflict, probably the first thing you’ll want to do is to find out what’s happened.
The dc option will tell you. It shows the conflicting portions of the file in question. Here’s what Bob sees
when he selects dc:<?php

Free download pdf