How can I set default remote repository for mercurial local repository?
It's in the .hg/hgrc file.
[paths]
default = https://myserver/hg/repo1
default:pushurl = /home/me/mytestrepo
Related
I would like to create "secret" commit instead of "draft" commit by default in a mercurial project. Is there any way to configure mercurial so that the default phase is "secret" instead of "draft" ?
From hg help phases
To make yours commits secret by default, put this in your configuration
file:
[phases]
new-commit = secret
I have a local mercurial repository. And I back it up with a clone in a separate folder that lives in my google drive folder. Every now and again I'll go into the google drive repo and do an hg pull, and google drive takes care of backing it up. But I'd like to swap those responsibilities, so that my local is a clone of the one in google drive. In other words, today I do this:
From my local c:\source folder:
do stuff
hg commit
cd c:\googledrive\source
hg pull
I would rather:
From my local c:\source folder:
do stuff
hg commit
hg push
I don't know what to do in my hgrc files to make that happen. Can someone help?
Here's the contents of my c:\source hgrc:
# Generated by TortoiseHg settings dialog
[tortoisehg]
summarylen = 80
engmsg = True
editor = notepad
tabwidth = 2
forcerepotab = False
monitorrepo = localonly
[ui]
username = *****
And this is the contents of the clone in google drive
[paths]
default = c:\source\SwissArmyKnife
Your question reveals an illuminating misconception. When one says that Mercurial is a Distributed Version Control System (DVCS), it means that there is no ‘master‘ repository.
When you type hg push <repo> or hg pull <repo>, then Mercurial compares the changesets in the current repository with those in <repo>, and pushes or pulls changesets to make this one and the remote one consistent. The <repo> can be indicated by a URL (that is, ssh://..., or http://...) or else by a shorthand named in your .hg/hgrc: thus in your case you might add
[paths]
gdrive = c:\googledrive\source
and that would mean that you could write hg push gdrive or hg pull gdrive and Mercurial would know what you meant. You can have multiple paths listed here.
There's one ‘magic’ path, however. If you have a path default then that's the path that Mercurial uses if you don't specify a <repo>.
Thus (finally), if you adjust the .hg/hgrc in your c:\source folder to include
[paths]
default = c:\googledrive\source
then in that directory plain hg push will sync changesets with that drive.
When you clone a repository (hg clone) Mercurial generally adds to your .hg/hgrc a default = ... which indicates the location from which you cloned the repository. Given that default behaviour, it's very natural to think of that repository as the ‘master’ one, but there's nothing fundamentally special about it.
I have a plenty of small projects served by hgwebdir and I want to configure local repos such a way I don't need to create almost similar hgrc files for every project:
[paths]
default = http:/ /myserver.com/projectN
default-push = http:/ /myserver.com/projectN
Can I use some default value like this?
[paths]
default = projectN
Environment variables won't work (win7).
You could use the schemes extension. Put something like this in your ~/.hgrc:
[extensions]
schemes =
[schemes]
my = http://myserver.com
And then your repository hgrc's can contain:
[paths]
default = my://projectN
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?
You can do that by adding the upstream URL to /project/.hg/hgrc like this:
[paths]
default = ssh://test#bitbucket.com/repos/something
upstream = ssh://test#bitbucket.com/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:
default
default-push
Is there any way of having mercurial automatically create hgrc, so that I don't have to create it every time I create a repository?
I'd like hgrc to at least contain the following:
[ui]
username = geo
Can this be done?
You can set the username in mercurial.ini or .hgrc in your Home directory and it will automatically be used for all repositories where it's not overridden by a local hgrc.
In TortoiseHg, this can be set using right-click and choosing TortoiseHg/Global Settings....
See the docs.