Overview

I found this script pretty useful but lacking some basic commands for cleanup like "unregister" or "delete" existing repos, so I decided to try to make my own using the DEFAULT aliases in config file.

Settings in ~/.mrconfig

I've added the following definitions in my ~/.mrconfig file:

[DEFAULT]
# Teach mr how to `mr gc` in git repos.
git_gc = git gc "$@"
unregister = sed -i "\|${PWD//${HOME}\//}|,+2 d" ${MR_CONFIG}
delete = rm -rI "$@" "$PWD" && sed -i "\|${PWD//${HOME}\//}|,+2 d" ${MR_CONFIG}

While the first command is an example in the documentation the other two basically iterate over available repos in "mr ls" to either just remove the entry lines from mrconfig file (mr unregister) or delete existing directory with confirmations (mr delete) and then unregister, you can force using (mr delete -f)

Unregister repos already deleted

I also had the situation that some repositories were already deleted and so "mr unregister" would fail because it could not "change to directory". I've applied the following workaround:

repo_list=$(mr ls 2>&1 | grep "failed to chdir to" | egrep -o "/.*:" | sed "s|/:||" | sed "s|${HOME}/||")
for repo in ${repo_list//${HOME}\//}; do
    sed -i "\|${repo}|,+2 d" ~/.mrconfig
done

I hope this helps other users and hopefully, the new commands will get into the default release eventually.