MR(1) | mr | MR(1) |
mr - a tool to manage all your version control repos
mr [options] checkout
mr [options] update
mr [options] status
mr [options] clean [-f]
mr [options] commit [-m "message"]
mr [options] record [-m "message"]
mr [options] fetch
mr [options] push
mr [options] diff
mr [options] log
mr [options] grep pattern
mr [options] run command [param ...]
mr [options] bootstrap src [directory]
mr [options] register [repository]
mr [options] config section ["setting=[value]" ...]
mr [options] action [params ...]
mr [options] [online|offline]
mr [options] remember action [params ...]
mr is a tool to manage all your version control repos. It can checkout, update, or perform other actions on a set of repositories as if they were one combined repository. It supports any combination of Subversion, git, cvs, mercurial, bzr, darcs, fossil and veracity repositories, and support for other version control systems can easily be added.
mr cds into and operates on all registered repositories at or below your working directory. Or, if you are in a subdirectory of a repository that contains no other registered repositories, it will stay in that directory, and work on only that repository,
mr is configured by .mrconfig files, which list the repositories. It starts by reading the .mrconfig file in your home directory, and this can in turn chain load .mrconfig files from repositories. It also automatically looks for a .mrconfig file in the current directory, or in one of its parent directories.
These predefined commands should be fairly familiar to users of any version control system:
If a repository isn't checked out yet, it will first check it out.
The optional -f parameter allows removing the files as well as printing them.
The optional -m parameter allows specifying a commit message.
The optional -m parameter allows specifying a commit message.
These commands are also available:
mr understands several types of sources:
The directory will be created if it does not exist. If no directory is specified, the current directory will be used.
As a special case, if source "src" includes a repository named ".", that is checked out into the top of the specified directory.
The mrconfig file that is modified is chosen by either the -c option, or by looking for the closest known one at or in a parent of the current directory.
For example, to add (or edit) a repository in src/foo:
mr config src/foo checkout="svn co svn://example.com/foo/trunk foo"
To show the command that mr uses to update the repository in src/foo:
mr config src/foo update
To see the built-in library of shell functions contained in mr:
mr config DEFAULT lib
The mrconfig file that is used is chosen by either the -c option, or by looking for the closest known one at or in a parent of the current directory.
Actions can be abbreviated to any unambiguous substring, so "mr st" is equivalent to "mr status", and "mr up" is equivalent to "mr update"
Additional parameters can be passed to most commands, and are passed on unchanged to the underlying version control system. This is mostly useful if the repositories mr will act on all use the same version control system.
If a number is specified, will recurse into repositories at most that many subdirectories deep. For example, with -n 2 it would recurse into ./src/foo, but not ./src/packages/bar.
Note that running more than 10 jobs at a time is likely to run afoul of ssh connection limits. Running between 3 and 5 jobs at a time will yield a good speedup in updates without loading the machine too much.
Ignored when being run from subdirs of a repo unless --top is enabled.
This is used by the "cache-mr-status.sh" shell extension.
Ignored when being run from subdirs of a repo unless --top is enabled.
This is most useful when the "cache-mr-status.sh" shell extension is enabled.
This may be useful to users of the "cache-mr-status.sh" shell extension.
This is used by the "cache-mr-status.sh" shell extension.
Here is an example .mrconfig file:
[src] checkout = svn checkout svn://svn.example.com/src/trunk src chain = true [src/linux-2.6] checkout = git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git && cd linux-2.6 && git checkout -b mybranch origin/master
The .mrconfig file uses a variant of the INI file format. Lines starting with "#" are comments. Values can be continued to the following line by indenting the line with whitespace.
The "DEFAULT" section allows setting default values for the sections that come after it.
The "ALIAS" section allows adding aliases for actions. Each setting is an alias, and its value is the action to use.
All other sections add repositories. The section header specifies the directory where the repository is located. This is relative to the directory that contains the mrconfig file, but you can also choose to use absolute paths. (Note that you can use environment variables in section names; they will be passed through the shell for expansion. For example, "[$HOSTNAME]", or "[${HOSTNAME}foo]").
Within a section, each setting defines a shell command to run to handle a given action. mr contains default handlers for "update", "status", "commit", and other standard actions.
Normally you only need to specify what to do for "checkout". Here you specify the command to run in order to create a checkout of the repository. The command will be run in the parent directory, and must create the repository's directory. So use "git clone", "svn checkout", "bzr branch" or "bzr checkout" (for a bound branch), etc.
Note that these shell commands are run in a "set -e" shell environment, where any additional parameters you pass are available in $@. All commands other than "checkout" are run inside the repository, though not necessarily at the top of it.
The "MR_REPO" environment variable is set to the path to the top of the repository. (For the "register" action, "MR_REPO" is instead set to the basename of the directory that should be created when checking the repository out.)
The "MR_CONFIG" environment variable is set to the .mrconfig file that defines the repo being acted on, or, if the repo is not yet in a config file, the .mrconfig file that should be modified to register the repo.
The "MR_ACTION" environment variable is set to the command being run (update, checkout, etc).
A few settings have special meanings:
Here are two examples. The first skips the repo unless mr is run by joey. The second uses the hours_since function (included in mr's built-in library) to skip updating the repo unless it's been at least 12 hours since the last update.
[mystuff] checkout = ... skip = test `whoami` != joey [linux] checkout = ... skip = [ "$1" = update ] && ! hours_since "$1" 12
Another way to use skip is for a lazy checkout. This makes mr skip operating on a repo unless it already exists. To enable the repo, you have to explicitly check it out (using "mr --force -d foo checkout").
[foo] checkout = ... skip = lazy
Note that if a repository is located in a subdirectory of another repository, ordering it to be processed earlier is not recommended.
Unlike everything else, "include" does not need to be placed within a section.
mr ships several libraries that can be included to add support for additional version control type things (unison, git-svn, git-fake-bare, git-subtree). To include them all, you could use:
include = cat /usr/share/mr/*
See the individual files for details.
Unlike most other settings, this can be specified multiple times, in which case the chunks of shell code are accumulatively concatenated together.
Note that running more than 10 jobs at a time is likely to run afoul of ssh connection limits. Running between 3 and 5 jobs at a time will yield a good speedup in updates without loading the machine too much.
Internally, mr has settings for "git_update", "svn_update", etc. To change the action that is performed for a given version control system, you can override these VCS specific actions. To add a new version control system, you can just add VCS specific actions for it.
This is useful for applying modifier commands such as nice, ionice or nocache. To apply modifier commands, ensure you end this suffix with a shell line continuation character (the backslash "\" in most shells) so that the line ending added by this suffix is ignored.
This is used by the mr "upgrade" extension.
Since mrconfig files can contain arbitrary shell commands, they can do anything. This flexibility is good, but it also allows a malicious mrconfig file to delete your whole home directory. Such a file might be contained inside a repository that your main ~/.mrconfig checks out. To avoid worries about evil commands in a mrconfig file, mr defaults to reading all mrconfig files other than the main ~/.mrconfig in untrusted mode. In untrusted mode, mrconfig files are limited to running only known safe commands (like "git clone") in a carefully checked manner.
To configure mr to trust other mrconfig files, list them in ~/.mrtrust. One mrconfig file should be listed per line. Either the full pathname should be listed, or the pathname can start with ~/ to specify a file relative to your home directory.
The ~/.mrlog file contains commands that mr has remembered to run later, due to being offline. You can delete or edit this file to remove commands, or even to add other commands for 'mr online' to run. If the file is present, mr assumes it is in offline mode.
mr can be extended to support things such as unison and git-svn. Some files providing such extensions are available in /usr/share/mr/. Some files providing mr shell extensions are in /usr/share/mr.sh/. See the documentation in the files for details about using them.
mr returns nonzero if a command failed in any of the repositories.
Copyright 2007-2011 Joey Hess <joey@kitenet.net>
Licensed under the GNU GPL version 2 or higher.
<https://myrepos.branchable.com/>
2018-07-26 | perl v5.26.2 |