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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:20:35+00:00 2026-05-20T10:20:35+00:00

Part of my software build process includes getting the hash of the working directory

  • 0

Part of my software build process includes getting the hash of the working directory parent into a C++ string for inclusion in the “version” output. This is done by using hg identify -i to get the global revision id, and copying this output into a .h file for inclusion. I do this in a Windows batch file:

setlocal enabledelayedexpansion
for /f "tokens=1 delims=;=" %%a in ('hg identify -i') do (
  echo const std::string revision^(_T^("%%a"^)^); > rev.h
)

Which will output something like this into the file:

const std::string revision(_T("3b746fd492c6"));

If the working directory has any uncommitted changes, the hash has a + appended, making the string "3b746fd492c6+". This allows me to easily check whether the version of software I have built is controlled or not – if the string includes a + then the software is not reproducible from the repository.

However, hg identify adds a + to denote uncommitted changes, but it does not recognised untracked files. If I commit all changes but forget to add that all-important “do stuff” class, hg identify will not indicate this.

So my question is: how can I get the required functionality?
How can I simulate hg identify recognising new and removed files?

Ideally I would like to not have to use extensions, but will consider them as an option.


Update

Following on from Oben Sonne’s suggestion of using a combination of hg st and hg id -r . I have come up with the following batch file which produces quite a nice result:

@echo off
set REPOMODS=
for /F %%a IN ('hg st -n') DO set REPOMODS=+

for /f "tokens=1 delims=;=" %%a in ('hg identify -i -r .') do (
  echo const std::string revision^(_T^("%%a%REPOMODS%"^)^); > rev.h
)

%REPOMODS% is empty unless there is anything in the output of the hg st, in which case it is +. I’ve done a few tests and it seems to work.

Is there another solution which requires less faffing in batch files? Or is this the best I’ll get?

  • 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-20T10:20:36+00:00Added an answer on May 20, 2026 at 10:20 am

    How about simply checking if the output of hg st is empty? If not, add a + yourself to the version (if not already given by hg id).

    UPDATE: To prevent the double + issue, you could run hg id -r ., which never gives you a trailing +.

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

Sidebar

Related Questions

Sometimes, when I present a part of the software development process to certain people,
I am working on some software that will dynamically build menu items for certain
I'm part of a software development company where we do custom developed applications for
I am part of a software development company looking for a good way to
I am parsing a XML file supplied by some software. Part of the parsing
I'm writing my first proper useful piece of software. Part of it will involve
I am interested in knowing what the best software would be to build an
We're in the process of streamlining/automating build, integration and unit testing as well as
Does anyone have know how I can step into system.web.mvc? I am getting an
I'm trying to convert a Netbeans 6.9.1 project into a scripted build (without netbeans).

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.