Commit Graph

122 Commits

Author SHA1 Message Date
Siddharth Agarwal
82f2aec334 filemerge: also return whether the merge is complete
In future patches, we'll pause merges after the premerge step. After the
premerge step we'll return complete = False.
2015-10-11 12:56:21 -07:00
Siddharth Agarwal
da75e232c9 filemerge: add a wrapper around the filemerge function
We'll introduce a separate premerge function that calls the same code.
2015-10-11 12:31:08 -07:00
Siddharth Agarwal
056b42f09f filemerge: clean up temp files in a finally block
This isn't really a big deal because the temp files are created in $TMPDIR, but
it makes some upcoming work simpler.
2015-10-07 21:51:24 -07:00
Siddharth Agarwal
4376011dff filemerge: move post-merge checks into a separate function
This makes the overall filemerge function easier to follow, and makes upcoming
work simpler.
2015-10-07 23:35:30 -07:00
Siddharth Agarwal
3fbcf75f0f filemerge._xmerge: drop no longer necessary 'if r:' check
Cleanup from an earlier patch to make premerge be directly called from the main
filemerge function.
2015-10-08 14:18:43 -07:00
Siddharth Agarwal
1cb9cb73fe filemerge._idump: drop no longer necessary 'if r:' check
Cleanup from an earlier patch to make premerge be directly called from the main
filemerge function.
2015-10-08 14:17:31 -07:00
Siddharth Agarwal
3f7b11ab57 filemerge._merge: drop no longer necessary 'if r:' check
Cleanup from an earlier patch to make premerge be directly called from the main
filemerge function.
2015-10-08 14:16:19 -07:00
Siddharth Agarwal
3d95b69af3 filemerge: call premerge directly from main merge function
The merge code currently does (in pseudocode):

for f in tomerge:
    premerge f
    merge f

We'd like to change this to look more like:

for f in tomerge:
    premerge f

for f in tomerge:
    merge f

This makes sure as many files are resolved as possible before prompting for the
others. This restructuring is also necessary for custom merge drivers.

This function separates out the premerge step from the merge step. In future
patches we'll actually turn these into separate steps in the merge driver.

The 'if r:' occurrences will be cleaned up in subsequent patches.
2015-10-07 21:22:16 -07:00
Siddharth Agarwal
1f3c72862f filemerge: move precheck to before files are written out
This is much simpler, and also avoids unnecessary disk IO.
2015-10-07 21:28:43 -07:00
Siddharth Agarwal
545f983ef8 filemerge: move 'merging' output to before file creation
This has no visible impact but makes some future work simpler.
2015-10-07 22:58:52 -07:00
Siddharth Agarwal
7ea14fa915 filemerge.filemerge: make a tuple containing merge paths on disk
We're going to need this same tuple elsewhere.
2015-10-07 21:21:56 -07:00
Siddharth Agarwal
6b1725d26f filemerge: switch trymerge boolean to mergetype enum
trymerge = False becomes mergetype = nomerge, and trymerge = True becomes
mergetype = fullmerge or mergeonly, depending on whether a premerge happens.
2015-10-07 16:14:57 -07:00
Siddharth Agarwal
36f6f22a1e filemerge: add some merge types
We're going to turn the 'trymerge' boolean into a 'mergetype' enum with these
three possible values.
2015-10-07 15:13:41 -07:00
Siddharth Agarwal
dbdf9ec262 filemerge: run symlink check for :merge3
Just like :merge, :merge3 doesn't support merging symlinks.
2015-10-07 00:27:23 -07:00
Siddharth Agarwal
bedfe886f8 filemerge: print correct name of tool for symlink checks
Earlier we'd print ':merge' even if the tool was something else like ':union'.
That's clearly a bug.
2015-10-07 00:24:44 -07:00
Siddharth Agarwal
30c73e4dd2 filemerge: normalize 'internal:foo' names to ':foo'
In upcoming patches we're going to present these names in the UI -- it would be
good not to present deprecated names.
2015-10-07 00:01:16 -07:00
Siddharth Agarwal
aef73939f9 filemerge: use symlinkcheck for :merge and :union
This exposes a couple of bugs, both of which will be fixed in upcoming patches.
2015-10-06 22:57:21 -07:00
Siddharth Agarwal
258f79e559 filemerge: add a precheck for symlinks
This will be used by internal merge tools.
2015-10-06 22:56:33 -07:00
Siddharth Agarwal
11ffaa85a2 filemerge: call precheck if available
In upcoming patches we'll define a precheck function for some merge tools.
2015-10-06 22:55:21 -07:00
Siddharth Agarwal
3226585b5b filemerge: add a before-merge callback to internal merge tools
We're going to separate the pre-merge and merge steps for merge tools. The
merge step will be specific to the tool, but the pre-merge step will be common
to all merge tools that need it.

However, some merge tools run checks *before* the pre-merge step. This callback
will allow that to continue to work.
2015-10-06 22:54:14 -07:00
Siddharth Agarwal
6e9048d788 filemerge: indent filemerge.filemerge
This will make upcoming patches much easier to review.
2015-10-06 17:39:13 -07:00
Jordi Gutiérrez Hermoso
ccabd73556 filemerge: add non-interactive :merge-local and :merge-other
There are two non-interactive internal merge tools, :other and :local,
but they don't really merge, they just pick all changes from the local
or other version of the file. In some situations, it is known that we
want a merge and also know that all merge conflicts should be resolved
in one direction. Although external merge tools can do this, sometimes
it can be convenient to do so from within hg, without invoking a merge
tool. These new :merge-local and :merge-other tools can do just that.
2015-09-10 09:41:11 -04:00
Erik Huelsmann
5e269b46c8 filemerge: add 'union' merge to internal merge tool
'union merge' is a merge strategy which adds both left and right hand side
of a conflict region. Git implements this merge strategy which is very
practical to have for merging e.g. the Changelog file.
2015-08-16 10:19:00 +02:00
Erik Huelsmann
b74b3ab292 filemerge: split internal merge into api entry point and internal helper
This is a step toward adding 'union merge' to the internal merge tool.

'union merge' is a merge strategy which adds both left and right hand side
of a conflict region.  Git implements this merge strategy which is very
practical to have for merging to e.g. the Changelog file.
2015-08-16 00:24:29 +02:00
Gregory Szorc
1a6a1553f7 filemerge: use absolute_import 2015-08-08 19:15:09 -07:00
Matt Mackall
647579e3af filemerge: mark internal-only config option 2015-06-25 17:46:55 -05:00
Yuya Nishihara
71c4aa007f templater: remove noop calls of parsestring(s, quoted=False) (API)
Since e926f2ef639a, parsestring(s, quoted=False) just returns s.
2015-05-04 10:01:03 +09:00
Mads Kiilerich
17c4f7c523 merge: better debug messages before/after invoking external merge tool 2015-03-19 22:22:50 +01:00
Gregory Szorc
bfb9e38893 help.merge-tools: do not double document merge tools
Merge tools were being double documented in help system output due
to functions being defined under multiple names in the merge tools
dictionary.

Establish a new dictionary for just the tools to document and
use it from the help system so we don't get double output.

Double documentation likely plagues other auto-documented items
as well. It might be a good idea to eventually compare function
instances to filter out duplicate entries from dictionaries
passed to ``makeitemsdoc``. However, without an easy way to break
ties, this may result in some functions being advertised over
their modern equivalents. This would be a noble patch series.
But it isn't one this author is willing to tackle at this time.
2015-02-09 23:07:39 -08:00
Yuya Nishihara
ceda6fbba9 util.system: use ui.system() in place of optional ui.fout parameter 2014-11-08 13:06:22 +09:00
Matt Harbison
4db0fae74a filemerge: split the logic for finding an external tool to its own function
This will be used by extdiff in an subsequent patch.
2014-11-02 14:58:50 -05:00
Mads Kiilerich
26870bfa1d filemerge: switch the default name for internal tools from internal:x to :x 2014-09-28 17:15:28 +02:00
Mads Kiilerich
59a85f7e89 filemerge: introduce :x as short version of internal:x merge tool name
"internal:" is so much typing - it is frequently specified on the command line
and gives options that are longer than any other I have seen.
2014-09-28 17:15:25 +02:00
Pierre-Yves David
bbc45b832a merge-tools: add a premerge=keep-merge3 config option
This value leaves premerge markers that includes the merge base too. This is a
the same as what `internal:merge3` would do.
2014-08-04 16:32:41 -07:00
Pierre-Yves David
eab8e275dd merge-tools: make premerge valid values extensible
We want to introduce a version leaving merge3 style markers.
2014-08-04 16:58:39 -07:00
Pierre-Yves David
16c46d5926 merge: add an internal:merge3 tool
This variant gives access to a feature already present in ``internal:merge``:
displaying merge base content.

In the basic merge (calling ``hg merge``) case, including more context to the
merge markers is an interesting addition.

But this extra information is the only viable option in case conflict from
grafting (, rebase, etc…).

When grafting ``source`` on ``destination``, the parent of ``source`` is
used as the ``base``. When all three changesets add content in the same
location, the marker for ``source`` will contains both ``base`` and ``source``
content. Without the content of base exposed, there is no way for the user
to discriminate content coming from ``base`` and content commit from ``source``.

Practical example (all addition are in the same place):

* ``destination`` adds ``Dest-Content``
* ``base``        adds ``Base-Content``
* ``source``      adds ``Src-Content``

Grafting ``source`` on ``destination`` will produce the following conflict:

  <<<<<<< destination
  Dest-Content
  =======
  Base-Content
  Src-Content
  >>>>>>> source

This that case there is no way to distinct ``base`` from ``source``. As a result
content from ``base`` are likely to slip in the resolution result.

However, adding the base make the situation very clear:

  <<<<<<< destination
  Dest-Content
  ||||||| base
  Base-Content
  ======= base
  Base-Content
  Src-Content
  >>>>>>> source

Once the base is added, the addition from the grafted changeset is made clear.
User can compare the content from ``base`` and ``source`` to make an enlightened
decision during merge resolution.
2014-08-05 14:58:45 -07:00
Pierre-Yves David
0ddace5f8c internal:merge: update documentation
Highlight the fact there are two regions in the markers and what their contents
are. This prepares for the arrival of merge3.
2014-08-05 15:09:54 -07:00
Pierre-Yves David
6120cff637 filemerge: allow the formatting of three labels instead of two
When a third label is provided (to included the base content) it is properly
processed as the two others. Nothing changes if only two labels are provided.
2014-08-05 15:17:38 -07:00
Pierre-Yves David
2fc8f16378 filemerge: drop extra white space
There should be no white space around the brace.
2014-08-05 15:12:22 -07:00
Pierre-Yves David
2017698ec4 simplemerge: burn "minimal" feature to the ground
Matt Mackall said:

  The goal of simplemerge should have always been to be a drop-in
  replacement for RCS merge. Please nuke this minimization thing entirely.

This whole things is now dead.
2014-08-05 14:56:25 -07:00
Pierre-Yves David
0fe23d7392 merge: use no-minimal for premerge too
fade484cb8f6 disabled minimal for `internal:merge` but forgot to also disabled
it for premerge. This is now done.

This gives me an occasion to shamelessly includes my explanation of why this
minimisation feature must disappear:

[this is why it's pointless to reject patches with misspellings in the
description - mpm]

Detailled explanation
=====================


The ``simplemerge`` code use in ``internal:merge`` has a feature called
"minimization". It reprocess conflicting chunks to find common changes
inside them and excludes such common sections from the marker.

This approach seems a significant win at first glance but produces very
confusing results in some other cases.

Simple example
--------------

A simple example is enough to show the benefit of this feature.  In this merge,
both sides change all numbers from letters to digits, but one side is also
changing some values.

  $ cat << EOF > base
  > Small Mathematical Series.
  > One
  > Two
  > Three
  > Four
  > Five
  > Hop we are done.
  > EOF

  $ cat << EOF > local
  > Small Mathematical Series.
  > 1
  > 2
  > 3
  > 4
  > 5
  > Hop we are done.
  > EOF

  $ cat << EOF > other
  > Small Mathematical Series.
  > 1
  > 2
  > 3
  > 6
  > 8
  > Hop we are done.
  > EOF

In the minimalists case, the markers focus on the disagreement between the two
sides.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  Small Mathematical Series.
  1
  2
  3
  <<<<<<< local
  4
  5
  =======
  6
  8
  >>>>>>> other
  Hop we are done.
  warning: conflicts during merge.
  [1]

In the non minimalist case, the whole chunk is included in the conflict marker.
Making it harder spot actual differences.

  $ $TESTDIR/../contrib/simplemerge --print --no-minimal local base other
  Small Mathematical Series.
  <<<<<<< local
  1
  2
  3
  4
  5
  =======
  1
  2
  3
  6
  8
  >>>>>>> other
  Hop we are done.
  warning: conflicts during merge.
  [1]

Practical Advantages of minimalisation: merge of grafted change
---------------------------------------------------------------

This feature can be very useful when a change have been grafted in another
branch and then some change have been made to the grafted code.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def somefunction(one, two):
  >     some = one
  >     stuff = two
  >     are(happening)
  >     here()
  > EOF

  $ cat << EOF > other
  > def somefunction(one, two):
  >     some = one
  >     change = two
  >     are(happening)
  >     here()
  > EOF

The minimalist case recognises the grafted content as similar and highlight the
actual change.


  $ $TESTDIR/../contrib/simplemerge --print local base other
  def somefunction(one, two):
      some = one
  <<<<<<< local
      stuff = two
  =======
      change = two
  >>>>>>> other
      are(happening)
      here()
  warning: conflicts during merge.
  [1]

Again, the non-minimalist case produces a larger conflict. Making it harder to
spot the actual conflict.

  $ $TESTDIR/../contrib/simplemerge --print --no-minimal local base other
  <<<<<<< local
  def somefunction(one, two):
      some = one
      stuff = two
      are(happening)
      here()
  =======
  def somefunction(one, two):
      some = one
      change = two
      are(happening)
      here()
  >>>>>>> other
  warning: conflicts during merge.
  [1]


Practical disadvantage: multiple functions on each side
---------------------------------------------------------------

So, if this "minimalist" help so much, why introduce a setting to disable it?

The issue is that this minimisation will grab any common lines for breaking
chunks. This may result in partial context when solving a merge. The most
simple example is a merge where both side added some (different) functions
separated by blank lines. The "minimalist" approach will recognise the blank
line as "common" and over slice the chunks, turning a simple conflict case into
multiple pairs of conflicting functions.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def function1():
  >     bla()
  >     bla()
  >     bla()
  >
  > def function2():
  >     ble()
  >     ble()
  >     ble()
  > EOF

  $ cat << EOF > other
  > def function3():
  >     bli()
  >     bli()
  >     bli()
  >
  > def function4():
  >     blo()
  >     blo()
  >     blo()
  > EOF

The minimal case presents each function as a separated context.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  <<<<<<< local
  def function1():
      bla()
      bla()
      bla()
  =======
  def function3():
      bli()
      bli()
      bli()
  >>>>>>> other

  <<<<<<< local
  def function2():
      ble()
      ble()
      ble()
  =======
  def function4():
      blo()
      blo()
      blo()
  >>>>>>> other
  warning: conflicts during merge.
  [1]

The non-minimalist approach produces a simpler version with more context in
each block. Solving such conflicts is usually as simple as dropping the 3 lines
dedicated to markers.

  $ $TESTDIR/../contrib/simplemerge --prin --no-minimal local base other
  <<<<<<< local
  def function1():
      bla()
      bla()
      bla()

  def function2():
      ble()
      ble()
      ble()
  =======
  def function3():
      bli()
      bli()
      bli()

  def function4():
      blo()
      blo()
      blo()
  >>>>>>> other
  warning: conflicts during merge.
  [1]

Practical disaster: programing language have a lot of common line
=================================================================

If only blank lines between function where the only frequent content of a code
file. But programming language tend to repeat them self much more often. In that
case, the minimalist approach turns a simple conflict into a massive mess.

Consider this example where two unrelated functions are added on each side.
Those function shares common programming constructs by chance.

  $ cat << EOF > base
  > # empty file
  > EOF

  $ cat << EOF > local
  > def longfunction():
  >     if bla:
  >        foo
  >     else:
  >        bar
  >     try:
  >        ret = some stuff
  >     except Exception:
  >        ret = None
  >     if ret is not None:
  >         return ret
  >     return 0
  >
  > def shortfunction(foo):
  >     goo()
  >     ret = foo + 5
  >     return ret
  > EOF

  $ cat << EOF > other
  > def otherlongfunction():
  >     for x in xxx:
  >        if coin:
  >            break
  >        tutu
  >     else:
  >        bar()
  >     baz()
  >     ret = week()
  >     try:
  >        groumpf = tutu
  >        fool()
  >     except Exception:
  >        zoo()
  >     pool()
  >     if cond:
  >         return ret
  >
  >     # some big block
  >     ret ** 6
  >     koin()
  >     return ret
  > EOF

The minimalist approach will hash the whole conflict into small chunks that
does not match any meaningful semantic and are impossible to solve.

  $ $TESTDIR/../contrib/simplemerge --print local base other
  <<<<<<< local
  def longfunction():
      if bla:
         foo
  =======
  def otherlongfunction():
      for x in xxx:
         if coin:
             break
         tutu
  >>>>>>> other
      else:
  <<<<<<< local
         bar
  =======
         bar()
      baz()
      ret = week()
  >>>>>>> other
      try:
  <<<<<<< local
         ret = some stuff
  =======
         groumpf = tutu
         fool()
  >>>>>>> other
      except Exception:
  <<<<<<< local
         ret = None
      if ret is not None:
  =======
         zoo()
      pool()
      if cond:
  >>>>>>> other
          return ret
  <<<<<<< local
      return 0
  =======
  >>>>>>> other

  <<<<<<< local
  def shortfunction(foo):
      goo()
      ret = foo + 5
  =======
      # some big block
      ret ** 6
      koin()
  >>>>>>> other
      return ret
  warning: conflicts during merge.
  [1]

The non minimalist approach will properly produce a single set of conflict
markers. Highlighting that the two chunk are unrelated. Such conflict from
unrelated content added at the same place is usually solved by dropping the
marker an keeping both content. Something impossible with minimised markers.


  $ $TESTDIR/../contrib/simplemerge --prin --no-minimal local base other
  <<<<<<< local
  def longfunction():
      if bla:
         foo
      else:
         bar
      try:
         ret = some stuff
      except Exception:
         ret = None
      if ret is not None:
          return ret
      return 0

  def shortfunction(foo):
      goo()
      ret = foo + 5
      return ret
  =======
  def otherlongfunction():
      for x in xxx:
         if coin:
             break
         tutu
      else:
         bar()
      baz()
      ret = week()
      try:
         groumpf = tutu
         fool()
      except Exception:
         zoo()
      pool()
      if cond:
          return ret

      # some big block
      ret ** 6
      koin()
      return ret
  >>>>>>> other
  warning: conflicts during merge.
  [1]
2014-07-29 11:55:01 -07:00
Pierre-Yves David
b9d14448be merge: refactor labels selection code
The code is simplified to prepare the future introduction of a third labels for
the merge base.
2014-06-09 23:37:36 -07:00
Angel Ezquerra
38433239a4 filemerge: add internal:tagmerge merge tool
Add a new internal:tagmerge merge tool which implements an automatic merge
algorithm for mercurial's tag files

The tagmerge algorithm is able to resolve most merge conflicts that
currently would trigger a .hgtags merge conflict. The only case that
it does not (and cannot) handle is that in which two tags point to
different revisions on each merge parent _and_ their corresponding tag
histories have the same rank (i.e. the same length). In all other
cases the merge algorithm will choose the revision belonging to the
parent with the highest ranked tag history. The merged tag history is
the combination of both tag histories (special care is taken to try to
combine common tag histories where possible).

The algorithm also handles cases in which tags have been manually
removed from the .hgtags file and other similar corner cases.

In addition to actually merging the tags from two parents, taking into
account the base, the algorithm also tries to minimize the difference
between the merged tag file and the first parent's tag file (i.e. it
tries to make the merged tag order as as similar as possible to the
first parent's tag file order).

The algorithm works as follows:
1. read the tags from p1, p2 and the base
    - when reading the p1 tags, also get the line numbers associated to each
      tag node (these will be used to sort the merged tags in a way that
      minimizes the diff to p1). Ignore the file numbers when reading p2 and
      the base
2. recover the "lost tags" (i.e. those that are found in the base but not on p1
   or p2) and add them back to p1 and/or p2
    - at this point the only tags that are on p1 but not on p2 are those new
      tags that were introduced in p1. Same thing for the tags that are on p2
      but not on p2
3. take all tags that are only on p1 or only on p2 (but not on the base)
    - Note that these are the tags that were introduced between base and p1 and
      between base and p2, possibly on separate clones
4. for each tag found both on p1 and p2 perform the following merge algorithm:
    - the tags conflict if their tag "histories" have the same "rank" (i.e.
      length) _AND_ the last (current) tag is _NOT_ the same
    - for non conflicting tags:
        - choose which are the high and the low ranking nodes
            - the high ranking list of nodes is the one that is longer.
              In case of draw favor p1
            - the merged node list is made of 3 parts:
                - first the nodes that are common to the beginning of both the
                  low and the high ranking nodes
                - second the non common low ranking nodes
                - finally the non common high ranking nodes (with the last one
                  being the merged tag node)
            - note that this is equivalent to putting the whole low ranking node
              list first, followed by the non common high ranking nodes
    - note that during the merge we keep the "node line numbers", which will
      be used when writing the merged tags to the tag file
5. write the merged tags taking into account to their positions in the first
   parent (i.e. try to keep the relative ordering of the nodes that come
   from p1). This minimizes the diff between the merged and the p1 tag files
   This is done by using the following algorithm
    - group the nodes for a given tag that must be written next to each other
        - A: nodes that come from consecutive lines on p1
        - B: nodes that come from p2 (i.e. whose associated line number is None)
             and are next to one of the a nodes in A
        - each group is associated with a line number coming from p1
    - generate a "tag block" for each of the groups
        - a tag block is a set of consecutive "node tag" lines belonging to the
          same tag and which will be written next to each other on the merged
          tags file
    - sort the "tag blocks" according to their associated number line
        - put blocks whose nodes come all from p2 first
    - write the tag blocks in the sorted order

Notes:
- A few tests have been added to test-tag.t. These tests are very specific to
the new internal:tagmerge tool, so perhaps they should be moved to their own
test file.
- The merge algorithm was discussed in a thread on the mercurial mailing list.
In http://markmail.org/message/anqaxldup4tmgyrx a slightly different algorithm
was suggested. In it the p1 and p2 tags would have been interleaved instead of
put one before the other. It would be possible to implement that but my tests
suggest that the merge result would be more confusing and harder to understand.
2014-06-26 01:20:25 +02:00
Matt Mackall
dcb326f0e5 filemerge: use non-minimal conflict marker regions (BC)
As extensively detailed by Pierre-Yves[1], simplemerge's minimal
markers can result in hopeless confusion for many common merges. As it
happens, we accidentally inherited this behavior when we borrowed
simplemerge from bzr; it is not the behavior used by RCS's merge(1),

Since merge(1) (and not bzr) is what we aim to emulate when emulating
RCS's merge markers, we simply turn this feature off. This brings us
in line with the behavior of CVS, SVN, and Git as a bonus.

(NB: using conflict markers with Mercurial is discouraged.)

[1] http://markmail.org/message/wj5mh3lc46czlvld

convert glob tessa
2014-07-18 21:49:52 -05:00
FUJIWARA Katsunori
ba5b3b9f46 filemerge: use 'basic' as the default of '[ui] mergemarkers' for safety
Before this patch, 'detailed' is used as the default of '[ui]
mergemarkers'. This embeds non-ASCII characters in tags, branches,
bookmarks, author and/or commit descriptions into merged files in the
encoding specified by '--encoding' global option, 'HGENCODING' or
other locale setting environment variables.

But, if files to be merged use another encoding, this behavior breaks
consistency of encoding in merged files.

For example, ISO-2022-JP or EUC-JP are sometimes used as the file
encoding for Japanese characters, because of historical and/or
environmental reasons, even though UTF-8 or Shift-JIS are ordinarily
used as the terminal encoding.

This can't be resolved automatically, because Mercurial doesn't aware
encoding of managed files.

This patch uses 'basic' as the default of '[ui] mergemarkers' to avoid
embedding encoding sensitive characters for safety.

This patch puts '[ui] mergemarkers = detailed' into default hgrc file
for tests, to reduce changes for tests in this patch.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
872be90f3b filemerge: use 'util.ellipsis' to trim custom conflict markers correctly
Before this patch, filemerge slices byte sequence directly to trim
conflict markers, but this may cause:

  - splitting at intermediate multi-byte sequence

  - incorrect calculation of column width (length of byte sequence is
    different from columns in display in many cases)

This patch uses 'util.ellipsis' to trim custom conflict markers
correctly, even if multi-byte characters are used in them.
2014-07-06 02:56:41 +09:00
FUJIWARA Katsunori
31bba09810 filemerge: use only the first line of the generated conflict marker for safety
Before this patch, with careless configuration (missing '|firstline'
filtering for '{desc}' keyword, for example), '[ui]
mergemarkertemplate' can make conflict markers multiple lines.

For ordinary users, advantage of allowing '[ui] mergemarkertemplate'
to generate multiple lines for customizing seems to be less than
advantage of disallowing it for safety.

This patch uses only the first line of the conflict marker generated
from '[ui] mergemarkertemplate' configuration for safety.
2014-07-06 02:56:41 +09:00
Pierre-Yves David
21bb02d08f merge: drop the quotes around commit description
We already have a ":" after the user name to denote the start of the
description. The current usage of quotes around the description is
problematic as the truncation to 80 chars is likely to drop the
closing quote. This may confuse syntax coloration in some editors.
2014-05-26 11:44:58 -07:00
Durham Goode
0ac70cfdb2 merge: add labels parameter from merge.update to filemerge
Adds a labels function parameter to all the functions between merge.update and
filemerge.filemerge. This will allow commands like rebase to specify custom
marker labels.
2014-05-08 16:54:23 -07:00
Durham Goode
bcc0ea1fe2 merge: add conflict marker formatter (BC)
Adds a conflict marker formatter that can produce custom conflict marker
descriptions. It can be set via ui.mergemarkertemplate. The old behavior
can be used still by setting ui.mergemarkers=basic.

The default format is similar to:

  {node|short} {tag} {branch} {bookmarks} - {author}: "{desc|firstline}"

And renders as:

  contextblahblah
  <<<<<<< local: c7fdd7ce4652 - durham: "Fix broken stuff in my feature branch"
  line from my changes
  =======
  line from the other changes
  >>>>>>> other: a3e55d7f4d38  master - sid0: "This is a commit to master th...
  morecontextblahblah
2014-05-08 16:50:22 -07:00