Commit Graph

40 Commits

Author SHA1 Message Date
Simon Farnsworth
3622717b76 merge: add conflict labels to merge command
Now that we present the conflict labels in prompts, it's useful to have
better names than "local" and "other" for every command.
2016-10-07 08:51:50 -07:00
timeless
9b55d3b408 summary: move mergemod before parents to give access to ms 2016-03-17 14:50:29 +00:00
timeless
1fcd9b7563 resolve: when pats do not match, hint about path:
Suggest a command that would probably work.
2015-12-24 04:31:34 +00:00
Durham Goode
4834302703 merge: add file ancestor linknode to mergestate
During a merge, each file has a current commitnode+filenode, an other
commitnode+filenode, and an ancestor commitnode+filenode. The ancestor
commitnode is not stored though, and we rely on the ability for the filectx() to
look up the commitnode by using the filenode's linkrev. In alternative backends
(like remotefilelog), linkrevs may have restriction that prevent arbitrary
linkrev look up given a filenode.

This patch accounts for that by storing the ancestor commitnode in
the merge state so that it is available later at resolve time.

This results in some test changes because the ancestor commitnode we're using at
resolve time changes slightly. Before, we used the linkrev commit, which is the
earliest commit that introduced that particular filenode (which may not be the
latest common ancestor of the commits being merged). Now we use the latest
common ancestor of the merged commits as the commitnode. This is fine though,
because that commit contains the same filenode as the linkrev'd commit.
2016-02-05 10:22:14 -08:00
Martin von Zweigbergk
8e7f0fdda8 merge: refuse update/merge if there are unresolved conflicts (BC)
We currently allow updating and merging (with --force) when there are
unresolved merge conflicts, as long as there is only one parent of the
working copy. Even worse, when updating to another revision
(linearly), if one of the unresolved files (including any conflict
markers in the working copy) can now be merged cleanly with the target
revision, the file becomes marked as resolved.

While we could potentially allow updates that affect only files that
are not in the set of unresolved files, that's considerably more work,
and we don't have a use case for it anyway. Instead, let's keep it
simple and refuse any merge or update (without -C) when there are
unresolved conflicts.

Note that test-merge-local.t explicitly checks for conflict markers
that get carried over on update. It's unclear if that was intentional
or not, but it seems bad enough that we should forbid it. The simplest
way of fixing the test case is to leave the conflict markers in place
and just mark the files resolved, so let's just do that for now.
2015-12-07 20:43:24 -08:00
Matt Harbison
ea3de44e49 test-resolve: fix '--tool f' invocation for Windows
Windows can't invoke a python script directly, so invoke sh.exe instead.

According to sid0, the output changes are due to the fact that 'f' is no longer
being passed all of the args that it was, but these changes aren't essential to
the test [1].

[1] https://selenic.com/pipermail/mercurial-devel/2015-November/075768.html
2015-11-22 21:20:08 -05:00
Siddharth Agarwal
4a78a436f9 mergestate: handle additional record types specially
This works around a bug in older Mercurial versions' handling of the v2 merge
state.

We also add a bunch of tests that make sure that
(1) we correctly abort when the merge state has an unsupported record type
(2) aborting the merge, rebase or histedit continues to work and clears out the
    merge state.
2015-11-18 15:46:45 -08:00
Siddharth Agarwal
d523c7a52e test-resolve.t: remove completely unnecessary line
I have no idea what I was thinking when I wrote this.
2015-11-18 23:42:32 -08:00
Matt Mackall
a20ef0162d merge with stable 2015-11-18 20:59:17 -06:00
Siddharth Agarwal
4e11ac7ea5 resolve: restore .orig only after merge is fully complete (issue4952)
Previously, we'd restore the .orig file after the premerge is complete but
before the merge was complete. This would lead to the .orig file potentially
containing merge conflict markers in it, as a leftover from the last merge
attempt.
2015-11-13 15:56:02 -08:00
Siddharth Agarwal
dbd338edf0 test-resolve.t: switch to mergestate.read()
See previous patches for why we're doing this.
2015-11-17 15:43:21 -08:00
Siddharth Agarwal
3465e76062 commands.resolve: don't allow users to mark or unmark driver-resolved files
Users will often be in the habit of running 'hg resolve --mark --all' after
resolving merge conflicts in source files. We need to make sure this doesn't
cause driver-resolved files to be marked.

'hg resolve --all' will resolve driver-resolved files, though.

The weird conditional structure is to accommodate an upcoming patch.
2015-10-15 01:15:22 -07:00
Siddharth Agarwal
25aa934095 resolve: perform all premerges before performing any file merges (BC)
Just like the BC to merge before it, this allows for a maximally consistent
state before providing any prompts to the user.
2015-10-11 23:58:07 -07:00
Siddharth Agarwal
4961e30679 test-resolve.t: add some tests for .orig file contents
An upcoming patch will touch some code around this area, and I couldn't find
any tests related to this.
2015-10-11 23:56:44 -07:00
Siddharth Agarwal
b47d5aac3c test-resolve.t: add some output to show order of operations
This basically shows the behavior of resolve with multiple files. An upcoming
behavior change will cause this output to also change.
2015-10-11 23:54:40 -07: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
timeless@mozdev.org
776539bcbf resolve: consistently describe re-merge + unresolved 2015-09-25 03:51:46 -04:00
Matt Harbison
d7467d5e8b tests: fix globs for Windows 2015-11-15 21:12:13 -05:00
Christian Delahousse
a53e055553 resolve: choose where .orig file locations are kept
Having your working copy littered with .orig files is a common HG complaint.
This patch uses the cmd.origpath helper function to let the user
specify where they should be kept when using the resolve command.
2015-11-10 14:26:19 -08:00
Yuya Nishihara
34b5e5774a resolve: port to generic templater
Test output changes because color labels are applied separately.
2015-02-11 13:59:13 +09:00
Yuya Nishihara
ab0dd2e3c1 resolve: silence warning of unknown pats for -l/--list (BC)
It was introduced at 1e92106a20bc to warn that "hg resolve" did nothing
meaningful. The warning seems not good for "hg resolve -l" because it is
rather like "hg status" or "hg files".
2015-02-11 13:47:43 +09:00
Augie Fackler
bc9dc896c1 test-resolve.t: use redirection to /dev/null instead of grep -q 2014-10-17 11:01:05 -04:00
Martin von Zweigbergk
6d828e9c66 resolve: run happily after conflict-free merge 2014-10-08 22:30:04 -07:00
Martin von Zweigbergk
3fff17492d test-resolve: add tests for re-merge 2014-10-08 22:16:18 -07:00
Martin von Zweigbergk
9791d9b4dc test-resolve: add more tests for in conflict-free states
We already have a test for 'hg resolve -m' when there is no merge in
progress. Add one for 'hg resolve --all' as well.

Also add tests for both --all and -m when there is a merge without
conflicts in progress. They should both be successful, just as if
there had been conflicts that had been marked resolved. However, that
is currently broken, so mark the tests broken for now. The behavior
will be fixed in a later patch.
2014-10-08 22:19:08 -07:00
Martin von Zweigbergk
1645eb5e43 test-resolve: add test resolving one of two files
The tests for resolve are missing a lot of cases. Let's start by
adding another file to the test repo, so we can test resolving one of
two files.
2014-10-08 21:07:30 -07:00
Martin von Zweigbergk
362a7efc7a test-resolve: clarify test descriptions and consistently use "should" 2014-10-08 21:19:31 -07:00
Pierre-Yves David
3efa776f85 resolve: add parenthesis around "no more unresolved files" message
This message may be confused with an error message. Adding parenthesis around it
will make it more recognisable as an informative message.
2014-07-26 03:32:49 +02:00
Matt Mackall
140901211f resolve: fix grammar of no matching files message 2014-06-09 14:11:17 -05:00
Siddharth Agarwal
265738b91b resolve: don't abort resolve -l even when no merge is in progress
This broke some internal automation that was quite reasonably checking for
unresolved files as a way to determine whether a merge happened cleanly. We
still abort for resolve --mark etc.
2014-05-23 13:10:31 -07:00
Matt Mackall
0cb0a7ba67 resolve: simplify "finished" message
The recently introduced message was:

  no unresolved files; you may continue your unfinished operation

This had three problems:

- looks a bit like an error message because it's not saying "we've
  just resolved the last file"
- refers to "unfinished operation", which won't be the case with
  "update" or "merge"
- introduces semicolons to error messages, which is stylistically
  questionable

I've simplified this to:

  no more unresolved files

In the future, if we want to prompt someone to continue a particular operation, we should use
a hint style:

  no more unresolved files
  (use 'hg graft --continue' to finish grafting)
2014-05-09 14:46:50 -05:00
Gregory Szorc
85e363fea8 resolve: print message when no unresolved files remain (issue4214)
When using resolve, users often have to consult with the output of |hg
resolve -l| to see if any unresolved files remain. This step is tedious
and adds overhead to resolving.

This patch will notify a user if there are no unresolved files remaining
after executing |hg resolve|::

    no unresolved files; you may continue your unfinished operation

The patch stops short of telling the user exactly what command should be
executed to continue the unfinished operation. That is because this
information is not currently captured anywhere. This would make a
compelling follow-up feature.
2014-04-18 22:19:25 -07:00
Gregory Szorc
3f06fc8ed0 resolve: print warning when no work performed (issue4208)
Previously, if the paths specified as arguments to |hg resolve| were
invalid, they were silently ignored and a no-op would ensue.

This patch fixes that in some scenarios.

If none of the paths specified to |hg resolve| match a path that is in
mergestate, a warning will be emitted.

Ideally, a warning would be emitted for every path/pattern specified
that doesn't match anything. To achieve this would require significant
refactoring of the matching subsystem. That work is beyond the scope of
this patch series. Something is better than nothing and this patch
gets us something.
2014-04-18 18:56:26 -07:00
Gregory Szorc
8e5e922c37 resolve: abort when not applicable (BC)
The resolve command is only relevant when mergestate is present.
This patch will make resolve abort when no mergestate is present.

This change will let people know when they are using resolve when they
shouldn't be. This change will let people know when their use of resolve
doesn't do anything.

Previously, |hg resolve -m| would allow mergestate to be created. This
patch now forbids that. Strictly speaking, this is backwards
incompatible. The author of this patch believes creating mergestate via
resolve doesn't make much sense and this side-effect was unintended.
2014-04-18 19:08:32 -07:00
Gregory Szorc
2ec67abea0 resolve: split test
Part of test-resolve.t is split into multiple tests to create an
injection point for new tests that will be added in subsequent patches.
2014-04-18 18:26:42 -07: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
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
Matt Mackall
08439e0f2d tests: add exit codes to unified tests 2010-09-16 17:51:32 -05:00
Brodie Rao
4be7b3bfc3 merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'
Without specifying the parent revision of the working copy, users will
update to tip, which is most likely the other head they were trying to
merge, not the revision they were at before the merge.
2010-09-12 18:05:53 -05:00
Nicolas Dumazet
4f017eca36 tests: unify test-resolve 2010-08-30 14:06:18 +09:00