Handling if's with parenthesis

Matt Mackall mpm at selenic.com
Fri Dec 5 17:11:33 UTC 2008


On Fri, 2008-12-05 at 14:54 +0100, Mads Kiilerich wrote:
> E.L.K. wrote:
> > Now we have next contents of this file:
> > int main(){
> >
> >   if (true)
> >     somefunc();
> >     somefunc2();
> >
> >
> >
> > }
> >
> > Which is clearly not what was intended.
> >
> > How thigs like that should be handled?
> >   
> 
> The obvious solution is to use a programming language without braces and 
> with proper semantics of indentation ;-)
> 
> The behaviour you see is works-as-designed - see 
> http://www.selenic.com/mercurial/bts/issue1295 msg7160. Your case is a 
> variant of the example in msg7101.
> 
> You can fix that by disabling premerge for your merge tool - see 
> http://www.selenic.com/mercurial/wiki/index.cgi/MergeToolConfiguration .

The trade-off is that the average person's error rate when faced with a
large number of 'trivial' merges will likely be higher than the
automated tool's error rate.

For instance, I suspect my error rate when fiddling with kdiff3 on the
rare occassions it pops up for me is something like 10% or more.
Meanwhile, I don't think I've yet seen a merge error while managing the
main Mercurial repo, so I think that error rate is < 1%. If I were
reviewing all those merges by hand, I'm pretty sure it would be worse
rather than better.

Merging is hard. Errors will happen occasionally regardless of what tool
or process you're using.

Lastly, I wrote a quick test and discovered that the internal merge
properly flags this error.. but kdiff3 (which is slightly more
optimistic) silently merges it.

internal:merge gives:

int main() {

  if (true)
    somefunc();
<<<<<<< local
    somefunc2();
  }
=======
>>>>>>> other
}

kdiff3 gives:

int main() {

  if (true)
    somefunc();
    somefunc2();
}

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list