0

Is there any sample to show how to use Mercurial.net library to push to a remote mercurial repository at Bitbucket?

var workingDir = @"E:\testrepo";
var repository = new Mercurial.Repository(workingDir);
repository.Clone(repourl, new Mercurial.CloneCommand().WithObserver(new Mercurial.DebugObserver()).WithUpdate(false));

For example I added some txt files to local repo, than:

repository.AddRemove(new AddRemoveCommand().WithIncludePattern("*.txt"));
repository.Commit("test commit");     
repository.Push(repourl); //How to push?

I think I have to create a new instance of PushCommand and use it at Push(). But how can I set up the parameters of PushCommand? How to add credentials?

Thank you very much!

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Gábor Domonkos
  • 1,081
  • 1
  • 17
  • 33
  • 1
    The general advice is to first figure out how you would do it using only the command line client, ie. which `hg push XXX` options would you need to add in order to push and add credentials? Then see if there's anything in the PushCommand type that allows for this, otherwise use the generic `.AdditionalArguments` collection to add additional arguments. – Lasse V. Karlsen Jul 25 '14 at 15:11
  • And is it possible that there isn't that kind of hg push option? Everybode write that add credentials to mercurial.ini file which isn't a way for my problem. – Gábor Domonkos Jul 25 '14 at 17:32
  • Yes, that is possible. I have no idea how to do it, but that's a mercurial question, not a mercurial.net question. – Lasse V. Karlsen Jul 25 '14 at 21:27
  • 1
    You can look into the "--config" option, which can be used to specify configuration items as though they were in the config file. For instance `--config security.oauth=123456` would make it seem that you had `oauth=123456` in the `[security]` section of the config file. Might be what you need. – Lasse V. Karlsen Jul 26 '14 at 16:46
  • I got the answer that the tokens are not OAuth tokens. They are simple Basic Auth tokens that are available to team accounts only. Also, Bitbucket uses OAuth 1.0, which offers very strict security all the time So with the help of that token I cannot perform push operation, I have to find another way to solve my problem. Thank you again! – Gábor Domonkos Jul 28 '14 at 15:28

0 Answers0