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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:30:14+00:00 2026-06-05T20:30:14+00:00

This may seem a bit crazy, but if you can tell me a better

  • 0

This may seem a bit crazy, but if you can tell me a better way please do.
I need a webservice that will display the mercurial revision number for the current version.

I have a very simple batch file that writes this number to a text file

cd C:\inetpub\wwwroot\MyWebsite
hg identify --num > services\version.txt 

and a method that should call the batch file then read the contents of the file and, for now, write to screen (I’m doing it in a web page, but will migrate to a simple service later)

Private Sub GetVersionNumber()
    Dim versionFile = Server.MapPath("~/services/version.txt")
    Dim batchFile = Server.MapPath("~/services/version.bat")
    Process.Start(batchFile)

    Dim revision As String = String.Empty
    Using reader As New StreamReader(versionFile)
        Do While reader.Peek() <> -1
            revision = reader.ReadLine()
        Loop
    End Using
    Response.Write(revision)
End Sub

I have granted Everyone write access to the services directory and explicitly on version.txt, but when I hit the page the version.txt file is always empty. If I have the file open in notepad++ when I do then I get a message saying the file has been modified by another program, do I want to reload it. When I do it’s empty. If I set some text in the file and save it then visit the web page again the contents of my text file are wiped out.

I had this in a try/catch block but no exception was thrown, so I’ve removed it (for clarity).

Ultimately all I need is to get the results of
hg identify –num
to display as a string on the web page/service which will be called by a separate SharePoint site

  • 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-06-05T20:30:16+00:00Added an answer on June 5, 2026 at 8:30 pm

    Instead of manually invoking the batch file from your web server every time the page is requested, you can configure a Mercurial update hook to invoke your identify command automatically every time the working copy updates.

    For example, add this to the repository’s .hg\hgrc file:

    [hooks]
    update.writeversion = hg identify --num > services\version.txt
    

    Some links with additional info on hooks:

    • http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html
    • https://www.mercurial-scm.org/wiki/Hook
    • http://www.selenic.com/mercurial/hgrc.5.html#hooks
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem a bit odd, but I really need to create a workaround
I'm sorry this may seem a bit basic, but I can't get my head
This may bit a bit of a basic question, but I can't seem to
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This may seem stupid, but I can't see the events list on the Debug
This question may seem a bit stupid, but i'm new to Joomla! And i
This may seem like a rudimentary request, but I can't seem to get it
This may seem silly, but I'm a bit confused about the following code: public
this may seem a little odd, but it would make for a convenient way
Ok this may seem like a bit of a noob question but one many

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.