Mercurial.Net Clone with http authorization - mercurial

I would like to clone a private repository with the help of mercurial.net.
I know I can clone a repo in the following way:
repository.Clone(repourl, new Mercurial.CloneCommand().WithObserver(new Mercurial.DebugObserver()).WithUpdate(false));
But it fails:
Additional information: abort: http authorization required for repourl
I searched a lot but I can't find a hg command to clone somehow like:
hg clone http://bitbucket.com/user/repo username/passowrd
Is there a way to do this in Mercurial? I don't want to use mercurial.ini file. If yes, how can I implement it with Merucial.Net?
Thank you very much!

I found the right solution.
With Mercurial.NET you can clone repositories easily like you did it in the command like client.
The URL should looks like the following:
http://<USERNAME>:<PASSWORD>#bitbucket.org/user/repo
So you can use this URL to process the clone with the Mercurial.NET library..

Related

Hglib: How to connect to remote repo using over ssh?

Using "raw" mercurial API I can write just something like:
peer = hg.peer(ui.ui(), {}, 'ssh://hg#bitbucket.org/some/project')
After the connection is established, I can work with remote repo.
I'm failing to understand what should work with a remote repo using hglib.
Naïve approach, i.e. using something just as simple as:
hglib.open("ssh://hg#bitbucket.org/some/project")
does not work, and the exception raised does not make anything clearer to me.
My question: With hglib, how can I open connection to a remote ssh-repo?
The hglib documentation is not very wordy about how to use it. The best is to already have your key copied and RSA fingerprint in your ~/.ssh/known_hosts.
But you can clone a repo with:
hglib.clone(source="ssh://hg#bitbucket.org/some/project")
You can of course add destination folder (e.g. dest="/path/to/blah").
If you already have an existing hg repo cloned you can change some settings in your hgrc before trying hglib.open(), so hg uses the ssh url like so:
[ui]
username = some_user
[paths]
default = ssh://hg#bitbucket.org/some/project
EDIT
I think for hg.open to work, you have to have a repo checked out. For me I refer to the path where my repo is cloned. So:
hglib.open('/path/to/cloned/repo')
To do this over SSH you have to edit your /repopath/.hg/hgrc as mentioned above.

Mercurial: how to display message to clients

I am planning to move the central repo, I want to display an error message to anyone that is trying to use: hg pull and tell them the new location of the repo. I wrote a hook that uses events, but none of the events are triggering if someone uses: hg pull
pulling over HTTP
any ideas??
ssg's answer is extremely easy and here is one more easy way based on preoutgoing hook. You need to put this in your .hg/hgrc of your remote repository.
[hooks]
preoutgoing = echo "Repository moved to <url>"

Mercurial, Dreamhost, and Bitbucket

I'm using dreamhost to host a django app, and also the static content for the app. I want to have my static content versioned together with my application code.
Because the dreamhost install of hg is version 1.0.1, to use subrepos at all, one must install ones own version of hg. I have done so.
Once that is done, it is sufficient to create a .hgsub file with the location pointing to another repo, then just add the .hgsub file.
Now, the problem I have is that I want to push to my bitbucket repository, but:
(a) I would need to upgrade my python to be able to use https; and
(b) trying ssh I get the following error:
pushing to ssh://hg#bitbucket.org/marcintustin/oneclickcos
pushing subrepo public to ssh://hg#bitbucket.org/marcintustin/public
remote: conq: repository does not exist.
abort: no suitable response from remote hg!
(To confirm, I have registered my ssh key with bitbucket.)
Any suggestions?
You need to make site a Mercurial repository. Then add a .hgsub file with
project = project
public = public
and make a commit in the site repository. You'll see that it creates and tracks a .hgsubstate file with the changeset hashes of project and public. Make a local clone of site and the subrepositories will follow along nicely.
If that is not enough help, then my suggestion is to read the output of hg help subrepos, the Kick Start guide, and the subrepository wiki page again.
If those guides do not help you along, then come talk to us in #mercurial on irc.freenode.net or on the mailing list. Your question is not very specific and I think it is much easier to discuss this on the proper support channels.

Mercurial, push just to one developer

I'm trying to find out Mercurial advantages and i've read something about commiting between developers without influence on main branch.
I know i have to commit to my local repo, and then what? I don't like to push it to server (then everyone will see it right?), but just to one concrete user. I'd like him to fix something for me and send me back his changeset. Then later I'll push everything to server.
How can i do that? How should i do that in mercurial?
Run hg serve on your system. It will print something like:
listening at http://yoursystem.someplace.com:8000/ (bound to *:8000)
Assuming the other developer also has a clone of the server project, he can run:
hg pull http://yoursystem.someplace.com:8000
to get your updates.
Later you can reverse the process to get his changes back to you.
Hg serve is the easiest way, but if firewalls prevent you from doing that you can create a bundle and send it by email:
hg bundle thebundlefiletocreate.bundle http://URL/of/your/central/repo
then you can email the resulting thebundlefiletocreate.bundle file to the person. They can apply it with:
hg unbundle `thebundlefiletocreate.bundle`
This is a pretty clumsy way to work though. Using hg serve back and forth (as Mark suggested) is better if possible. Ideally you create a repo you can both read/write on a shared server or drive and both push/pull to it.

How to commit to Sourceforge using Mercurial

I have directory named "Proyectos" with Django code inside.
I need to commit the project to Source Forge so my teacher can "download" all the code to his computer.
I think I should use some of these address:
http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/phone-apps-djan (read-only)
ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan (read/write)
I did this on Kubuntu:
lucas#lucas-Satellite-L305:~/Desarrollo/Python/Django/Proyectos$ hg clone http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/django-mercurial
but only the folder is created.
I'm a novice and didn't find how to do this. I followed some tutorials but I can't understand a lot of concepts.
I would appreciate some assistance with this, please.
Thanks in advance.
You have two different address to access your Mercurial repository on sourceforge :
http://phone-apps-djan.hg.sourceforge.net:8000/hgroot/phone-apps-djan/phone-apps-djan (read-only), like said after the address, this one is read-only, it is for everyone to clone your project, so they can see the sources and compile / use it. There's no authentication. When you use this address, Mercurial use the HTTP protocol to pull the changes.
ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan (read/write), you can write to your repository through this address, but you have to authenticate yourself (you'll have to enter your password) and Mercurial use the SSH protocol to do that. You can also see your sourceforge username in the address.
First of all, you must do another clone of your project with the second address, otherwise you won't be able to commit. Just cd in a new directory and do :
hg clone ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan
You should be prompted for your sourceforge account password.
Then, you can cd in the newly created directory, do all your changes, add files, etc. When you're done, you can do a hg commitand then a hg push to publish the modification to your repository. If you add new file to the directory don't forget to do a hg add or hg addremove.
You can find a really good and simple tutorial about mercurial on Hg Init, you should read it and try to understand the workflow before doing anything on sourceforge.
Good luck with your project :)
Many thanks to Rob Sobers and Krtek for their answers. I finally could add all my files to SourceForge. I followed their instructions and everything went fine, although I had some minor complications.
This is the answer to my questions step by step:
Over the folder "Proyectos" I did:
hg clone ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-djan and entered the password for my SourceForge account. A folder "phone-apps-djan" was created.
hg add after I cd into phone-apps-djan and copied all the files of my project into that folder.
hg commit. There was an error at this point: abort: no username supplied (see "hg help config"). So I created a file named .hgrc in my home dir and added these lines:
[ui]
username = my username at sourceforce <the mail address I supplied when registering>
verbose = True
Then I re-entered hg commit.
hg push. The follow error message was displayed: abort: repository default-push not found!. Then I just re-edited the .hgrc file created on the last step and added:
[paths]
default = ssh://lucasab#phone-apps-djan.hg.sourceforge.net/hgroot/phone-apps-djan/phone-apps-dja
I really don't understand what happened here because the .hg directory in my repo already contains a hgrc file with that path :(. Anyway, I did hg push again.
And that was all.
Doing hg clone downloaded the repository to your computer. Now, to update your working directory (so you can work with the files), type hg update.
When you're done making changes, type hg commit to record them. When you're ready upload your changes to SourceForge, type hg push http://path/to/repo. Make sure you push up to the correct repository!