Commit Graph

41 Commits

Author SHA1 Message Date
Siddharth Agarwal
1c3dcd1546 filemerge: default change/delete conflicts to 'leave unresolved' (BC)
It makes far more sense to leave these conflicts unresolved and kick back to
the user than to just assume that the local version be chosen. There are almost
certainly buggy scripts and applications using Mercurial in the wild that do
merges or rebases non-interactively, and then assume that if the operation
succeeded there's nothing the user needs to pay attention to.

(This wasn't possible earlier because there was no way to re-resolve
change/delete conflicts -- but now it is.)
2015-12-23 12:51:45 -08:00
Siddharth Agarwal
7382fa0a4e filemerge: add a 'leave unresolved' option to change/delete prompts
We're going to make this option the default in an upcoming patch.
2015-11-30 13:43:55 -08:00
Siddharth Agarwal
807dab9ed1 filemerge: add debug output for whether this is a change/delete conflict
Just like binary and symlink conflicts, change/delete conflicts influence the
tool picked.
2015-11-25 14:25:26 -08:00
Siddharth Agarwal
106338a190 merge: move almost all change/delete conflicts to resolve phase (BC) (API)
We have finally laid all the groundwork to make this happen.

The only change/delete conflicts that haven't been moved are .hgsubstate
conflicts. Those are trickier to deal with and well outside the scope of this
series.

We add comprehensive testing not just for the initial selections but also for
re-resolves and all possible dirstate transitions caused by merge tools. That
testing managed to shake out several bugs in the way we were handling dirstate
transitions.

The other test changes are because we now treat change/delete conflicts as
proper merges, and increment the 'merged' counter rather than the 'updated'
counter. I believe this is the right approach here.

For third-party extensions, if they're interacting with filemerge code they
might have to deal with an absentfilectx rather than a regular filectx.

Still to come:
- add a 'leave unresolved' option to merges
- change the default for non-interactive change/delete conflicts to be 'leave
  unresolved'
- add debug output to go alongside debug outputs for binary and symlink file
  merges
2015-11-25 14:25:33 -08:00
Siddharth Agarwal
3a27c524dc merge: add a new action type representing files to add/mark as modified
This is somewhat different from the currently existing 'a' action, for the
following case:

- dirty working copy, with file 'fa' added and 'fm' modified
- hg merge --force with a rev that neither has 'fa' nor 'fm'
- for the change/delete conflicts we pick 'changed' for both 'fa' and 'fm'.

In this case 'branchmerge' is true, but we need to distinguish between 'fa',
which should ultimately be marked added, and 'fm', which should be marked
modified.

Our current strategy is to just not touch the dirstate at all. That works for
now, but won't work once we move change/delete conflicts to the resolve phase.
In that case we may perform repeated re-resolves, some of which might mark the
file removed or remove the file from the dirstate. We'll need to re-add the
file to the dirstate, and we need to be able to figure out whether we mark the
file added or modified. That is what the new 'am' action lets us do.
2015-11-30 10:19:39 -08:00
Martin von Zweigbergk
b3bed98791 test-rename-merge2: make selected output less arbitrary
It's unclear why everything from the first 'updating:' line should be
ignored. The arbitrariness makes it confusing that changing the code
so e.g. the 'getting 8/f' line is printed later makes it disappear
completely from the ouput. The list of 'preserving x for resolve of y'
seems convered by the subsequent for loop in the test case. Perhaps
it's only copies that are of interests, so let's keep only that part.
2015-02-11 22:22:29 -08:00
Martin von Zweigbergk
3d33120c8b merge: move messages about possible conflicts a litte earlier
I actually wanted to reduce the amount of code around the call to
applyupdates(), so I tried moving these warnings a little earlier, and
I think it makes the output make a little more sense (see changes to
test cases).
2015-11-12 13:14:03 -08:00
Siddharth Agarwal
c97c4cf7f6 merge.mergestate: perform all premerges before any merges (BC)
We perform all that we can non-interactively before prompting the user for input
via their merge tool. This allows for a maximally consistent state when the user
is first prompted.

The test output changes indicate the actual behavior change happening.
2015-10-11 21:56:39 -07:00
Siddharth Agarwal
88da24240c filemerge: break overall filemerge into separate premerge and merge steps
This means that in ms.resolve we must call merge after calling premerge. This
doesn't yet mean that all premerges happen before any merges -- however, this
does get us closer to our goal.

The output differences are because we recompute the merge tool. The only
user-visible difference caused by this patch is that if the tool is missing
we'll print the warning twice. Not a huge deal, though.
2015-10-11 20:47:14 -07:00
Pierre-Yves David
281365197e progress: get the extremely verbose output out of default debug
When the progress extension is not enabled, each call to 'ui.progress' used to
issue a debug message. This results is a very verbose output and often redundant
in tests. Dropping it makes tests less volatile to factor they do not meant to
test.

We had to alter the sed trick in 'test-rename-merge2.t'. Sed is used to drop all
output from a certain point and hidding the progress output remove its anchor.
So we anchor on something else.
2015-05-09 23:40:40 -07:00
Matt Harbison
9d40fb3218 windows: make shellquote() quote any path containing '\' (issue4629)
The '~' in the bug report is being expanded to a path with Windows style slashes
before being passed to shellquote() via util.shellquote().  But shlex.split()
strips '\' out of the string, leaving an invalid path in dispatch.aliasargs().

This regressed in 72640182118e.

For now, the tests need to be conditionalized for Windows (because those paths
are quoted).  In the future, a more complex regex could probably skip the quotes
if all component separators are double '\'.  I opted to glob away the quotes in
test-rename-merge2.t and test-up-local-change.t (which only exist on Windows),
because they are in very large blocks of output and there are way too many diffs
to conditionalize with #if directives.  Maybe the entire path should be globbed
away like the following paths in each changed line.  Or, letting #if directives
sit in the middle of the output as was mentioned a few months back would work
too.

Unfortunately, I couldn't figure out how to test the specific bug.  All of the
'hg serve' tests have a #require serve declaration, causing them to be skipped
on Windows.  Adding an alias for 'expandtest = outgoing ~/bogusrepo' prints the
repo as '$TESTTMP/bogusrepo', so the test runner must be changing the
environment somehow.
2015-04-29 21:14:59 -04:00
Matt Harbison
d731476e46 test-rename-merge2: fix test failure on Windows
Windows and OpenVMS use double quote for shell quoting, posix uses
single quote. Since the other test lines added in 3ba9d147e92e don't
include the quotes, this was presumably an oversight.
2015-04-17 12:39:55 -04:00
Mads Kiilerich
17c4f7c523 merge: better debug messages before/after invoking external merge tool 2015-03-19 22:22:50 +01:00
Martin von Zweigbergk
6ddc19cb79 merge: don't report progress for dr/rd actions
It is easier to reason about certain algorithms in terms of a
file->action mapping than the current action->list-of-files. Bid merge
is already written this way (but with a list of actions per file), and
largefiles' overridecalculateupdates() will also benefit. However,
that requires us to have at most one action per file. That requirement
is currently violated by 'dr' (divergent rename) and 'rd' (rename and
delete) actions, which can exist for the same file as some other
action.

These actions are only used for displaying warnings to the user; they
don't change anything in the working copy or the dirstate. In this
way, they are similar to the 'k' (keep) action. However, they are even
less action-like than 'k' is: 'k' at least describes what to do with
the file ("do nothing"), while 'dr' and 'rd' or only annotations for
files for which there may exist other, "real" actions.

As a first step towards separating these acitons out, stop including
them in the progress output, just like we already exclude the 'k'
action.
2014-12-05 16:13:26 -08:00
Martin von Zweigbergk
72e9071545 merge: make 'keep' message more descriptive
Most merge action messages don't describe the action itself, they
describe the reason the action was taken. The only exeption is the 'k'
action, for which the message is just "keep" and instead there is a
code comment folling it that says "remote unchanged". Let's move that
comment into the merge action message.
2014-12-03 14:03:20 -08:00
Martin von Zweigbergk
96d97f796c merge: break out "both renamed a -> b" case
We can further limit the scope of the 2-way merge case by breaking out
the case where the file was not created from scratch on both sides but
rather renamed in the same way (and is therefore a 3-way merge). This
involves copying some code, but it makes it clearer which case the
"Note:" in the code refers to.
2014-11-24 16:42:36 -08:00
Martin von Zweigbergk
dd435d36bb merge: separate out "both created" cases
When 'f' is not in 'ma', 'a' will be 'nullid' and all the if/elif
conditions that check whether some one nodeid is equal to 'a' will
fail, and the else-clause will instead apply. We can make that more
explicit by creating a separate 'm' action for the case where 'a' is
'nullid'. While it does mean copying some code, perhaps it makes it a
little clearer which codepaths are possible, and which cases the
"Note:" in the code refers to. It also lets us make the debug action
messages a little more specific.
2014-11-24 16:16:34 -08:00
Mads Kiilerich
473137c772 merge: change debug logging - test output changes but no real changes
Preparing for action list split-up, making sure the final change don't have any
test changes.

The patch moves debug statements around without really changing anything.
Arguably, it temporarily makes the code worse. The only justification is that
it makes it easier to review the test changes ... and in the end the big change
will not change test output at all.

The changes to test output are due to changes in the ordering of debug output.
That is mainly because we now do the debug logging for files when we actually
process them. Files are also processed in a slightly different but still
correct order. It is now primarily ordered by action type, secondarily by
filename.

The patch introduces some redundancy. Some of it will be removed again, some of
it will in the end help code readability and efficiency. It is possible that we
later on could introduce a "process this action list and do some logging and
progress reporting and apply this function".

The "preserving X for resolve" debug statements will only have single space
indentation. It will no longer have a leading single space indented "f: msg ->
m" message. Having this message double indented would thus no longer make
sense.

The bid actions will temporarily be sorted using a custom sort key that happens
to match the sort order the simplified code will have in the end.
2014-04-22 02:10:25 +02:00
Mads Kiilerich
43db2a4aa5 merge: change priority / ordering of merge actions
The ordering of actions matters. Normal file system semantics is that files
have to be removed before a directory with the same name can be created.

Before the first ordering key was to have 'r' and 'f' actions come first,
secondary key was the filename.

Because of future refactorings we want to consistently have all action types
(with a sensible priority) as separate first keys. Grouped by action type, we
sort by filename.

Not processing in strict filename order could give worse performance,
especially on spinning disks. That is however primarily an issue in the cases
where "all" actions are of the same kind and will be grouped together anyway.
2014-05-02 01:09:14 +02:00
Mads Kiilerich
276e18adae merge: let manifestmerge emit 'keep' actions when keeping wd version
Such a 'keep' action will later be the preferred (non)action when there
is multiple ancestors. It is thus very convenient to have it explicitly.

The extra actions will only be emitted in the case where the local file has
changed since the ancestor but the other hasn't. That is the symmetrical
operation to a 'get' action.

This will create more action tuples that not really serve a purpose. The number
of actions will however have the number of changed files as upper bound and it
should thus not increase the memory/cpu use significantly.
2014-04-07 02:12:28 +02:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Mads Kiilerich
a0f70f6a56 merge: keep destination filename as key in filemerge actions
Gives more readable debug output and makes it possible to compare/merge actions
later.
2014-03-02 18:52:16 +01:00
Mads Kiilerich
43ddf0086b copies: when both sides made the same copy, report it as a copy
Not used yet ... but shows up in debug output.
2014-02-25 20:29:14 +01:00
Mads Kiilerich
b991c5191a tests: add systematic test of merge ancestor calculation
There is probably some overlap with the existing tests - it is hard to figure
out what these tests are doing.
2014-02-25 20:28:40 +01:00
FUJIWARA Katsunori
37ccfcc8ea merge: increase safety of parallel updating/removing on icasefs
"merge.applyupdates()" sorts "actions" in removal first order, and
"workeractions" derived from it should be also sorted.

If each actions in "workeractions" are executed in serial, this
sorting ensures that merging/updating process is collision free,
because updating the file in target context is always executed after
removing the existing file which causes case-folding collision against
the former.

In the other hand, if each actions are executed in parallel, updating
on a worker process may be executed before removing on another worker
process, because "worker.partition()" partitions list of actions
regardless of type of each actions.

This patch divides "workeractions" into removing and updating, and
executes the former first.

This patch still scans "actions"/"workeractions" some times for ease
of patch review, even though large list may cost much in this way.
(total cost should be as same as before)

This also changes some tests, because dividing "workeractions" affects
progress indication.
2013-04-29 15:58:15 +09:00
Bryan O'Sullivan
2429ebf0ed tests: getremove test output changes (fold into previous patch) 2013-02-09 15:22:10 -08:00
Bryan O'Sullivan
948134e159 tests: update test output (will be folded into parent) 2013-02-09 15:22:04 -08:00
Siddharth Agarwal
ace5cac25b manifestmerge: pass in branchmerge and force separately
This will be used in an upcoming patch.
2013-02-08 15:23:23 +00:00
Mads Kiilerich
2ec21b22f5 merge: don't indent "local changed %s which remote deleted" prompt
It was usually not shown in a context where indentation helped readability and
it was inconsistent with other prompts.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
ee476759ff merge: delay debug messages for merge actions
Show messages at a point where the actions have been sorted, thus preparing for
backout of 14f4258e3526.

This makes manifestmerge more of a silent operation, just like 'copies' is.

Indent 'preserving' messages to make them subordinate to the action logging so
they fit in the new context. (The 'preserving' messages are quite redundant and
could also be removed completely.)
2013-01-24 23:57:44 +01:00
Mads Kiilerich
e4cb2af2e8 merge: delay prompts a bit and show them in (extra) sorted order
Preparing for backout of 14f4258e3526.

The number of prompts will for all relevant cases be significantly smaller than
the total number of files in the manifests. We can thus afford to sort the
prompts more than we can afford to sort the manifests.
2013-01-24 23:57:44 +01:00
Mads Kiilerich
2e43383c70 copies: report found copies sorted 2012-12-12 02:38:14 +01:00
Siddharth Agarwal
76d4a91eed copies: make debug messages more sensible
The -> in debug messages is currently overloaded to mean both source to dest
and dest to source. To fix this, we add explicit labels and make the arrow
direction consistent.
2012-12-26 15:03:58 -08:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Thomas Arendsen Hein
6c60809dcc merge: show renamed on one and deleted on the other side in debug output 2012-05-23 21:34:29 +02:00
Martin Geisler
ae8ca6aff5 merge: make debug output easier to read
I always found it hard to figure out what the debug code meant without
the separators.
2011-12-09 17:34:53 +01:00
Martin Geisler
5a0135a6ca tests: remove redundant mkdir
There are still many tests that check that a bare 'hg init'
initializes the current directory.
2011-04-19 12:04:44 +02: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
Dan Villiom Podlaski Christiansen
17cfc8fdc9 merge: make 'diverging renames' diagnostic a more helpful note.
See the Hg Book on why we actually want to detect this case:
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html#id364290

Before:

$ hg up deadbeef
warning: detected divergent renames of X to:
...

After:

$ hg up deadbeef
note: possible conflict - X was renamed multiple times to:
...

No functionality change.
2010-10-10 09:50:25 -05:00
Adrian Buehlmann
758fc721d8 check-code: add 'no tab indent' check for unified tests
and fix the offending tests accordingly
2010-10-16 18:09:01 +02:00
Matt Mackall
c4877b48a6 tests: unify test-rename-merge2 2010-09-26 13:44:49 -05:00