Mercurial > hg
changeset 33005:9343fce87789
bookmarks: factor out delete logic from commands
We keep the lock in the caller so that future devs are aware of the
locking implications.
author | Sean Farley <sean@farley.io> |
---|---|
date | Mon, 12 Jun 2017 23:02:48 -0700 |
parents | c808862f2e6e |
children | e0a8dd6c87c7 |
files | mercurial/bookmarks.py mercurial/commands.py |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Fri Jun 23 15:30:27 2017 -0400 +++ b/mercurial/bookmarks.py Mon Jun 12 23:02:48 2017 -0700 @@ -691,3 +691,17 @@ "whitespace")) scmutil.checknewlabel(repo, mark, 'bookmark') return mark + +def delete(repo, tr, names): + """remove a mark from the bookmark store + + Raises an abort error if mark does not exist. + """ + marks = repo._bookmarks + for mark in names: + if mark not in marks: + raise error.Abort(_("bookmark '%s' does not exist") % mark) + if mark == repo._activebookmark: + deactivate(repo) + del marks[mark] + marks.recordchange(tr)
--- a/mercurial/commands.py Fri Jun 23 15:30:27 2017 -0400 +++ b/mercurial/commands.py Mon Jun 12 23:02:48 2017 -0700 @@ -975,14 +975,7 @@ marks = repo._bookmarks if delete: tr = repo.transaction('bookmark') - for mark in names: - if mark not in marks: - raise error.Abort(_("bookmark '%s' does not exist") % - mark) - if mark == repo._activebookmark: - bookmarks.deactivate(repo) - del marks[mark] - + bookmarks.delete(repo, tr, names) elif rename: tr = repo.transaction('bookmark') if not names: