diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py --- a/mercurial/rewriteutil.py +++ b/mercurial/rewriteutil.py @@ -16,9 +16,11 @@ revset, ) -def precheck(repo, revs, action='rewrite'): +def precheck(repo, revs, action='rewrite', allowotherusers=True): """check if revs can be rewritten action is used to control the error message. + allowotherusers can be passed as false if you want to disallow users to + obsolete someone else changesets Make sure this function is called after taking the lock. """ @@ -40,6 +42,13 @@ if newunstable: raise error.Abort(_("cannot %s changeset with children") % action) + if not allowotherusers: + curuser = repo.ui.username() + for r in revs: + if repo[r].user() != curuser: + raise error.Abort(_("cannot obsolete %s changeset which is not" + " authored by you") % r) + def disallowednewunstable(repo, revs): """Checks whether editing the revs will create new unstable changesets and are we allowed to create them.