Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2008
    Posts
    1

    Default Is there a way to avoid simple C/C++ conflicts?

    Hi there,

    So I often come across the situation where I'm performing a 3-way merge of C/C++ files and a conflict is flagged because both of the changed files have added a new line or lines at the same point in the file.

    I realise that this is actually a conflict, but there are cases in C/C++ where this can be trivially resolved. Common cases I see are where multiple include directives are added to a file or multiple variable declarations are added at the same point in a header file.

    As an example

    Base

    Code:
    #inlcude "foo.h"
    My Change

    Code:
    #include "foo.h"
    #include "bar.h"
    Their change

    Code:
    #include "foo.h"
    #include "baz.h"
    Result

    Code:
    #include "foo.h"
    --- This section marked as conflict ---
    #include "bar.h"
    #include "baz.h"
    --- This section marked as conflict ---
    Therefore, is there an option I can set somewhere (possibly C/C++ specific) to supress these simple conflicts?

    Any help much appreciated.

    Regards

    Alan

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    2,519

    Default

    Sorry, no. Anything like that would require language-specific knowledge, which BC doesn't currently support.

    You should be able to easily take both lines with the "Take Left then Right" or "Take Right then Left" commands though.
    Zoë P Scooter Software

  3. #3
    Join Date
    Oct 2007
    Location
    Pennsylvania
    Posts
    1,772

    Default

    I don't know why you would want to, but you could very easily create a regular expression grammar element for include directives (^#include .*$) and mark it as unimportant...then ignore the unimportant changes.

    The nice thing about putting it in its own grammar element is that you can always go back to your session settings to toggle the importance setting to choose whether or not you want include directives to trigger a conflict.

    The downside of marking a grammar element as unimportant is that you will lose the change. Instead of taking both sides automatically, BC3 will take the center when unimportant conflicts are ignored.
    BC v4.0.7 build 19761
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

  4. #4
    Join Date
    Oct 2007
    Location
    Pennsylvania
    Posts
    1,772

    Default

    Now, an enhancement request might be to add a merge option to grammar elements. By default, a conflict is raised. But if you configure BC to take a different action on a conflict section based on the type of grammar element in the conflict, that would actually accomplish what you are looking for...

    Raise Conflict
    Take Left
    Take Center
    Take Right
    Take Left Then Right
    Take Right Then Left

    I'm not sure that there would be a high demand for such functionality, however. I doubt that it would get implemented.
    BC v4.0.7 build 19761
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •