To get a remote mercurial repo local, we use the clone command. If this repo does not expose a public URL, we can do this clone equally well via ssh:
hg clone ssh://user@server:port//path/to/repo/ /path/to/local/repo
hg clone [OPTION]... SOURCE [DEST]
Notice the double slashes after the server's port, it doesn't work with a single slash.
Theoretically you might as well start hg in serve mode on the remote machine (probably via ssh) for a while, so the local and remote mercurials can communicate via HTTP. But when I tried it it turned out that the HTTP interface is not quite the same as local or ssh and mercurial runs into some issues preventing it from working 100%. So I would suggest relying on the ssh method here as it works best for working over a network.
Once you are done editing the repository locally, you might want to push your changes back to the master repository. This is done with push:
hg push ssh://user@server:port//path/to/repo/
hg push [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]
Mercurial will complain if this push would create multiple heads in the remote repository. Multiple heads means that two intersecting changesets reside within a repository, without being merged. This happens for example if someone else modified a file within the remote/master repository, and you so far haven't pulled this changeset into your local repo for a merge with your work.
push has no -n or --dry-run switch, which would allow you to simulate what is about to happen without actually doing so. Theres a good reason, as hg has a dedicated command to do just that: hg outgoing.
After that you could delete your local repository directory. But that's usually not how people use mercurial. The above clone operation assumes that you have no working copy of the repo on your local computer. But after you followed this guide once, you do, and this enables you to just do an "update" (do not mix this up with mercurials update command) of your local directory/repo. This can be done with pull:
hg pull ssh://user@server:port//path/to/repo/
hg pull [-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]
From the docs: "A pull propagates changesets from a "remote" repository (the source) into a local repository (the destination). It can optionally update the working directory (specify option -u or --update)."
If the remote/master repo has contains no differences against your local copy, mercurial will tell you so and quit without doing anything.
In essence, this post here - without it's focus on how common hg commands look like with ssh - would just be a quick cheat-sheet for what's in A tour of mercurial.