Strategies for push/merge problem?

Martin Geisler mg at daimi.au.dk
Tue Jul 15 11:04:01 CDT 2008


Douglas Philips <dgou at mac.com> writes:

> On or about 2008 Jul 15, at 9:47 AM, Adrian Buehlmann indited:
>
>> "Cheap" commits doesn't mean they are allowed to be brain damaged.
>
> Sure it does. I practice test first design, so I commit tests that
> break because the code isn't there yet. And then if I don't like the
> API, I can try again, and when I like the testing API, I can strip
> the other experiments before I push, but I certainly do commit the
> API before I decide to bother implementing it. I don't push that out
> to anyone else until I have the concomitant implementation.
>
> Of course if I wanted to look like a super-programmer I'd use MQ to
> squash it all down into one diamond-polished-all-in-one-athena-from-
> the-forehead-of-zeus changeset that made it look like I had it all
> figured out in advance (in that case I wouldn't need a version
> control system in the first place, but I exaggerate for effect). :)

There is no need to compress things to a *single* changeset. I have
written tests before the code a couple of times, and with MQ I can do
that at avoid breaking the test suite:

hg qnew new-feature
... write stub functions ...
hg qrefresh
hg qnew tests
... write tests
hg qrefresh

It is then a matter of going back and forth between the two patches
and updating them until the code align with the tests. When the two
patches are converted back to Mercurial changesets you get what Adrian
wants while still having written the tests before the code.

The constant qpop/qpush takes a bit to get used to, but I find it okay
to work with.

If the code and tests live in different files, you can use "qpop -f"
and "qpush -f" to jump back and forth and still apply the changes in
the correct patch, even if you by mistake edit the tests while the
new-feature patch was applied (or the other way around).

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.


More information about the Mercurial mailing list