0

I would like to create a sample application which can clones the user's repository, add some files in it, and push back to the remote repository. I used Mercurial.NET C# API to create this application.

       string repoUrl = "https://bitbucket.org/USERNAME/REPONAME";

        var repoPath = @"THE LOCAL PATH";
        if (Directory.Exists(repoPath))
            Directory.Delete(repoPath, true);
        Directory.CreateDirectory(repoPath);
        var repo = new Mercurial.Repository(repoPath);

        repo.Clone(repoUrl, new CloneCommand().WithObserver(new DebugObserver()).WithUpdate(false));

        Random rand = new Random();

        string filename = "data" + rand.Next(0, 1000).ToString() + ".txt";

        using (StreamWriter _testData = new StreamWriter(@"E:\Lombiq\TestRepos\testrepo3\" + filename))
        {
            _testData.WriteLine("some text"); // Write the file.
        }
        repo.AddRemove(new AddRemoveCommand()
.WithIncludePattern("data*.txt"));

        repo.Commit("test commit");

        repo.Push(repoUrl); //How to add credentials?

I successfully authenticated the user with the help of CSharp.Bitbucket (https://github.com/scottksmith95/CSharp.Bitbucket) so I have got a token value and a token secret.

How can I use these values to push back the content of the local repo to the remote repo with the new file in it? And how can I use the token value and token secret to perform this operation?

Thank you very much!

Gábor Domonkos
  • 1,081
  • 1
  • 17
  • 33
  • How would you authenticate with the command line client? – Lasse V. Karlsen Jul 07 '14 at 22:47
  • I created an application at bitbucket and use that application to authenticate the user, so I got a token. And I would like to use that ticket, not the username/password combination to push to user repo. – Gábor Domonkos Jul 08 '14 at 08:35
  • You're not answering my question. How do you authenticate against bitbucket with the command line client, ie. hg.exe, using that ticket? *can* you authenticate using it with the command line client? If so, how, do you need to edit some configuration file, can you pass some parameters to the client? – Lasse V. Karlsen Jul 08 '14 at 11:22
  • Unfortunately I don't know how to use the command line client to authenticate with that ticket and I haven't find any example to this problem. Do you have any idead how to use command line to authenticate with token? – Gábor Domonkos Jul 24 '14 at 13:58
  • None at all, but if the command line can't do it, then Mercurial.Net can't do it, because it is simply a wrapper for the command line client. So you need to figure out if, and if so, how, to do it with the command line client first, then doing it with Mercurial.Net is easy afterwards. – Lasse V. Karlsen Jul 25 '14 at 07:11

0 Answers0