Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 381237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:03:58+00:00 2026-05-12T15:03:58+00:00

Is it possible to write some manner of hook in mercurial that will reject

  • 0

Is it possible to write some manner of hook in mercurial that will reject changesets that effect a specific named branch in a repository?

We have a managed project and would like to allow any developers to push their changes to our repository so long as they are in their own named branch. This allows us to manage a single buildbot and a shared sandbox in the same repository (by keeping branches separate). We’d like to block any attempts to write to the default branch from outsiders (we would, internally, merge their branches over).

We’re looking at using the pretxnchangegroup hook, but this has 2 concerns:

1) A user can push changes using any username; we basically only have an http-auth protecting the repository by requiring any username or password to actually connect to the repo, but it doesn’t check the usernames in the commit to make sure they match the account used to push.

2) Lets say a user has done right and developed in a branch, but then they do one last commit on the default branch. The hg push fails. What does the developer do at this point to fix their push?

Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:03:58+00:00Added an answer on May 12, 2026 at 3:03 pm

    Yeah, you can do this pretty easily with the pretxnchangegroup like you figured. I’ll do it in shell, but it’d be in-process (and thus faster) if you do it in python.

    Set up something like this as your pretxnchangegroup:

    #!/bin/sh
    for thenode in $(hg log -r $HG_NODE:tip --template '{node}\n') ; do
         if [ $(hg id --branch -r $thenode) = "default" ] ; then
              echo Commits to default branch are not allowed -- bad changeset $thenode
              exit 1
         fi
    done
    

    That makes sure that none of the arriving changesets are on branch “default”.

    Regarding concern 1: If you’re running behind apache you’ll have access to the usual CGI variables, so you can check $REMOTE_USER to make sure it matches the branch name if that’s something you want to try to enforce.

    Regarding concern 2: If a user sees the message that they’re pushing an invalid changeset, then they’ll just have to push the rest of them using push -r and they can strip or modify their changeset on default later.

    Lastly, have you considered just having a separate clone for the auto-builds / main branch? Let everyone push into the staging repo, and let only the buildmaster pull approved changesets from staging into auto-build when s/he is happy with them? You get the same workflow you have now (waiting for a builder to merge), but it’s much less hassle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if it is possible to write some software that
I've heard that it is possible to write some code like this SomeClass obj
I need to write some site that will be able to turn webcam of
I want to write some JavaScript that will change the onmousedown of a div
A customer (photographer) asked me, if it was possible to write some kind of
Is it possible to write and run with Visual Studio 2008 some unit test
I am trying to write a query and would like some help if possible.
Is it possible to write GLSL ES fragment shaders under iOS that generate multiple
I'm looking for some advice for unit-testing in a manner that doesn't leave test
Is it possible to write some code in your .install -file of your D7

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.