From 1d18a2690a0d501eef0ea49d5cf6f7b8fb609a0d Mon Sep 17 00:00:00 2001 From: Kostia Balytskyi Date: Fri, 17 Jun 2016 05:25:32 -0700 Subject: [PATCH] fbamend: abort if preamend bookmark points to the current commit Differential Revision: https://phabricator.intern.facebook.com/D3436696 --- fbamend.py | 10 ++++++++-- tests/test-fbamend.t | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fbamend.py b/fbamend.py index 5334437c93..9cee47335b 100644 --- a/fbamend.py +++ b/fbamend.py @@ -305,11 +305,17 @@ def fixupamend(ui, repo): raise error.Abort(_('no bookmark %s') % preamendname, hint=_('check if your bookmark is active')) - ui.status(_("rebasing the children of %s\n") % (preamendname)) - old = repo[preamendname] + if old == current: + hint = _('please examine smartlog and rebase your commits manually') + err = _('cannot automatically determine what to rebase ' + 'because bookmark "%s" points to the current commit') % \ + preamendname + raise error.Abort(err, hint=hint) oldbookmarks = old.bookmarks() + ui.status(_("rebasing the children of %s\n") % (preamendname)) + active = bmactive(repo) opts = { 'rev' : [str(c.rev()) for c in old.descendants()], diff --git a/tests/test-fbamend.t b/tests/test-fbamend.t index 1caee15ec9..adfd5ca509 100644 --- a/tests/test-fbamend.t +++ b/tests/test-fbamend.t @@ -651,4 +651,21 @@ Check whether unamend works with dirty working directory A c A d R b + $ cd .. + +Check whether fbamend warns people if preamend bookmark is the same as an active +bookmark + $ hg init messedpreamed && cd messedpreamed + $ echo root > root && hg ci -Am root + adding root + $ hg book -r . activebook + $ hg book -r . activebook.preamend + $ hg up activebook + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark activebook) + $ hg amend --fixup + abort: cannot automatically determine what to rebase because bookmark "activebook.preamend" points to the current commit + (please examine smartlog and rebase your commits manually) + [255] +