Successfully reported this slideshow.
Your SlideShare is downloading. ×

Perforce convergence vs divergence

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

10 of 24 Ad

More Related Content

Slideshows for you (20)

Viewers also liked (20)

Advertisement

Similar to Perforce convergence vs divergence (20)

Recently uploaded (20)

Advertisement

Perforce convergence vs divergence

  1. 1. Convergence vs. Divergence Purposeful Merging with Perforce Laura Wingerd  Perforce Software  www.perforce.com
  2. 2. Overview <ul><li>Background </li></ul><ul><ul><li>Branching and merging </li></ul></ul><ul><ul><li>3-way file merging </li></ul></ul><ul><li>Convergence vs. divergence </li></ul><ul><ul><li>Some branches should converge, some should diverge </li></ul></ul><ul><ul><li>Merging for convergence is not the same as merging for divergence </li></ul></ul><ul><li>Purposeful merging </li></ul><ul><ul><li>How to get the merge result you want </li></ul></ul>
  3. 3. Branching... DevX Main Rel 2 Rel 1 DevY DevZ
  4. 4. Branches over time... <ul><li>Some branches converge, some branches diverge </li></ul>Main Rel1 Main Rel1 Main DevX Rel1 Main DevX DevY Rel1 Main DevX DevY DevZ Rel1 Main Rel2 DevX DevY DevZ Rel1 Main Rel2 DevX DevZ Rel1 Main Rel2 DevX DevZ Rel1 Main Rel2 DevX DevZ Rel1 Main Rel2 DevX DevZ Rel1 Main Rel2 DevX DevZ
  5. 5. Branches diverge when… <ul><li>back-porting to release lines </li></ul><ul><ul><li>release lines always diverge from trunk </li></ul></ul><ul><li>cherry-picking </li></ul><ul><ul><li>e.g., hunt-and-peck feature packaging </li></ul></ul><ul><li>branching for customization </li></ul><ul><ul><li>e.g., per-customer, per-platform, etc. </li></ul></ul><ul><li>trading changes between developers </li></ul><ul><ul><li>e.g., boilerplates, code snippets </li></ul></ul>
  6. 6. Branches converge when... <ul><li>development tasks are completed </li></ul><ul><ul><li>i.e., delivering completed work from dev line to mainline </li></ul></ul><ul><li>isolated development projects are rejoined </li></ul><ul><ul><li>delivering private branch work into a shared branch </li></ul></ul><ul><li>distributed development is reconciled </li></ul><ul><ul><li>developers working in separate repositories </li></ul></ul>
  7. 7. Merging files <ul><li>Although we speak of “merging branches”... </li></ul><ul><li>...merging takes place between individual pairs of source and target files </li></ul>
  8. 8. Integration history “arrows” <ul><li>Integration history records source-to-target relationships between file revisions </li></ul><ul><li>Perforce uses integration history to determine: </li></ul><ul><ul><li>which source revisions still need to be integrated to target </li></ul></ul><ul><ul><li>the revision that will be used as the base for a three-way merge from source to target </li></ul></ul>
  9. 9. Three-way file merging <ul><li>A source file version and target file version are merged with reference to a base file version </li></ul><ul><li>The merged result is a consequence of: </li></ul><ul><ul><li>merge tool capabilities, and... </li></ul></ul><ul><ul><li>base selection </li></ul></ul>MERGED TARGET SOURCE BASE
  10. 10. The essence of a three-way merge A4 B5 C3 D2 E6 A4 B5 C4 D4 E7 A4 B6 C3 D3 E7 A4 B6 C4 ? E7 MERGED BASE SOURCE TARGET
  11. 11. Three-way file merge tools vary... <ul><li>Granularity </li></ul><ul><li>Conflict resolution </li></ul><ul><li>File formats </li></ul><ul><li>Syntax awareness </li></ul>
  12. 12. Perforce’s merge tools <ul><li>File formats: text </li></ul><ul><li>Syntax awareness: none </li></ul><ul><li>Granularity: line </li></ul><ul><li>Conflict resolution: “diligent” </li></ul><ul><ul><ul><li>Does more auto-resolving </li></ul></ul></ul><ul><ul><ul><li>Leaves fewer conflicts to be resolved manually </li></ul></ul></ul><figure id=&quot;create_gizmo&quot;> <title> The 'Create Gizmo' dialog </title> <graphic fileref=&quot;img/cg.gif&quot;/> </figure>
  13. 13. What makes a good merge base? SOURCE <ul><li>A base with “qualifying history” – i.e., whose complete history is in the history of both source and target... </li></ul><ul><li>... and a base with lots of history – i.e., whose history has as much in common with both the source’s history and the target’s history as possible </li></ul>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? X Y ? ? TARGET Z
  14. 14. The effect of base selection SOURCE TARGET A1 B1 C1 A1 ? ? X Y Z A1 B2 C1 A1 B2 C2 A1 B2 C1 A1 B3 C1 A1 B3 C2 A1 B3 C4 A1 B4 C4 A1 B3 C3 A2 B3 C4 A2 B3 C1 A1 ? ? A1 ? ? A3 B4 C4 A1 B4 C3 A3 B3 C4 A3 B4 ? A3 B3 C3 A3 B4 C3 A1 B4 C3 A3 B3 C4 A1 B3 C3 A3 B4 C4 ? B4 C3 ? B4 ? A3 B4 ? A3 ? ?
  15. 15. Base selection through the ages X Y Z SOURCE TARGET
  16. 16. Arrow types and base selection X Y Z SOURCE TARGET A1 B1 C1 A1 B2 C1 A1 B2 C2 A1 B2 C1 A1 B3 C1 A1 B5 C2 A1 B4 C1 A1 B6 C2 A1 B3 C2 A1 B4 C2 A1 B6 C2 A2 B4 C1 A2 ? C2 A1 B3 C1
  17. 17. Preserving divergence <ul><ul><li>Continuous, incremental merging preserves divergence </li></ul></ul><ul><ul><li>Cherry-picking before mass merging does not preserve divergence </li></ul></ul><ul><ul><li>After-the-fact, incremental merging preserves divergence </li></ul></ul>A B C D E F
  18. 18. “ Inherited” divergence A B C
  19. 19. Unintentional divergence <ul><li>“ Merge down, copy up” can be foiled by “ignore” arrows </li></ul>A B “ nothing to integrate” C D <ul><li>An “ignore” arrow is not the same as backing out a change </li></ul>
  20. 20. The effect of “edit” arrows C D A B <ul><li>Change propagation is assured, but convergence is not guaranteed </li></ul>
  21. 21. Guaranteeing convergence <ul><li>“ Merge down, copy up” </li></ul>COPY
  22. 22. Assuring a correct copy <ul><li>The recipe: </li></ul><ul><li>p4 integ –n [target] [source] </li></ul><ul><li>p4 integ –f [source] [target] </li></ul><ul><li>p4 resolve –at </li></ul><ul><li>p4 diff –sr | p4 –x - revert </li></ul><ul><li>p4 integ [source] [target] </li></ul><ul><li>p4 resolve –at </li></ul><ul><li>p4 submit </li></ul>
  23. 23. In a nutshell: <ul><li>Some branches diverge, some branches converge. </li></ul><ul><li>With three-way merging, base selection determines divergence or convergence. </li></ul><ul><li>As of Rel 2006.1, Perforce’s base selection accommodates both convergence and divergence nicely, but is biased toward preserving divergence </li></ul><ul><li>The “merge down, copy up” method achieves convergence between branches – as long as you’re copying branches correctly. </li></ul>
  24. 24. Convergence vs. Divergence Purposeful Merging with Perforce Laura Wingerd  Perforce Software  www.perforce.com

Editor's Notes

  • x

×