Fossil merge conflict output is very informative and includes a common ancestor section:
======= COMMON ANCESTOR
|I wonder if it's possible to use "||" for the leading marker instead of "="?|
This would make it agree with Git (diff3 mode), which in turn helps with visual tools that automatically highlight conflict sections and help in resolving it.
Basically, make the common ancestor header look something like:
||||||| COMMON ANCESTOR
I wonder if it's possible to use "" for the leading marker instead of "="?
Should read "|" for the pipe-char.
Looks like our Markdown parser took the unescaped pipe for a table column separator. Interesting...
What tool are you using that doesn't understand Fossil's conflict markers? I'm pretty sure it's an old convention predating Fossil, which implies that it's your merge tool that needs to be changed, not Fossil.
Perhaps it was not clear from my orginal post. Here's the comparison between conflict sections produced by Fossil vs Git.
Fossil conflict, src/merge3.c:
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<<<<< puts 'hola world' ======= COMMON ANCESTOR content follows ============================ puts 'hello world' ======= MERGED IN content follows ================================== putd 'hello mundo' >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Git conflict (diff3-style), Git - Advanced Merging:
<<<<<<< ours puts 'hola world' ||||||| base puts 'hello world' ======= puts 'hello mundo' >>>>>>> theirs
You can see that both formats are very much similar. However, the
COMMON ANCESTOR section is marked differently. Git uses "|" (pipe-char) leading marker for the ancestor section and "=" for the merged-in section. Fossil uses "=" for both.
I could not find any specs that generally govern the formatting of the common ancestor section.
Git's convention does have two advantages:
oursthe the left,
theirson the right
Fossil's convention holds a descriptive advantage -- the verbose labels make section contents more clear.
TLDR; By adopting "|" for Fossil's common ancestor section leading mark, it would equally simplify the parsing.
So, what I ask is to have Fossil output the confict with a format like this (?maybe a config option):
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<<<<< puts 'hola world' ||||||| COMMON ANCESTOR content follows |||||||||||||||||||||||||||| puts 'hello world' ======= MERGED IN content follows ================================== putd 'hello mundo' >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Git's convention is the most visible online and thus has a better chance for support by visual tools.
Are you suggesting merging the merge marker conventions? ;^)
I think this is a good change. I definitely prefer our merge marker format over git's format, but that doesn't mean we can't meet in the middle, and your proposal certainly does that.
Please allow me to disagree that this change simplifies parsing tools. I dislike parsing tools that take shortcuts since they are susceptible to false positives. It is best to parse the whole line. Better still is to maintain state so that, for example, the
>>>>>>> merge marker means nothing unless it comes after
======= without any intervening merge markers. Don't get me wrong; this is not a complaint. It's just a word of caution.
I would like to second this call.
As far as I can tell, use of the pipe character has nothing to do with
Git, per se. Rather, it is a Gnu
Accordingly, Emacs' Simple Merge mode (
smerge-mode.el) has matched
conflict markers in source files like so:
(defconst smerge-begin-re "^<<<<<<< \\(.*\\)\n") (defconst smerge-base-re "^||||||| \\(.*\\)\n") (defconst smerge-lower-re "^=======\n") (defconst smerge-end-re "^>>>>>>> \\(.*\\)\n")
since approx. 1999.
In my opinion, a
diff3-conflict-markers setting defaulting to
would be a sensible addition.
In the meantime, adding the following to your dotemacs is a possible workaround:
(defun smerge-try-smerge-mode () (save-excursion (goto-char (point-min)) (when (re-search-forward "^<<<<<<< " nil t) (require 'smerge-mode) (when (eq (vc-deduce-backend) 'Fossil) (mapc #'make-variable-buffer-local '(smerge-base-re smerge-lower-re)) (setq smerge-base-re ; "^||||||| \\(.*\\)\n" "^======= COMMON ANCESTOR \\(.*\\)\n" smerge-lower-re ; "^=======\n" "^======= MERGED IN .*\n")) (smerge-mode 1)))) (add-hook 'find-file-hook 'smerge-try-smerge-mode t)
This assumes you have vc-fossil.el: