I have a situation where I’m writing for a system that handles lots of repository, configuration, build and running stuff. There’s a task which might as well be called sync-repository which the user should be able to call to ensure that the latest version of the repository gets to the client.
It’s possible that the repo is already present, in which case I’d like to do a hg update. It’s also possible that the repo isn’t present, in which case I’d like to do a hg clone. The user shouldn’t have to care which is the case. Oh, and the repository is big, so just wiping the directory and cloneing every time isn’t an option.
Does hg provide a single command that clones or updates under the hood, depending on which is appropriate? Or am I going to have to do it with bash?
Yes, but YOU must care and know, does you have clone or no. How you want to manage it?
If you have someconfig-file in form, f.e
Reponame = /full/path/to/clone
you can detect, if clone exist or not and use if-then-else logic. If you haven’t information, you can’t make decision
Add-on
No, the are not such “combined” command in Mercurial core (I hope, they never appear in it), because Mercurial doesn’t go git-way “one command for different unrelated tasks” and follow Unix-way (“Mind your own business!”) more strictly
But, from other side, it give you freedom do what you want – you can define own Mercurial commands (if you asked this), which may be a hodgepodge of unrelated original commands (see Aliases extension (wiki page is slightly outdated) and [alias] section in .hgrc – up to date) and even use shell commands in Mercurial aliases