Painful user experience with 'hg resolve'

Greg Ward greg at gerg.ca
Thu Aug 25 15:33:39 CDT 2011


Here's an interesting tale from the Real World. A developer just came
to me asking how she could have possibly broken the build by
committing merge conflicts, because she followed all the instructions
to the letter. Here's what she did (translated from our workflow to
more normal terminology):

  $ hg update default
  $ hg merge --tool internal:merge <prev branch>
  [...conflicts in Foo.java...]

"OK, let's resolve all conflicts"

  $ hg resolve --all

(This is actually pointless since she has internal:merge configured as
her default merge tool. But it's harmless apart from wasting a few CPU
cycles. And it can be useful for people who merge with internal:merge,
but then resolve with (say) kdiff3. I tend to do that myself.)

"Now I fix my conflicts and make sure the code builds"

  $ vim Foo.java
  $ make

"Great! Now I'll check what other files have conflicts"

  $ hg resolve --all    (**)
  [...messages about Foo.java being merged again and failing again...]

"Good, it worked! Ready to commit!"

  $ hg resolve -m Foo.java
  $ hg commit ...

You probably spotted the problem up there at (**): she wanted "hg
resolve -l", but actually used "hg resolve --all". Note how "resolve
-l" is purely informative with no side effects, but "resolve --all" is
a destructive operation that throws away the user's current conflict
resolutions.

Recap: "hg resolve" does four things:
  1) purely informative, no side effects: "resolve -l"
  2) changes state, but reversible so not very dangerous: "resolve -m"
  3) changes state, also reversible, even less dangerous: "resolve -u"
  4) discards the user's current resolutions, non-reversible,
dangerous: "resolve"

(I think "resolve -m" is a touch more dangerous because it lets you
commit, whereas "resolve -u" blocks committing.) Is it any wonder
people get confused by "hg resolve"?

Here's an idea: add a new command, "hg remerge", to replace the
dangerous meaning of "hg resolve".

Alternately: add "hg mergestate" to report/change merge states and
keep resolve dangerous.

Thoughts?

Greg


More information about the Mercurial-devel mailing list