Mercurial > hg
changeset 33513:904894edb205
bookmark: use 'divergent2delete' in checkconflict
checkconflict used to also do some bookmark deletion in case of divergence. It
is a bit suspicious given the function name, but it's not the goal of this
series.
In order to unify bookmarks changing, checkconflict now return the list of
divergent bookmarks to clean up and the callers must clean them by calling
applyphases.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 10 Jul 2017 20:02:32 +0200 |
parents | 1424a769f31b |
children | 169c97bbd94c |
files | mercurial/bookmarks.py |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Mon Jul 10 19:12:25 2017 +0200 +++ b/mercurial/bookmarks.py Mon Jul 10 20:02:32 2017 +0200 @@ -183,13 +183,15 @@ If force is supplied, then forcibly move the bookmark to a new commit regardless if it is a move forward. + + If divergent bookmark are to be deleted, they will be returned as list. """ cur = self._repo.changectx('.').node() if mark in self and not force: if target: if self[mark] == target and target == cur: # re-activating a bookmark - return + return [] rev = self._repo[target].rev() anc = self._repo.changelog.ancestors([rev]) bmctx = self._repo[self[mark]] @@ -200,17 +202,16 @@ # the bookmark across branches when a revision is specified # that contains a divergent bookmark if bmctx.rev() not in anc and target in divs: - deletedivergent(self._repo, [target], mark) - return + return divergent2delete(self._repo, [target], mark) deletefrom = [b for b in divs if self._repo[b].rev() in anc or b == target] - deletedivergent(self._repo, deletefrom, mark) + delbms = divergent2delete(self._repo, deletefrom, mark) if validdest(self._repo, bmctx, self._repo[target]): self._repo.ui.status( _("moving bookmark '%s' forward from %s\n") % (mark, short(bmctx.node()))) - return + return delbms raise error.Abort(_("bookmark '%s' already exists " "(use -f to force)") % mark) if ((mark in self._repo.branchmap() or @@ -228,6 +229,7 @@ "(did you leave a -r out of an 'hg bookmark' " "command?)\n") % mark) + return [] def _readactive(repo, marks): """ @@ -747,8 +749,10 @@ mark = checkformat(repo, new) if old not in marks: raise error.Abort(_("bookmark '%s' does not exist") % old) - marks.checkconflict(mark, force) - changes = [(mark, marks[old]), (old, None)] + changes = [] + for bm in marks.checkconflict(mark, force): + changes.append((bm, None)) + changes.extend([(mark, marks[old]), (old, None)]) marks.applychanges(repo, tr, changes) if repo._activebookmark == old and not inactive: activate(repo, mark) @@ -778,7 +782,8 @@ tgt = cur if rev: tgt = scmutil.revsingle(repo, rev).node() - marks.checkconflict(mark, force, tgt) + for bm in marks.checkconflict(mark, force, tgt): + changes.append((bm, None)) changes.append((mark, tgt)) marks.applychanges(repo, tr, changes) if not inactive and cur == marks[newact] and not rev: