Mercurial Push Command

Jun 7, 2012 at 10:58 AM


I have a little problem understanding how the push command works when using it inside a .net c# project and was wondering if someone could help me or give me an example of such. I am a MSc Student and I am working on a web based authentication system for my final year project.

I managed to get the pull command working without any problems but as far as I understand mercurial push i need to identify the repository from which I want to push and then the repository to which I want to push. However I was not able to accomplish this.

I would be very happy if someone could give me some help or indication towards on how I can accomplish a push command using .net c# framework.


Thank you for your time. 

Jun 7, 2012 at 11:28 AM


You identify the repository you push from. When you construct the Repository object.
A Mercurial repository have the notion of saved remote repositories, that have a "nickname", typically you will have a remote repository nicknamed "default", but this is not required.
When you push you have the following options:
* push and do not mention where to, in this case the default remote repository will be used (the one nicknamed "default")
* push and specify the nickname of the remote repository to push to
* push and specify the full URL to the remote repository
Hope this answered your question, if not please elaborate.
Jun 30, 2012 at 12:04 PM
Edited Jun 30, 2012 at 12:07 PM


Sorry for the delayed reply ok what I have done for the clone command is this:


    protected void ButtonClone_Click(object sender, EventArgs e)
        startClone.Visible = true;
        startClone.Text = "Cloning Repository  - " + DateTime.Now + " ";
        var path = @"C:\Users\Master\Documents\LocalTest";
        var repoClone = TextBoxClone.Text;
        if (Directory.Exists(repoClone))
            Directory.Delete(repoClone, true);
        var reporepo = new Repository(repoClone);
            new CloneCommand()
                .WithObserver(new DebugObserver())
        TextBoxClone.Text = "";
        endClone.Text = "Repository Cloned   - " + DateTime.Now + " ";


Now this is so far working the way I want it however I could not find an example of the push command or code. so I was wondering if someone could give me an example of how it would be done. The way I would start is by declaring my variables such as:

var pathLcoal = @"C:\Temp\repo1";
Var pathRemot = @"C:\User\Master\Documents\LocalTest";

But after that I do get confused with which command to use from the object browser and how to use it with the variables as there are so many to choose from. I don't want the code done for me but a simple example would be much appreciated.

Kind Regards,


Jul 7, 2014 at 3:53 PM
The same problem here.

I think the repo.Push() method will do the push logic.

repo.Push("REPO URL", pushcommand);

The pushcommand is a new instance of Mercurial.PushCommand.

How can I use this PushCommand to provide the username and password (I have an access token).
I think the push should work after that.

Thank you very much!