Commit Graph

37 Commits

Author SHA1 Message Date
Pulkit Goyal
3e9e1184d1 py3: convert kwargs' keys' to str using pycompat.strkwargs()
On Python 3, we must have keys of keyword arguments as str.
2017-06-22 03:16:16 +05:30
Pierre-Yves David
ab789fa439 vfs: use 'vfs' module directly in 'mercurial.simplemerge'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:30:58 +01:00
Pierre-Yves David
e5cb48ac36 vfs: replace 'scmutil.opener' usage with 'scmutil.vfs'
The 'vfs' class is the first class citizen for years. We remove all usages of
the older API. This will let us remove the old API eventually.
2017-03-02 03:52:36 +01:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
Yuya Nishihara
1a2cfb06b7 simplemerge: obtain stdout from ui
This will help Python 3 porting.
2016-10-20 22:09:50 +09:00
Ryan McElroy
7172b75ac8 merge: minimize conflicts when common base is not shown (issue4447)
Previously, two changes that were nearly, but not quite, identical would result
in large merge conflict regions that looked very similar, and were thus very
confusing to users, and lead people used to other source control systems to
claim that "mercurial's merge algorithms suck". In the relatively common case
of a new file being introduced in two branches with very slight modifications,
the old behavior would show the entire file as a conflict, and it would be very
difficult for a user to determine what was going on.

In the past, mercurial attempted to solve this with a "very smart" algorithm
that would find all common lines, but this has significant problems as
described in 3d22d20aa950.

Instead, we use a "very dumb" algorithm introduced in the previous patch that
simply matches lines at the periphery of conflict regions. This minimizes most
conflict regions well, though there may still be some degenerate edge cases,
like small modification to the beginning and end of a large file.
2016-02-10 09:06:08 -08:00
Ryan McElroy
a017f9a43a merge: introduce method to minimize merge regions
In the next diff, we will use this to trim down the start and end of conflict
regions where the A and B sides both made the same changes.
2016-02-10 08:25:03 -08:00
Ryan McElroy
f1d55f43db merge: add some useful documentation 2016-02-09 15:25:09 -08:00
Siddharth Agarwal
a6dc53e738 simplemerge: move conflict warning message to filemerge
The current output for a failed merge with conflict markers looks something like:

  merging foo
  warning: conflicts during merge.
  merging foo incomplete! (edit conflicts, then use 'hg resolve --mark')
  merging bar
  warning: conflicts during merge.
  merging bar incomplete! (edit conflicts, then use 'hg resolve --mark')

We're going to change the way merges are done to perform all premerges before
all merges, so that the output above would look like:

  merging foo
  merging bar
  warning: conflicts during merge.
  merging foo incomplete! (edit conflicts, then use 'hg resolve --mark')
  warning: conflicts during merge.
  merging bar incomplete! (edit conflicts, then use 'hg resolve --mark')

The 'warning: conflicts during merge' line has no context, so is pretty
confusing.

This patch will change the future output to:

  merging foo
  merging bar
  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
  warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')

The hint on how to resolve the conflicts makes this a bit unwieldy, but solving
that is tricky because we already hint that people run 'hg resolve' to retry
unresolved merges. The 'hg resolve --mark' mostly applies to conflict marker
based resolution.
2015-10-09 13:54:52 -07:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Jordi Gutiérrez Hermoso
d752ffbdc0 simplemerge: enable option to resolve conflicts one way
With this change, the simplemerge algorithm grows an option to only
return the local or the other hunk in a conflicting region.
2015-08-12 08:53:01 -04:00
Erik Huelsmann
743457bb04 simplemerge: add 'mode' kwarg which - when 'union' - suppresses markers
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.

Note: the identifiers with underscores in this commit are all using existing
   variable names and/or keyword arguments.
2015-08-16 00:00:34 +02:00
Gregory Szorc
0748b3281a simplemerge: use absolute_import 2015-08-08 19:54:11 -07:00
Jordi Gutiérrez Hermoso
0ee68cc094 simplemerge: remove dead code
The following functions in simplemerge are dead code. I reran "make
test-merge*" after this change, and it passed. Looks like cruft that
we've been carrying since we nabbed this code from bzr.
2014-08-07 12:51:45 -04:00
Pierre-Yves David
72d8ebecb8 simplemerge: support three labels when merging
If a third label is provided it will be used for the "base" content:

  <<<<<<< local
  content
  from
  local
  ||||||| base
  former
  common
  =======
  other
  conflicting
  >>>>>>> other
2014-08-05 15:10:50 -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
Durham Goode
18d054f5ce merge: prevent simplemerge from mutating label list
simplemerge was using list.pop() to remove items from the labels list. This
mutated the list and made it unusable by other calls (for instance, it might be
used in both the premerge and actual merge stages).
2014-05-08 16:33:06 -07:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Martin Geisler
d8334151e6 Remove FSF mailing address from GPL headers
The GPLv3 FAQ suggests to upgrade by

  [...] replace all your existing v2 license notices (usually at the
  top of each file) with the new recommended text available on the GNU
  licenses howto. It's more future-proof because it no longer includes
  the FSF's postal mailing address.

This removes the postal address, but leaves the version number at 2+.
2012-01-06 16:27:13 +01:00
Matt Mackall
b066b57e3c backout 17bc9a6bb165 (issue3077) (issue3071)
Using util.realpath turns out to create complex issues on both Mac and
Windows. Back this change out for the release.
2011-10-29 11:02:23 -05:00
Thomas Arendsen Hein
51c498ead0 consistency: use util.realpath instead of os.path.realpath where useful
exceptions:
  hg: os.path.realpath used before util can be imported
  tests/run-tests.py: may not import mercurial modules
2011-10-24 13:51:24 +02:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Matt Mackall
1b52b02896 check-code: catch misspellings of descendant
This word is fairly common in Mercurial, and easy to misspell.
2011-06-07 17:02:54 -05:00
Matt Mackall
3afbc844f5 merge with stable 2011-05-15 13:15:41 -05:00
Steve Borho
48f0028601 simplemerge: do not allow binary files to abort an entire merge
When used as the default merge tool, or used as a --tool override,
the simplemerge script should not be allowed to raise a util.Abort
just because one of the files being merged is binary.  Instead, return
1 and mark the file unresolved.
2011-05-13 19:46:36 -05:00
Matt Mackall
51b3b09c8f backout most of 26e0b9a8ce0d 2010-09-24 12:46:54 -05:00
Brodie Rao
7362459729 cleanup: use x in (a, b) instead of x == a or x == b 2010-09-23 00:02:31 -05:00
Mads Kiilerich
9876c3e7ec simplemerge: remove hash-bang from non-executable script 2010-08-26 22:51:48 +02:00
Adrian Buehlmann
cf126bb7dd move opener from util to scmutil 2011-04-20 19:54:57 +02:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Steve Borho
83629eeaea simplemerge: use ui.warn() for warnings 2009-04-30 23:57:36 -05:00
Benoit Boissinot
ea7fe6dacc remove unused variables 2008-10-28 19:25:26 +01:00
Matt Mackall
6c908ebf9b chmod -x simplemerge.py 2008-10-22 13:05:40 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Matt Mackall
346758f77c merge: move the bulk of simplemerge into core
- keep existing simplemerge command in contrib
- clean up test interface
2008-02-03 19:29:05 -06:00