Merge like it's 2099 (AndroidMakers 2017)

Merge like it's 2099 (AndroidMakers 2017)

Every developer working in a team of more than 2 person has experienced conflicts when merging, rebasing or cherry picking a commit. Resolving those conflicts is a tedious task and it's time for a change. This talk will propose a solution to merge smarter and not harder.

Cf95f93e78f6d6dd0630049396f723c6?s=128

Xavier Gouchet

April 10, 2017
Tweet

Transcript

  1. 2.

    About... Xavier F. Gouchet Android Architect Jenkins/Sonar Admin Bash/Python dev

    tools Bad Puns Advocate @xgouchet on Github, StackOverflow, Twitter, …
  2. 7.

    “ “Let’s start at the very begining (a very good

    place to start)” Julie Andrews @xgouchet
  3. 8.

    @xgouchet Our first commit commit 1e7dfd3e0c6715f3e611975892d8618afb7c33a6 Author: _alex <_alex@...> Date:

    Tue Jan 6 14:56:57 2009 +0000 Created folder git-svn-id: file:///opt/svn-android/trunk@2 966f65aa-2a5b-49e2-8ec6-7a0f9cdf547d
  4. 9.

    Our code base ◎ 8 years ◎ 12’000+ commits ◎

    30+ different committers ◎ 750’000+ lines of code* ◎ 200’000+ lines of comments* ◎ 7’500+ source files* * Java, XML, python, gradle, shell @xgouchet
  5. 12.

    Text based ? ◎ Diff / Merge is based on

    a stream of characters. ◎ Easy (and fast-ish) to compute ◎ Recognizes newlines / whitespace ◎ Doesn’t understand any syntax¹ @xgouchet
  6. 13.

    Common conflicts ◎ The imports section ◎ Same change on

    both sides ◎ Additions at the same place ◎ Changes in different lines in same block ◎ Unrelated changes on same line ◎ … ? @xgouchet
  7. 15.

    “ “There must be a better way to make the

    things we want…” Paul Mc Cartney @xgouchet
  8. 17.

    Basic principle ◎ Many simple automatic solvers ◎ Language agnostic

    ◎ Manual solving as a “last resort” solution ◎ Integrate with git / 3rd party tools @xgouchet
  9. 18.

    $ git rebase develop $ git mergetool Auto Merge Tool

    Process auto auto auto @xgouchet
  10. 19.

    $ git merge feature/foo $ git mergetool auto auto auto

    Auto Merge Tool Process @xgouchet
  11. 20.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  12. 21.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  13. 22.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  14. 23.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  15. 24.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  16. 25.

    Configuration (~/.gitconfig) [merge] tool = amt [mergetool "amt"] cmd =

    amt.py -l $LOCAL -r $REMOTE -b $BASE -m $MERGED [amt] tools = java_imports;gen_additions;custom;meld [mergetool "java_imports"] order = android [mergetool "custom"] cmd = custom.sh "$LOCAL" "$REMOTE" "$MERGED" extensions = html;xml @xgouchet
  17. 26.

    Automatic conflict solvers ◎ Language agnostic ◦ Addition at the

    same line ◦ Deleting the same block ◦ Woven conflicts ◦ … ◎ Language specific ◦ Java Imports ◦ … @xgouchet
  18. 28.

    Specific Case ◎ Rebased a huuuuge commit (+1537, -3250) ◎

    Number of conflicted files : 37 ◎ Number of conflicts : 62 ◎ Number of conflicts solved manually : 3 ◎ Time spent : 2 minutes* * plus time to write AutoMergeTool @xgouchet
  19. 29.

    Globally ◎ Used since december 2016 ◎ Number of manual

    conflicts down by 75% ◎ Mood increased by 100% @xgouchet
  20. 31.

    ◎ Semantic Merge ($6.90/month) ◎ DeltaXML (XML only) ◎ Why

    doesn’t this exist yet: Syntax-aware merge ¹ Going even further @xgouchet