Game Engine Architecture

(Ben Green) #1
65

can be resolved automatically by the version control system. For example, if
you changed function f() and another programmer changed function g(),
then your edits would have been to a diff erent range of lines in the fi le than
those of the other programmer. In this case, the merge between your changes
and his or her changes will usually resolve automatically without any con-
fl icts. However, if you were both making changes to the same function f(),
then the second programmer to commit his or her changes will need to do a
three-way merge (see Figure 2.8).
For three-way merges to work, the version control server has to be smart
enough to keep track of which version of each fi le you currently have on your
local disk. That way, when you merge the fi les, the system will know which ver-
sion is the base version (the common ancestor, such as version 4 in Figure 2.8).
Subversion permits multiple check-out, and in fact it doesn’t require you
to check out fi les explicitly at all. You simply start editing the fi les locally—all
fi les are writable on your local disk at all times. (By the way, this is one reason
that Subversion doesn’t scale well to large projects, in my opinion. To deter-
mine which fi les you have changed, Subversion must search the entire tree of
source fi les, which can be slow. Version control systems like Perforce, which
explicitly keep track of which fi les you have modifi ed, are usually easier to
work with when dealing with large amounts of code. But for small projects,
Subversion’s approach works just fi ne.)


2.1. Version Control


Foo.cpp (joe_b) Foo.cpp (suzie_q) joe_b and suzie_q both start editing Foo.cpp at
the same time

Foo.cpp (version 4)

Foo.cpp (joe_b) Foo.cpp (version 5) suzie_q commits her changes first

joe_b must now do a 3-way
merge, which involves 2 sets
of diffs:

Foo.cpp (version 6)

Foo.cpp (joe_b) Foo.cpp (version 5)

Foo.cpp (version 4)

Foo.cpp (version 4)

version 4 to his local version

version 4 to version 5

Figure 2.8. Three-way merge due to local edits by two different users.

Free download pdf