changeset 252:f73da41a4f51

Vendor branches in Mercurial
author Martin Geisler <mg@lazybytes.net>
date Sun, 21 Nov 2010 21:22:08 +0100
parents f5274e700a8d
children 6839cd949165
files mercurial-vendor-branches.tex merge-details.tex merging-vendor-branches.tex vendor-branches.tex
diffstat 4 files changed, 125 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/mercurial-vendor-branches.tex
@@ -0,0 +1,38 @@
+\begin{frame}{Vendor Branches in Mercurial}
+  High-level view of vendor branches:
+  \begin{center}
+    \begin{tikzpicture}[start chain]
+      \path[use as bounding box] (-2, 0) rectangle (8.5, 1);
+      \tikzstyle{rev}+=[on chain, minimum size=4mm]
+      \tikzstyle{libfoo}=[rev, draw=purple!50!black!50, top
+        color=white, bottom color=purple!50!black!20]
+      \tikzset{node distance=8mm and 10mm, on grid}
+      \tikzstyle{join-se}=[out=0, in=90]
+      \tikzstyle{join-ne}=[out=90, in=180]
+
+      \node<1->[left=of chain-1, anchor=west, xshift=-1cm] {default:};
+      \node<1->[rev, join] {};
+      \node<1->[rev, join] (a) {};
+      \node<2->[libfoo, join=with a by join-ne, above right=of a] (v1) {};
+      %\draw<2->[thick] (v1.north) -- +(0, 0.2) node[tag,above] {libfoo 1.0};
+
+      \node<2->[above left=of chain-1, anchor=west, xshift=-1cm] {libfoo:};
+      \node<3->[rev, join=by join-se, join=with a, below right=of v1] {};
+      \node<4->[rev, join] {};
+      \node<5->[rev, join] (b) {};
+      \node<6->[libfoo, join=with v1, above right=of b] (v2) {};
+      %\draw<6->[thick] (v2.north) -- +(0, 0.2) node[tag,above] {libfoo 2.0};
+      \node<7->[rev, join=by join-se, join=with b, below right=of v2] {};
+      \node<8->[rev, join] {};
+    \end{tikzpicture}
+  \end{center}
+
+  \onslide<9->
+
+  This workflow lets you:
+  \begin{itemize}
+  \item clearly distinguish between upstream code and your code
+  \item directly modify libraries in your codebase
+  \item<10-> Mercurial knows exactly what to merge
+  \end{itemize}
+\end{frame}
new file mode 100644
--- /dev/null
+++ b/merge-details.tex
@@ -0,0 +1,35 @@
+\begin{frame}{What Happens in a Merge?}
+  Or: Why does distributed revision control work?
+  \begin{center}
+    \begin{tikzpicture}[start chain]
+      \path (-0.5, -2.5) rectangle (8.5, 2.5); % extend bounding box
+
+      \tikzstyle{comment}=[text width=2cm, text badly centered, alert, inner sep=0]
+      \tikzstyle{rev}+=[on chain, minimum size=6mm]
+      \tikzset{node distance=10mm and 20mm, on grid}
+      \tikzstyle{join-se}=[out=0, in=180]
+      \tikzstyle{join-ne}=[out=0, in=180]
+
+      \node[rev, join] {};
+      \node[rev, join] (a) {};
+
+      \node[rev, join] (x) {};
+      \node[rev, join] (y) {};
+
+      \node<2->[rev, above right=of a] (r) {};
+      \node<2->[rev, join] (s) {};
+      \draw<2->[->] ([yshift=0.5mm] a.east) to[join-se] (r);
+
+      \draw<3->[short, ->] (y) ++ (0, -1) node[comment, below] {local head} -- (y);
+      \draw<4->[short, ->] (s) ++ (0, +1) node[comment, above] {remote head} -- (s);
+      \draw<5->[short, ->] (a) ++ (0, -1) node[comment, below] {common ancestor} -- (a);
+
+      \node<6->[rev, join=with y, right=of y] (b) {};
+      \draw<6->[->] (s) to[join-ne] ([yshift=0.5mm] b.west);
+
+      \path<7-> (a) -- node[xshift=-8pt, yshift=8pt] {$\Delta_1$} (r);
+      \path<7-> (r) -- node[above] {$\Delta_2$} (s);
+      \path<8-> (y) -- node[below] {$\Delta_1 + \Delta_2$} (b);
+    \end{tikzpicture}
+  \end{center}
+\end{frame}
new file mode 100644
--- /dev/null
+++ b/merging-vendor-branches.tex
@@ -0,0 +1,47 @@
+\begin{frame}{Merging Vendor Branches}
+  Upgrading from \ext{libfoo} version 1.0 to version 2.0:
+  \begin{center}
+    \begin{tikzpicture}[start chain]
+      \path[use as bounding box] (-2, -0.1) rectangle (7.5, 2.2);
+
+      \tikzstyle{comment}=[text width=2cm, text badly centered, alert, inner sep=0]
+      \tikzstyle{rev}+=[on chain, minimum size=4mm, font=\scriptsize]
+      \tikzstyle{libfoo}=[rev, draw=purple!50!black!50, top
+        color=white, bottom color=purple!50!black!20]
+      \tikzset{node distance=8mm and 14mm, on grid}
+      \tikzstyle{join-se}=[out=0, in=180]
+      \tikzstyle{join-ne}=[out=0, in=180]
+
+      \node[left=of chain-1, anchor=west, xshift=-5mm] {default:};
+      \node[above left=of chain-1, anchor=west, xshift=-5mm] {libfoo:};
+      \node[on chain] {\dots};
+      \node[rev, join] (a) {};
+      \node[rev, join] (b) {};
+      \node[rev, join] (c) {};
+      \node[rev, join] (d) {};
+      \node<8->[rev, join] (e) {};
+
+      \node[on chain, above=of chain-1] {\dots};
+      \node[libfoo, join, above=of a] (v1) {1.0};
+      \node<4->[libfoo, join, above=of d] (v2) {2.0};
+
+      \draw[->] ([yshift=-0.5mm] v1.east) to[join-se] ([yshift=0.5mm] b.west);
+      \draw<8->[->] (v2) to[join-se] ([yshift=0.5mm] e.west);
+
+      \draw<6->[short, ->] (d) ++ (0, -8mm) node[comment, below] {local head} -- (d);
+      \draw<6->[short, ->] (v2) ++ (0, 8mm) node[comment, above] {remote head} -- (v2);
+      \draw<6->[short, ->] (v1) ++ (0, 8mm) node[comment, above] {common ancestor} -- (v1);
+      \path<7-> (v1) -- node[above] {$\Delta$} (v2);
+      \path<8-> (d) -- node[below] {$\Delta$} (e);
+    \end{tikzpicture}
+  \end{center}
+
+  \begin{itemize}
+    \item<2-> \cmd{hg update libfoo}
+    \item<3-> unpack and import \ext{libfoo} version 2.0
+    \item<4-> \cmd{hg commit -m 'Import of libfoo 2.0'}
+    \item<5-> \cmd{hg update default}
+    \item<7-> \cmd{hg merge libfoo}
+    \item<8-> \cmd{hg commit -m 'Merged with libfoo 2.0'}
+  \end{itemize}
+\end{frame}
--- a/vendor-branches.tex
+++ b/vendor-branches.tex
@@ -51,6 +51,11 @@
 \include{library-maintenance}
 \include{library-upgrades}
 
+\subsection{Vendor Branches in Mercurial}
+\include{mercurial-vendor-branches}
+\include{merge-details}
+\include{merging-vendor-branches}
+
 \section{Wrapping Up}
 
 \include{links}