How to upload project code to Mercurial repository?

Added by yonghao wang almost 13 years ago


I have two sets of code in two directory such as /prjcode1 /prjcode2. How can I upload them into my Mercurial Repository? I tried:

hg clone prjcode1

Above command doesn't work. Also can we create two repositories within the same project repository space?

Any help will be appreciated!

Replies (2)

RE: How to upload project code to Mercurial repository? - Added by Chris Cannam almost 13 years ago

Hello there!

The hg clone command is used to make a copy of a repository in a local folder that has no repository at all in it yet. You cannot use it to copy a repository to a remote server using web protocols; instead the normal sequence of events is to create an empty repository on the remote server and then push your changes to it.

When you are using this site, the site itself creates an empty repository for your project automatically after you set up the project, so all you have to do is push your changes to it. To do this from the command line, use

$ cd prjcode1
$ hg push

(If you are using EasyMercurial, then you would do this by going to Remote -> Set Remote Location and entering the URL before hitting the Push button.)

You'll notice that the push URL I gave above was simply that of the "myproject" repository, not a sub-folder of it. Mercurial always clones, pushes and pulls entire repositories, never sub-folders of a repository. As a consequence this means you also cannot create two separate areas within the same repository and refer to them independently. As each project on this site has a single repository created automatically, this also means you cannot have two repositories for a project.

However, you can add any number of sub-projects to a project on this site, and they will all get separate repositories. This is very easy to do (just click "New subproject" on the project home page) and is used by many projects here already.

Note that after you have pushed some changes to a repository that started out empty, you can only subsequently push changes from the same repository or others that have been cloned from it -- that is, you can only push between "related" repositories (with the special case that any empty repository can be pushed to from anything).

Finally -- if you have any more problems, or if you think you've messed up a repository and need to work out how to recover it, please don't hesitate to ask!



RE: How to upload project code to Mercurial repository? - Added by yonghao wang almost 13 years ago

Thanks Chris, It works. I installed EasyMercurial.
By the way when I install pycrypto on my Mac 10.6.7 xcode4, I have to do:
sudo ARCHFLAGS='-arch i386 -arch x86_64' easy_install pycrypto
to make it work.