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!