Commit f3e37a0f authored by iannucci@chromium.org's avatar iannucci@chromium.org

Add better error messages to git_reparent_branch.

R=dhsharp@chromium.org, vadimsh@chromium.org
BUG=538454

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297848 0039d316-1c4b-4281-b951-d872f2087c98
parent b371a1c8
......@@ -31,6 +31,7 @@ def main(args):
# TODO(iannucci): Allow specification of the branch-to-reparent
branch = current_branch()
if opts.root:
new_parent = root_ref
elif opts.lkgr:
......@@ -46,6 +47,16 @@ def main(args):
if new_parent == cur_parent:
parser.error('Cannot reparent a branch to its existing parent')
if not cur_parent:
msg = (
"Unable to determine %s@{upstream}.\n\nThis can happen if you didn't use "
"`git new-branch` to create the branch and haven't used "
"`git branch --set-upstream-to` to assign it one.\n\nPlease assign an "
"upstream branch and then run this command again."
)
print >> sys.stderr, msg % branch
return 1
mbase = get_or_create_merge_base(branch, cur_parent)
all_tags = tags()
......
......@@ -387,6 +387,14 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
M H I J K L
""")
def testReparentBranchWithoutUpstream(self):
self.repo.git('branch', 'nerp')
self.repo.git('checkout', 'nerp')
_, err = self.repo.capture_stdio(self.rp.main, ['branch_K'])
self.assertIn('Unable to determine nerp@{upstream}', err)
if __name__ == '__main__':
sys.exit(coverage_utils.covered_main((
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment