Make marked merge base invalid when the upstream changes.
This should let the base marker transparently work with plain-old-git tools
which was the idea in the first place. Specifically `git branch -u` without a
corresponding rebase.
R=agable@chromium.org
BUG=373977
Review URL: https://codereview.chromium.org/288323002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@271112 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_common.py b/git_common.py
index 6952c1e..298ecc4 100644
--- a/git_common.py
+++ b/git_common.py
@@ -352,9 +352,16 @@
If parent is supplied, it's used instead of calling upstream(branch).
"""
base = branch_config(branch, 'base')
+ base_upstream = branch_config(branch, 'base-upstream')
parent = parent or upstream(branch)
+ if not parent:
+ return None
actual_merge_base = run('merge-base', parent, branch)
+ if base_upstream != parent:
+ base = None
+ base_upstream = None
+
def is_ancestor(a, b):
return run_with_retcode('merge-base', '--is-ancestor', a, b) == 0
@@ -370,7 +377,7 @@
if not base:
base = actual_merge_base
- manual_merge_base(branch, base)
+ manual_merge_base(branch, base, parent)
return base
@@ -409,8 +416,9 @@
return branch_config(branch, 'dormant', 'false') != 'false'
-def manual_merge_base(branch, base):
+def manual_merge_base(branch, base, parent):
set_branch_config(branch, 'base', base)
+ set_branch_config(branch, 'base-upstream', parent)
def mktree(treedict):
@@ -475,6 +483,7 @@
def remove_merge_base(branch):
del_branch_config(branch, 'base')
+ del_branch_config(branch, 'base-upstream')
def root():