@need 3200

@node Implementing Development Policies
@appendix Implementing Development Policies

Different projects have different policies for managing the "main
development path" as distinguished from various kinds of release
(such as candidate releases, experimental releases, and stable
releases).


@code{arch} is flexible enough to allow many such policies to be
implemented in a direct way.  Here are some examples and hints about
using @code{arch}.

@need 3200

@section Milestone/Numbered Versions

One development policy is based on @geindex milestones
@dfn{milestones}.  The team works on
one milestone goal at a time.  When they have just about reached that
milestone, they make @geindex candidate releases
@dfn{candidate releases} of the milestone for people
to test.  After fixing bugs, a @geindex milestone release
@dfn{milestone release} is made.


After several milestones, the milestone release gets a version number,
and becomes a @geindex version release
@dfn{version release}.


Beginning from scratch on the first milestone, the developers create
the first development path -- in which to work on reaching the
first milestone:

@example
@group
     mozilla--devo--1.0
     ------------------
     base-0
     patch-1
     patch-2
     patch-3
     patch-4
@end group
@group
@end group
@end example

After some time, they are ready to make some candidate releases
and enter a bug-fixing cycle.  They'll use tags for that -- making the
bug fixes in the @code{devo} branch:

@example
@group
     mozilla--devo--1.0
     ------------------
     base-0
     patch-1
     patch-2                       mozilla--milestone--1.0
@end group
@group
     patch-3                       -----------------------
@end group
@group
     patch-4 --------------------->base-0 (tag -- 1st release candidate)
     patch-5               .------>patch-1 (tag -- 2nd candidate)
     patch-6 --------------   ---->patch-3 (tag -- 3rd candidate)
     patch-7                 |
     patch-8 ----------------
@end group
@group
@end group
@end example

In the diagram, patches @code{5..8} in the @code{devo} branch are fixes made
based on reports from candidate releases.  We'll suppose that after
@code{patch-8}, the first milestone appears to be stable.  The developers
want to make the milestone release, and begin work on milestone @code{2}:

@example
@group
     mozilla--devo--1.0
     ------------------
     base-0
     patch-1
     patch-2                       mozilla--milestone--1.0
@end group
@group
     patch-3                       -----------------------
     patch-4 --------------------->base-0 (tag -- 1st release candidate)
     patch-5               .------>patch-1 (tag -- 2nd candidate)
     patch-6 --------------   ---->patch-3 (tag -- 2rd candidate)
     patch-7                 |     version-0 (milestone release)
@end group
@group
   --patch-8 ----------------
  |
  |  mozilla--devo--2.0  (development path for the second milestone)
  |  ------------------
   ->base-0 (continuation)
@end group
@group
@end group
@end example

That pattern can continue indefinately, eventually resulting in a
versioned release, (again using tags):

@example
@group
     mozilla--devo--1.0            mozilla-milestone--1.0
     ------------------            ----------------------
     ...
   --patch-N---------------------->...
  |                                version-0 (milestone 1 release)
@end group
@group
  |
  |
  |  mozilla--devo--2.0            mozilla-milestone--2.0
  |  ------------------            ----------------------
  |  ...
@end group
@group
   ->patch-N---------------------->...
  |                                version-0 (milestone 2 release)
  |
  |
  |  mozilla--devo--3.0            mozilla-milestone--3.0
@end group
@group
  |  ------------------            ----------------------
  |  ...
   ->patch-N---------------------->...
  |                                version-0 (milestone 3 release)
  |          ...
@end group
@group
  |
  |  mozilla--devo--10.0           mozilla-milestone--10.0
  |  -------------------           -----------------------
  |  ...
   ->patch-N---------------------->...
@end group
@group
                                 --version-0 (milestone 10 release)
@end group
@group
                                |
                                |  mozilla-1.0
                                |  -----------
                                 ->base-0 (tag)
                                   version-0 (versioned release)
@end group
@group
@end group
@end example

That pattern of @code{arch} usage is very simple because the developers
stay in sync, following a strict cycle of working on a milestone,
making candidate releases and bug-fixing, making a milestone releases
and starting on the next milestone.   Less synchronized development
can be much more complicated, as illustrated in the next example:




@need 3200

@section Even/Odd Versions

Another, more intricate policy is based on version numbers.  Odd
numbered versions are the "leading-edge" of development -- often
unstable, but having the very latest sources.  Even numbered versions
are "stable" -- lagging behind the leading-edge, but containing only
code known to work reasonably well.


The @code{arch} concept of a "continuation version" is ideal for this,
because there is no requirement that a continuation version be a
continuation of the immediately preceeding version.


A series of diagrams can help to illustrate this usage of @code{arch} and
some of the subtleties that can arise.  We'll start with just
the initial leading-edge development path

@example
@group
     linux--0.1
     ----------
     base-0
     patch-1
     patch-2
     patch-3
     patch-4
     version-0
@end group
@group
@end group
@end example

At that point, the developers decide to make the first stable release:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
     patch-3          |
     patch-4          |
     version-0  ------
@end group
@group
@end group
@end example

We can suppose that @code{patch-1} of @code{linux--0.2} is just a quick change
to the top level @code{README} file, and that after that -- the new stable
version is sealed (creating @code{version-0}) and released.  We never
particularly want to merge @code{patch-1} of @code{linux-0.2} back on to the
odd-numbered versions.


Naturally, some bugs are detected in the stable release -- three in
rapid succession.  The developers fix these on the @emph{leading edge}
branch, planning to merge them with the stable tree later:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |
@end group
@group
     patch-4          |
     version-0  ------
     versionfix-1
     versionfix-2
     versionfix-3
@end group
@group
@end group
@end example

They wait a week for some testing to occur.  The bug fixes are looking
ok, so the developers decide to start work on the next leading-edge
version:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |
     patch-4          |
     version-0  ------
     versionfix-1
     versionfix-2
@end group
@group
   --versionfix-3
  |
@end group
@group
  |
  |  linux--0.3
  |  ---------
   ->base-0 (continuation)
     patch-1
@end group
@group
@end group
@end example

Just as the developers are about to merge the bug fixes with the
stable version, one more bug report trickles in.  Fortunately, it's a
trivial bug -- so the developers are confident about making the fix in
the leading edge, but immediately releasing it in the stable version.


Here's a catch, though -- the latest leading edge version
(@code{linux--0.3}) has already diverged from the stable version because of
@code{patch-1}.  The developers definately don't want @code{patch-1} of @code{0.3} in
the the stable @code{0.2} yet, so they fix the newly reported bug in @code{0.1},
then merge all four bug fixes with the stable tree in the usual way.
Meanwhile, separate work also continues on @code{0.3}:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |
     version-0  ------    |
     versionfix-1\        |
     versionfix-2 |-------
@end group
@group
   --versionfix-3 |
  |  versionfix-4/
  |
  |
  |
@end group
@group
  |  linux--0.3
@end group
@group
  |  ---------
   ->base-0 (continuation)
     patch-1
     patch-2
     patch-3
@end group
@group
@end group
@end example

It's worth noting at that point that @code{linux--0.3} is missing a bug-fix
(@code{versionfix-4}) from @code{linux--0.1}:

@example
@group
     % cd ~/wd/linux--0.3
@end group
@group
@end group
@end example
@example
@group
     % larch whats-missing linux--0.1
     versionfix-4
@end group
@group
@end group
@end example

We'll eventually do an update to pick up that bug fix, but first,
let's make the situation more complicated.


Suppose, some mailing lists get wind of @code{patch-3} in @code{linux--0.3}.
Soon @code{Slashdot} and @code{Newsforge} pick up the story.  It turns out that
@code{patch-3} is a very desirable feature and the implementation appears
to be clean and stable.  People are clammering for its appearence in a
stable release, and the developers happen to think it is a good idea.


So, they start the next stable revision:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |     |
     version-0  ------    |     |
     versionfix-1\        |     |
     versionfix-2 |-------      |    linux--0.4
@end group
@group
   --versionfix-3 |             |    ----------
  |  versionfix-4/               --->base-0 (continuation)
  |
  |
  |
@end group
@group
  |  linux--0.3
@end group
@group
  |  ---------
   ->base-0 (continuation)
     patch-1
     patch-2
     patch-3
@end group
@group
@end group
@end example

They only want @code{patch-3} of @code{0.3} for @code{0.4} -- not anything else.
That's a job for @code{replay --exact}:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |     |
     version-0  ------    |     |
     versionfix-1\        |     |
     versionfix-2 |-------      |    linux--0.4
@end group
@group
   --versionfix-3 |             |    ----------
  |  versionfix-4/               --->base-0 (continuation)
  |                               =->patch-1 (replay --exact merge)
  |                              |   version-0
  |                              .
@end group
@group
  |  linux--0.3                  |
  |  ---------                   .
@end group
@group
   ->base-0 (continuation)       |
     patch-1                     .
     patch-2                     |
     patch-3-=--=--=--=--=--=--=-
     ...
@end group
@group
@end group
@end example

After merging the much-desired @code{patch-3} of @code{0.3} into @code{0.4}, the
developers seal @code{0.4} and make the stable release.


Let's suppose that development on @code{0.3} continues for a while.
After some time, the developers decide that @code{0.3} has aquired enough
new features.  They want to do two things: start @code{0.5}, and start
getting the stable @code{0.6} release ready:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |     |
     version-0  ------    |     |
     versionfix-1\        |     |
     versionfix-2 |-------      |    linux--0.4
@end group
@group
   --versionfix-3 |             |    ----------
  |  versionfix-4/               --->base-0 (continuation)
  |                               =->patch-1 (replay --exact merge)
  |                              |   version-0
  |                              .
@end group
@group
  |  linux--0.3                  |
  |  ---------                   .
   ->base-0 (continuation)       |
     patch-1                     .
     patch-2                     |
@end group
@group
     patch-3-=--=--=--=--=--=--=-
     ...                            linux--0.6
   -version-0                       ----------
  |
@end group
@group
  |
  |
  |  linux--0.5
  |  ----------
   ->base-0
@end group
@group
@end group
@end example

Notice that they haven't created the base revision for @code{0.6} yet.
There's a choice here.  They could make @code{0.6} a continuation of @code{0.4},
then merge in all the patches they're missing from @code{0.3}.  On the
other hand, they could make @code{0.6} a continuation of some @code{0.3} and
pick up all those missing patches "the easy way".


But, oops, when someone checks out @code{version-0} from @code{0.3} and runs
@code{whats-missing}, they find out that the @code{0.3} branch never picked up
@code{versionfix-4} from @code{0.1}.  That's easily fixed by updating a @code{0.3}
tree against @code{0.1}, and checking in the resulting merge to @code{0.3}.
The resulting merge is also the revision that will become the base
revision for @code{0.6}:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |     |
     version-0  ------    |     |
     versionfix-1\        |     |
     versionfix-2 |-------      |    linux--0.4
@end group
@group
   --versionfix-3 |             |    ----------
  |  versionfix-4/               --->base-0 (continuation)
  |            |                  =->patch-1 (replay --exact merge)
  |             -----            |   version-0
  |                  |           .
@end group
@group
  |  linux--0.3      |           |
  |  ---------       |           .
   ->base-0 (continuation)       |
     patch-1         |           .
     patch-2         |           |
@end group
@group
     patch-3-=--=--=--=--=--=--=-
     ...             |              linux--0.6
   -version-0        V              ----------
  | versionfix-1 (0.1 update)------>base-0 (continuation)
  |                                 version-0
@end group
@group
  |
@end group
@group
  |  linux--0.5
  |  ----------
   ->base-0
     patch-1
     patch-2
@end group
@group
@end group
@end example

Meanwhile, new work continues on @code{0.5}.


But now, the @code{0.5} tree is in an interesting state.  If a developer
checks out the latest @code{0.5} and asks:

@example
@group
     % larch whats-missing linux--0.1
     linux--0.1--versionfix-4
@end group
@group
@end group
@end example

If the developer asks @code{whats-missing} from @code{0.3}, the answer is:

@example
@group
     % larch whats-missing linux--0.3
     linux--0.3--versionfix-1
@end group
@group
@end group
@end example

If those two patches were unrelated -- there would be no problem:
simply update from both branches and check the result into @code{0.5}.


In fact, though, @code{versionfix-1} from @code{0.3} is really the same change
as @code{versionfix-4} from @code{0.1} (look back at how @code{versionfix-1} was
created).  Let's also suppose that when the fix was merged into @code{0.3},
a slight change had to be made -- to resolve a merge conflict.


So if the developer just blindly updates from @code{0.1}, then from @code{0.3},
the second update will result in new conflicts.  That might not be so
bad if we're only talking about two patches -- but if we were talking
about @code{20} or @code{200}, a lot of needless work would be called for.


Fortunately, @code{arch} can help.  First, the developer gets the latest
@code{0.5} revision:

@example
@group
     % larch get linux--0.5 ~/wd/linux--0.5
@end group
@group
@end group
@end example

Then gets a list of all patches missing from @code{0.1} and @code{0.3}:

@example
@group
     % cd ~/wd/linux--0.5
@end group
@group
@end group
@end example
@example
@group
     % larch whats-missing --full linux--0.1 linux--0.3
     archive@@kernel.org--primary/linux--0.1--versionfix-4
     archive@@kernel.org--primary/linux--0.3--versionfix-1
@end group
@group
@end group
@end example

That list can be piped into the @code{reconcile} tool:

@example
@group
     % ... | larch reconcile
     archive@@kernel.org--primary/linux--0.3--versionfix-1
@end group
@group
@end group
@end example

What happened?  @code{reconcile} figured out that @code{versionfix-1} from
@code{0.3} already includes @code{versionfix-4} from @code{0.1} -- there's no need to
apply both patches.   So @code{patch-plan} reported the list of patches
that @emph{do} need to be applied, and in this case, there's only one.


In a more complicated situation, @code{patch-plan} would print a list of
patches in the order they should be applied.  In general, it will be a
subset of the patches in its input, but applying that subset will have
the same effect as applying all of the patches (but hopefully with
fewer conflicts).


The developer uses @code{larch replay --list} to process that list, finally
winding up with:

@example
@group
     linux--0.1              linux--0.2
     ----------              ----------
     base-0            ----> base-0 (continuation)
     patch-1          |      patch-1
     patch-2          |      version-0
@end group
@group
     patch-3          |    ->versionfix-1 (merge)
     patch-4          |   |     |
     version-0  ------    |     |
     versionfix-1\        |     |
     versionfix-2 |-------      |    linux--0.4
@end group
@group
   --versionfix-3 |             |    ----------
  |  versionfix-4/               --->base-0 (continuation)
  |            |                  =->patch-1 (replay --exact merge)
  |             -----            |   version-0
  |                  |           .
@end group
@group
  |  linux--0.3      |           |
  |  ---------       |           .
   ->base-0 (continuation)       |
     patch-1         |           .
     patch-2         |           |
@end group
@group
     patch-3-=--=--=--=--=--=--=-
     ...             |              linux--0.6
   -version-0        V              ----------
  | versionfix-1 (0.1 update)------>base-0 (continuation)
  |                    |            version-0
@end group
@group
  |                    |
  |  linux--0.5        |
@end group
@group
  |  ----------        |
   ->base-0            |
     patch-1           |
     patch-2           V
     patch-3 (0.1/0.3 reconciliation)
@end group
@group
@end group
@end example

Now if someone gets the latest revision of @code{0.5} and asks:

@example
@group
     % larch whats-missing --full linux--0.1 linux--0.3
     [no output]
@end group
@group
@end group
@end example

Isn't @code{reconcile} handy?







