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 7605875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:16:38+00:00 2026-05-31T00:16:38+00:00

I currently have a pre-commit hook in my mercurial project that gives the user

  • 0

I currently have a pre-commit hook in my mercurial project that gives the user the option to update the version number of the project if they wish (e.g. 1.0 to 1.0.1 or 1.1 or 2.0). They select one of these options, and the hook updates the version number in one of the project’s files prior to the commit taking place.

When I run hg commit, this hook runs and updates the relevant file with the new version number, and then performs the commit.

I’d like to add to the hook such that it calls hg tag <new_verson_number> as well.

However, I can’t add this to the pre-commit hook, because then the tag will be added before the commit is called, causing the tag to be one revision out of date.

I’d like to add the hg tag command to a commit hook (run after the commit), so that the sequence of events is like so:

  • hg commit -m "my commit message"
  • user says yes, I’d like to change the version number
  • version number is updated in the relevant file
  • commit occurs [everything up to here is fine]
  • if the user changed the version number, run a commit hook: hg tag <new_version_number>.

Now, I could add a commit hook that read off the new version number from the file it’s stored in and run hg tag <new_version_number>, but what if the user decided not to change the version number? In that case, I don’t want a tag added, and if I blindly run hg tag <new_version_number> I’ll end up with tags I don’t want.

So – is there some way I can tell the pre-commit hook to leave some information for the commit hook (a yes/no of whether to add the tag), and the commit hook can use this to determine whether to add the tag or not?

cheers.

  • 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-31T00:16:40+00:00Added an answer on May 31, 2026 at 12:16 am

    How about a commit hook that checks if the last commit modified the file in which you store the version? Something like:

    [hooks]
    commit.tagversion = if hg log -r $HG_NODE --template '{files}' | grep -q VERSION_FILE ; then hg tag $(hg cat -r $HG_NODE VERSION_FILE) ; fi
    

    I haven’t tested it, but that or something like it should work.

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

Sidebar

Related Questions

I'm writing a pre-commit hook in C# and I know I have to return
I want to have a pre-commit hook check if the current commit is a
I wrote the following pre-commit script for SVN to validate that a user has
I have the following pre-commit hook to use JavaScript Lint for checking JavaScript files
I currently have a number of special flavors of an iPhone application that I
I currently have an ASP.NET MVC 3 project, plus a class library project, that
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have a DetailsView in ASP.NET that gets data from the database based
I currently have a listing of data that has a randomly generated order listing.
I currently have an iPhone app that reads data from an external XML file

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.