Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Mercurial upstream

I created local hg repository for new project: hg init ; hg addremove, then I created empty upstream repo, and pushed first version there: hg push https://remoterepo.

Now, I want to set that https://remoterepo as default upstream, so I can just do hg push/pull without giving it.

I was surprised Google did not give me a straight answer with "set mercurial upstream", and I didn't find a direct answer here at SO either. So, for the benefit of all the people using SO as a howto, what's the right way to do this?

like image 652
hyde Avatar asked Oct 08 '12 08:10

hyde


1 Answers

You can do that by adding the upstream URL to /project/.hg/hgrc like this:

[paths]
default = ssh://[email protected]/repos/something
upstream = ssh://[email protected]/repos/something_else

and now upstream is an alias for repo something_else which you can then pull from or push to:

hg pull upstream
hg push upstream

Reference

hg help urls:

URLs can all be stored in your configuration file with path aliases under the [paths] section like so:

  [paths]
  alias1 = URL1
  alias2 = URL2
  ...

You can then use the alias for any command that uses a URL (for example hg pull alias1 will be treated as hg pull URL1).

Two path aliases are special because they are used as defaults when you do not provide the URL to a command:

  1. default
  2. default-push
like image 156
K Z Avatar answered Oct 21 '22 10:10

K Z