# HG changeset patch # User Boris Feld # Date 1499709752 -7200 # Node ID 904894edb2059a4549a9cdc23b1e4d88673ad98a # Parent 1424a769f31b3d53c30ff1c1de718a163c2b00cf 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. diff -r 1424a769f31b -r 904894edb205 mercurial/bookmarks.py --- 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: