Add a family of git-commands to assist with the management of multiple CLs/branches.

git-rebase-update - ensure all branches are up to date
git-new-branch - create branches
git-rename-branch - rename a branch while preserving parentage relationships
git-reparent-branch - change the parent of a branch, including rebasing it correctly onto that new parent.
git-squash-branch - collapse a branch into a single commit
git-upstream-diff - show the diff between the current branch and it's upstream branch
git-mark-merge-base - explicitly set what you want the above tools to consider the merge-base for the current branch.

R=agable@chromium.org, hinoka@chromium.org, stip@chromium.org, szager@chromium.org
BUG=261738

Review URL: https://codereview.chromium.org/184253003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@259520 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_map.py b/git_map.py
index 7001325..8281222 100755
--- a/git_map.py
+++ b/git_map.py
@@ -10,13 +10,16 @@
   * Green   - Local branch
   * Red     - Remote branches
   * Magenta - Tags
+  * White   - Merge Base Markers
   * Blue background - The currently checked out commit
 """
+
 import sys
 
 import subprocess2
 
 from git_common import current_branch, branches, tags, config_list, GIT_EXE
+from git_common import branch_config_map
 
 from third_party import colorama
 
@@ -24,12 +27,16 @@
 GREEN = colorama.Fore.GREEN
 MAGENTA = colorama.Fore.MAGENTA
 RED = colorama.Fore.RED
+WHITE = colorama.Fore.WHITE
 
 BLUEBAK = colorama.Back.BLUE
 
 BRIGHT = colorama.Style.BRIGHT
 RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL
 
+# Git emits combined color
+BRIGHT_RED = '\x1b[1;31m'
+
 def main():
   map_extra = config_list('depot_tools.map_extra')
   fmt = '%C(red bold)%h%x09%Creset%C(green)%d%Creset %C(yellow)%ad%Creset ~ %s'
@@ -40,6 +47,7 @@
     stdout=subprocess2.PIPE,
     shell=False)
 
+  merge_base_map = branch_config_map('base')
   current = current_branch()
   all_branches = set(branches())
   if current in all_branches:
@@ -47,6 +55,21 @@
   all_tags = set(tags())
   try:
     for line in log_proc.stdout.xreadlines():
+      if merge_base_map:
+        commit = line[line.find(BRIGHT_RED)+len(BRIGHT_RED):line.find('\t')]
+        base_for_branches = set()
+        for branch, sha in merge_base_map.iteritems():
+          if sha.startswith(commit):
+            base_for_branches.add(branch)
+        if base_for_branches:
+          newline = '\r\n' if line.endswith('\r\n') else '\n'
+          line = line.rstrip(newline)
+          line += ''.join(
+              (BRIGHT, WHITE, '    <(%s)' % (', '.join(base_for_branches)),
+               newline))
+          for b in base_for_branches:
+            del merge_base_map[b]
+
       start = line.find(GREEN+' (')
       end   = line.find(')', start)
       if start != -1 and end != -1: