[client] Fix a minor bug in sync.

When commiting an unclean merge, second parent id should not be
directly set to current master branch head. The master branch
may have been updated after the last merge. In this case, second
parent id will be incorrect.

To solve this, we record the remote head id before merge starts.
When commiting an unclean merge, just use the recorded id as
second parent id. Because the code ensures a new merge won't start
until the last unclean merge is commited, the recorded id is
garanteed to be the correct one.