Commit Graph

89 Commits

Author SHA1 Message Date
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
Durham Goode
c8985b17b0 merge: define conflict marker labels in filemerge()
Moves the conflict marker definition up to filemerge, so it gets applied to all
merge strategies, and so in a future patch we can manipulate the markers.
2014-05-08 16:37:33 -07:00
Mads Kiilerich
638e3b7e24 filemerge: better handling of failing remove of temporary files
We have seen some failures on Windows that could seem like the unlinks of
temporary files were failing. That could perhaps be because the merge tool
somehow still held the files open.

Instead of the bare bone os.unlink, use our util.unlink with special
rename/retry handling on Windows.
2014-04-17 14:54:46 +02:00
Augie Fackler
b6015ab3da filemerge: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:15:09 -04:00
Matt Mackall
13d2a13ea6 ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
2013-05-22 17:31:43 -05:00
Mads Kiilerich
4d69012587 merge: warn when internal:merge cannot merge symlinks
A follow-up to 6847621b4da6.

internal:merge should never be picked for merging symlinks ... but in the test
suite we have HGMERGE="internal:merge" which bypasses all the usual merge-tool
cleverness. Without any output it can be hard to figure out what happened and
where the problem is.
2013-01-15 01:05:11 +01:00
Mads Kiilerich
e379b091a9 merge: never do premerge on symlinks
Simplemerge is not symlink aware and will never do the right thing on symlinks.
2013-01-08 04:15:46 +01:00
Mads Kiilerich
b67259b61a merge: make internal merge fail cleanly on symlinks
Simplemerge is not symlink aware and will never do the the right thing on
symlinks. It would read the symlink as a file and abort with 'No such file or
directory' on dangling symlinks.

Instead, internal:merge now simply fails to merge symlinks.
2013-01-08 04:15:41 +01:00
Keegan Carruthers-Smith
556604a6f0 filemerge: use util.shellquote when calling merge (issue3581) 2012-10-26 12:02:58 -07:00
Matt Mackall
2a84e7e364 merge with stable 2012-03-13 16:29:13 -05:00
Matt Mackall
2fd77dbcdb filemerge: restore default prompt for binary/symlink lost in c5dd8ad52586
This could result in a traceback.
2012-03-13 15:12:26 -05:00
Thomas Arendsen Hein
d564ac8a84 filemerge: remove temporary files when using internal:dump as merge-tool 2012-03-01 17:35:12 +01:00
Matt Mackall
6287da213f filemerge: remove some redundancy in decorators/docstrings 2012-02-16 15:58:51 -06:00
FUJIWARA Katsunori
4629df01c9 filemerge: create detail of internal merge tools from documentation string
this patch introduces 'internaltoolsmarker' which creates detail of
each internal merge tools from documentation string for 'hg help merge-tools'.
2012-02-12 21:38:12 +09:00
FUJIWARA Katsunori
030b0e3bf3 filemerge: refactoring of 'filemerge()'
current 'filemerge.filemerge()' implementation is verfy complicated.

    - it is not easy to add new internal merge tools
      (only by patching on 'filemerge()', or replacing it completely)

    - cleanup of temporary files is unsatisfactory
      ('internal:dump' does not, in fact)

this is patch for refactoring of 'filemerge()' to isolate each
internal merge tool implementations from 'filemerge()', and clean up
common part in it.
2012-02-12 21:38:12 +09:00
Laurens Holst
8daae4999d context: add isbinary function 2011-12-21 18:20:15 +01:00
Matt Mackall
66de5cde16 merge: give a special message for internal:merge failure (issue3105) 2011-11-16 18:04:19 -06:00
Greg Ward
aeec456986 merge: expand environment variables and ~/ in tool.executable
hgrc(5) already implies that this works, so we might as well support it.

Another approach would be to implement this in util.findexe(): that
would benefit other callers of findexe(), e.g. convert and anyone
calling the user's editor. But findexe() is really implemented in
both posix.py and windows.py, so this would make both of those modules
depend on util.py: not good. So keep it narrow and only for merge
tools.
2011-10-12 21:45:58 -04:00
Idan Kamara
446fde5f1b filemerge: use ui out descriptor when calling util.system 2011-06-24 17:04:37 +03:00
Adrian Buehlmann
4163cf2e6f rename util.find_exe to findexe 2011-05-08 20:35:46 +02:00
Adrian Buehlmann
554b565228 rename util.lookup_reg to lookupreg 2011-05-06 15:16:22 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Steve Borho
fe1b6543d5 filemerge: introduce a 'regkeyalt' merge tool variable
This allows us to provide alternate search keys for 64bit operating systems that
may have 32bit merge tools installed.  Presumably it may find other uses.
2011-03-08 13:05:18 -06:00
Steve Borho
a3baf6a2e7 merge: implement --tool arguments using new ui.forcemerge configurable
ui.forcemerge is set before calling into merge or resolve commands, then unset
to prevent ui pollution for further operations.

ui.forcemerge takes precedence over HGMERGE, but mimics HGMERGE behavior if the
given --tool is not found by the merge-tools machinery.  This makes it possible
to do:  hg resolve --tool="python mymerge.py" FILE

With this approach, HGMERGE and ui.merge are not harmed by --tool
2010-10-19 22:33:52 -05:00
Thomas Arendsen Hein
d83b895da6 Fix merge-tools.checkconflicts
re.match only looks at the beginning of the merged file, and without
re.MULTILINE the file had to end with ">>>>>>> something".

Now conflict markers inside the file are found, too.
2010-08-26 17:38:43 +02:00
Matt Mackall
5fd0f613e6 merge with stable 2010-08-21 10:48:49 -05:00
Matt Mackall
395274c87f merge: move reverse-merge logic out of filemerge (issue2342) 2010-08-21 10:41:29 -05:00
Steve Losh
b2ecd09159 util: add an interpolate() function to for replacing multiple values
util.interpolate can be used to replace multiple items in a string all at once
(and optionally apply a function to the replacement), without worrying about
recursing:

    >>> import util
    >>> s = '$foo, $spam'
    >>> util.interpolate(r'\$', { 'foo': 'bar', 'spam': 'eggs' }, s)
    'bar, eggs'
    >>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s)
    'spam, foo'
    >>> util.interpolate(r'\$', { 'foo': 'spam', 'spam': 'foo' }, s, lambda s: s.upper())
    'SPAM, FOO'

The patch also changes filemerge.py to use this new function.
2010-08-18 18:18:26 -04:00
Nicolas Dumazet
064d677bd7 filectx: use cmp(self, fctx) instead of cmp(self, text)
This allows more flexibility in implementation, and in particular,
lets the context decide if revision text has to be loaded or not.
2010-07-27 23:40:46 +09:00
David Champion
b8cccccefd merge: tool.check = prompt will force an interactive merge check
tool.check = prompt can be used when the exit status of a merge
tool is unreliable but an explicit user signoff on the merge result is
acceptable.
2010-05-10 11:04:56 -05:00
David Champion
884303ae82 merge: introduce tool.check parameter
tool.check is a list of check options, and can be used in place of
tool.checkchanged and tool.checkconflicts:

Equivalences:
tool.checkchanged = yes
tool.checkconflicts = no
tool.check = changed

tool.checkchanged = no
tool.checkconflicts = yes
tool.check = conflicts

tool.checkchanged = yes
tool.checkconflicts = yes
tool.check = changed, conflicts

Add _toollist() wrapper for ui.configlist() to implement this consistently.

checkchanged and checkconflicts are still supported, but check is
preferred for implementing new check options.
2010-05-10 11:04:56 -05:00
David Champion
14b32f640c merge: tool.premerge=keep will leave premerge markers in $local 2010-04-21 11:57:45 -05:00
Benoit Boissinot
7137f04bb0 filemerge: use working dir parent as ancestor for backward wdir merge
I checked the tests, they were bogus in the first place
2010-04-19 20:41:53 +02:00
Patrick Mezard
c5a46629ec filemerge: use native path separators when merging (issue1399) 2010-02-23 23:19:09 +01:00