How to call hg commands through firefox extension? - mercurial

I am trying to automate hg commit and hg push commands , for that I need to call those commands from firefox extension (which I am working on). Is there a way to do it without using batch files ?

Yes, you can just call hg directly like any other process.
See here how to make a command line call from within a firefox extension.
Of course for the call "initWithPath" you must specify the hg command line binary, that is also executed when you type "hg" in a Terminal window. And this command line utility will have different locations on different platforms. So if you expect the extension to work crossplatform, you should offer a preferences panel, where the users can enter the path to their local hg binary and by default you could also put there the standard path where most users on that platform would have installed hg to.

Related

In Mercurial on Windows how do I set (any) editor correctly? (Can't commit)

I have TortoiseHg installed on Windows XP. Although I can use most hg commands normally from the command line, I cannot use hg commit (without the -m option) because it fails to launch my editor. This is what happens:
> hg commit
/c: /c: is a directory
abort: edit failed: notepad.exe exited with status 126
in mercurial.ini I have the editor set as:
[ui]
editor = notepad.exe
If I myself type notepad.exe or even just notepad from the command line then notepad works fine. Changing the editor variable to something else (like to foobar) confirms that Mercurial is reading the variable and trying to run foobar with the same result (foobar exited with status 126).
I also have a problem using parts of the TortoiseHg GUI. Context menu options like "View at revision" don't work when clicked. Presumably they are trying to launch the editor but are failing.
This problem has persisted for about 2 1/2 years of using Mercurial, and I've tried everything I can think of to set the editor variable in another way or set it to another program. Currently using TortoiseHg version 2.8 ("with Mercurial-2.6, Python-2.7.3, PyQt-4.9.6, Qt-4.8.4").
related questions:
Using other editor with TortoiseHg
How do I specify a different editor for Mercurial on Windows?
Mercurial Editor: "abort: The system cannot find the file specified"
Not long did I ask this question before finally realizing the problem. Mercurial and TortoiseHg are running the value of my Editor variable into a command interpreter, and this interpreter is whichever is specified by the COMSPEC enviroment variable.
Apparently once in my life I set this variable to the msys shell C:\msys\bin\sh.exe (probably in a vain attempt at trying to fix a problem not unlike the one I was asking here). The funny errors were caused because the msys shell being sent something like /c notepad.exe as an argument.
I have no idea why the extra /c switch is being passed (which is cmd.exe specific) if Mercurial is also deciding to also use COMSPEC. Also, when editing the settings from TortoiseHg, I am somewhat misleadingly told that if the Shell value in my mercurial config file is left unspecified, then it will default to cmd.exe on windows. This value of Shell is probably used for something else though, like the 'Open Terminal' context menu.

I am trying to use mercurial and the perfarce extension to check out and getting an error

I am trying to use the "Perfarce" extension to Mercurial to create an hg repository (working copy) that is managed by mercurial, with a link to check out and in to a central perforce server "depot".
The help says to enter a command like this:
hg clone p4://hostname:portnumber/userid
When I do this, it creates a folder under my current working directory named with the userid name (so it seems sub-optimal way to pass the user name to the p4 url), and I get this error:
abort: p4: ... - must create client 'userid' to access local files.
The second try fails with destination is not empty error.
I have also tried specifying a destination:
hg clone p4://hostname:portnumber/userid dest
This doesn't work either -- same error message about creating a client. I don't see a way to tell it about my WORKSPACE, if any, or which depot, on the particular hostname to check out.
I already having a WORKSPACE that p4 and p4v know about, and it's in a different folder than the place where I would like to have my hg+perfarce working copy. I suspect the p4 command line program might be confused by this.
Has anyone gotten the "perfarce" extension working with mercurial? What did you do exactly, and what am I doing wrong, and not understanding?
You must have a Perforce client created when using Perfarce. You then use the specified convention to access the perforce depot. As per Perfarce documentation
hg clone [--startrev REV] [-r REV] [p4://server/clientname] [dest]
Also, make sure you have the destination folder created on your machine. It must be the same as set in the client. If your client spec specifies d:\foo you must run the Perfarce command in d:\ and have an empty foo directory. Not using the optional dest Perfarce creates a directory using the client name.
If your Perforce client is using the default settings and using the read-only flag, you might want to use the MakeWriteable extension.
It looks like you have to type "p4 client", and then edit the resulting file which sets up access to various depots within the p4 server. Then the hg commands will work in this working folder.
Except that it dies with an abort, from p4 client run within the hg clone operation, with a missing file error, each time a different missing file.
I'm new to Perfarce, too, but I've found that I need to use p4 login, even though this is not otherwise required by my P4 server. Perfarce doesn't seem to recognize P4 settings files set up via P4CONFIG.

Has anyone used "hstart.exe"?

What I trying to do is to run hg commands using firefox extension without showing command prompt window all the time.
I initiate process with hg.exe file and then execute hg commands by passing arguments in to it.
process.init("hg.exe");
args["update"];
process.run(true,args,args.lenght);
But I am confused how I am going to use hstart.exe on top of it
Any suggestions ?
Just pass hg commands as arguments in hstart.exe...that will do the trick !!!

How can I run hg commands in the background (without showing the command prompt window)?

I am using firefox extension to run hg commands on my repository. But when ever I execute any hg commands it shows command prompt window for a split second and closes it.
Eg:-
process.run("push");
process.run("update");
Is there any way to not show that window at all ?
Back in the day I used to have a tool that was hidewin.exe that would all you to start any bat file or exe file and have it run invisibly. I tried a google search for it but didn't find it easily but maybe you could have better luck at finding it.

How to configure hosted Mercurial in TeamCity 5

This is probably a simple problem and I'm feeling exceptionally dumb because I can't find a any kind of documentation.
I've just installed TeamCity 5 and I want to get files from my Mercurial hosting and there is two fields I just can't figure out.
HG Command path. What should I put here? The path to a file containing what? Can I get an example of that file somewhere?
The host is using Mercurial over SSH where do I define my private key?
Pull changes from? Should I put the address I'm cloning from i.e. ssh://username#myhost.something/project
I figured this out for my TeamCity 5 server last week.
HG Command path: HG
Pull changes from: https://bitbucket.org/.../.../
Don't put the username# in the URL. This is specificed as in the Username/Password fields. If you include the username in the URL it'll fail as there is a bug in the configuration tool. You'll also see a screenshot of the configuration attached to the thread:
http://www.jetbrains.net/devnet/message/5254640#5254640
I'd suggest getting things working with HTTPS and then moving to SSH if possible. This breaks things down into two easier to solve configuration problems. I used the following tutorial to get SSH going on my Windows client machine.
http://www.codza.com/mercurial-with-ssh-setup-on-windows
I've not set this up on my TeamCity server yet. However I did get TeamCity to pick up my Mercurial.ini settings by putting the ini file in \Documents and Settings\TeamCity, which is the account the service runs under.
I've not used team city, but I think hg command path is probably the full path to your local mercurial executable. For me (on linux) that's:
$ type hg
hg is /usr/bin/hg
On windows it's where the 'hg' executable in your system path was placed by whichever (of the many) windows installers for mercurial you used.
Pull changes from sounds like the URL to the repo, so:
ssh://username#myhost.something/project
or
ssh://username#myhost.something//project # note the _two_ double slashes
if you're using absolute paths on the server side.
Your private key location/specification depends on what you're using for ssh and whether or not you're running ssh-agent, but here's a links that explicitly points from within mercurial.ini, which seems sound:
http://dev.openttdcoop.org/projects/home/wiki/Configuring_TortoiseHg_(Windows)#Pointing-to-you-Private-key