Can I make 'one-shot' mr actions?

Evade Flow evadeflow at gmail.com
Sat Aug 22 22:11:13 CEST 2015


Poking around the latest version of the mr script on github, I see that it
has a --minimal option that turns output like this:

% mr hello Moon
mr hello: /home/acme/projects/rtt/ogm/../.repos
Hello, Moon!

mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-common, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-config-management, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-data-analysis, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-dataprocessing, skipping
mr hello: no defined action for git repository
/home/acme/projects/rtt/ogm/../.repos/rtt-datapump, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-event-server, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-gameclock, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-health-monitor, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-ogm, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-ogmlive, skipping
mr hello: no defined action for hg repository
/home/acme/projects/rtt/ogm/../.repos/rtt-vds, skipping
mr hello: finished (1 ok; 11 skipped)


into this:

% mr hello Sun
mr hello: /home/mmes/projects/bns/mws/nfl/../.repos
Hello, Sun!

This is exactly what I want! I can stuff arbitrary helper commands into a
'dummy' repository defined like this:

[../.repos]
test = test -e "${MR_REPO}/.e7905c59-c748-4ef2-98b6-0251455ed66c"
commit = :
diff = :
log = :
push = :
record = :
register = :
status = :
update = :
hello = echo "Hello, ${1:-Stranger}!"
goodbye = echo "Goodbye, ${1:-Stranger}!"

and I won't get a 'wall' of "no defined action" messages. I forked the mr
repository on github just to apply this trivial patch:

--- mr.orig     2015-08-22 14:46:11.040622441 -0400
+++ mr  2015-08-22 15:06:54.738551311 -0400
@@ -591,7 +591,7 @@
 # configurables
 my $config_overridden=0;
 my $verbose=0;
-my $minimal=0;
+my $minimal=1;
 my $quiet=0;
 my $stats=0;
 my $force=0;

I guess the question I asked previously really boils down to this: can I
make --minimal the default by editing .mrconfig?  I didn't see any
assignments to $minimal outside of its initialization to 0 and the getopts()
function, so... it doesn't appear override-able in the config file. I guess
a follow-up question is: would a patch to make the value of --minimal
override-able in .mrconfig be of interest?

As a parting shot, I want to say how totally great I think mr is. It solves
a huge problem that the Age of the DVCS has thrust upon software companies,
namely: DVCes are much-loved, but they don't handle large, monolithic
repositories very well. A common 'solution' to this has been to bust code
bases up into dozens of 'micro repos', so us developers can continue using
the DVCS tools we love so much. But that leaves a void for operations that
need to be applied across all repositories as a unit.

It used to be we would just svn tag 'The Code'—all of it—and be done. Or,
to put it more generically, we would vcs <verb> 'The Code'. But the lack of
(viable) git or hg <verb>-all-the-the-repos mechanisms has led to an
explosion of ad hoc shell scripts, fabfiles and various other workarounds
to allow development teams to invoke VCS operations targeting a *collection*
of repositories. Most these pointy little hacks have little value beyond
the team/project that spawned them.  mr fills that same role neatly, with
minimal ceremony, and its bare-bones, data-driven approach makes it useful
in a variety of different projects. Moreover, it makes me jealous of two
things: 1) that I didn't think of the idea myself, and 2) the knowledge
that—even if I *had* thought of it—I wouldn't have been capable of coming
up with such a supple, sublime design. I salute you, Joey Hess!



On Fri, Aug 21, 2015 at 1:07 PM, Evade Flow <evadeflow at gmail.com> wrote:

> Doh—I had a bonus 'not' in the most important sentence in my post. In case
> it wasn't clear from the context, I meant to ask:
>
> Is there some way I can coax mr into running an action just once, instead
> of once per repository?
>
> On Fri, Aug 21, 2015 at 9:26 AM, Evade Flow <evadeflow at gmail.com> wrote:
>
>> Greetings! I recently discovered mr, and—for me—it's the 'missing link'
>> for dealing with projects comprised of a dozen or more 'micro repos'. I
>> really appreciate how easy it is to create custom actions that target
>> *all* repositories. I'm at a point now where I'd like to implement some
>> convenience functions for various repo-juggling tasks that only target a
>> subset of repositories—or no repositories at all. I'm basically looking for
>> a way to include arbitrary shell functions in my .mrconfig and invoke
>> them the same as any other action, but with arguments specifying which
>> repo(s) they should target. What I'm trying to achieve is something like
>> this:
>>
>> $ mr hide rtt-gameclock bugfix-reboot
>> mr hide: /home/acme/projects/rtt/../.repos/rtt-gameclock
>> Rename /home/acme/projects/rtt/../.repos/rtt-gameclock to
>> rtt-gameclock.bugfix-reboot [y/N]? y
>> Renamed rtt-gameclock to rtt-gameclock.bugfix-reboot!
>>
>> $ mr unhide
>> 1. rtt-event-server.wip-replay
>> 2. rtt-gameclock.bugfix-reboot
>> 3. rtt-vds.wip-pcl-overlay
>>
>> $ mr unhide 2
>> Rename /home/acme/projects/rtt/../.repos/rtt-gameclock.bugfix-reboot to
>> rtt-gameclock [y/N]? y
>> Renamed rtt-gameclock.bugfix-reboot to rtt-gameclock!
>>
>>
>> Basically, I am (among other things) trying to make it easy for my team
>> to 'shelve' work by temporarily renaming a working copy and re-cloning it.
>> We're using Mercurial, and several team members prefer to use fresh clones
>> as 'topic branches' rather than trying to make sense of hg bookmarks. But
>> this is just one such task that I'd like to have mr wrap.
>>
>> Obviously, I could just  create a separate Bash script for these
>> functions, and perhaps that's what I'll wind up doing; but I like the
>> consistency of having all repo management commands be spelled mr
>> <something>, and it would streamline the setup instructions for
>> developers, too, if everything were wrapped up in the .mrconfig file.
>>
>> Is there some way I can coax mr into not running an action just once,
>> instead of once per repository?
>>
>> Any insight much appreciated—thanks!
>>
>
>


More information about the vcs-home mailing list