Possibility to forbid 2 heads for mercurial

Issue #216 new
Anonymous created an issue

For coprporate env it is usually required to have possibility to forbid two heads in branch in mercurial. Currently it is not possible with scm-manager.

Comments (5)

  1. DRayX

    Here is a simple server side hook that will do what you want:

    # [hooks]
    # pretxnchangegroup.heads = python:hooks.headshook
    def headshook(ui, repo, **kwargs):
        """Check that no branch has more than one head"""
        ret = None
        for branch, heads in repo.branchmap().iteritems():
            if len(heads) > 1:
                ui.warn('abort: branch "%s" would have more than one head after push\n' % branch)
                ui.status('hint: use "hg merge" to merge nodes %s and %s\n' % (repo[heads[0]], repo[heads[1]]))
                ret = True
        return ret

    It would be nice though to have a way to upload / edit hooks and set them in the hgrc through SCM-Manager so that you wouldn't need to SSH / RDP into the server to change them.

  2. pmv

    I'm also interested in this one. Is there an easy way to have python hooks like this be active on all repositories (and all new ones that are created)? If an scm-manager plugin is needed for this, is there any example plugin that could be looked at?

  3. DRayX

    Even better than the user specific hgrc files are the system wide ones:

    (Plan 9) /lib/mercurial/hgrc
    (Plan 9) /lib/mercurial/hgrc.d/*.rc
    (Unix) /etc/mercurial/hgrc
    (Unix) /etc/mercurial/hgrc.d/*.rc

    For the windows registry key, it needs to be a list of paths to Mercurial.ini file or directories containing .rc files. The best locations to use IMHO are "%AllUsersProfile%\Mercurial.ini" and "%AllUsersProfile%\hgrc.d\".

  4. Log in to comment