Commit Graph

654 Commits

Author SHA1 Message Date
Jun Wu
f331a9612f merge: use ProgrammingError 2017-03-26 16:55:56 -07:00
Durham Goode
30b5b6d685 merge: remove unnecessary matcher checks
As part of changing manifest.diff to accept a matcher, a previous patch added
matcher calls to each location in merge.manifestmerge that tested if 'x in mf'
to maintain the same behavior as before. After analyzing it further, this
matcher call isn't needed, and in fact hurts future patches ability to use the
matcher here.

Basically, all these 'if x in mf' checks were checking if a matched file's copy
source was in the matcher as well. This meant if you passed a matcher for just
file foo, it would not return file bar even if foo was a copy of bar. Since
manifestmerge cares about copy information, let's allow all lookups of copy
sources.

We also update one spot with a 'is not None' check, since it wasn't obvious that
the value could sometimes be None before, which broke when we called
matcher(None).

A future patch adds matcher optimizations to manifestmerge which causes this
code path to get covered by existing tests.
2017-03-19 11:42:17 -07:00
Martin von Zweigbergk
31bb49fb7d merge: also allow 'e' action with experimental.updatecheck=noconflict
With experimental.updatecheck=noconflict set, if one checks out
e1870a31325e (tests: add execute bit and fix shbang line, 2015-12-22)
and then try to check out its parent, hg will complain about
conflicting changes, even though the working directory is clean. We
need to also allow the 'e' action in merge.py. The 'e' action is used
when moving to a commit where the only change to the file is to its
executable flag, so it's just an optimized 'g' action.

Doesn't seem to be worth writing a test for, since the existing setup
in test-update-branches.t does not set any flags.
2017-03-13 21:58:43 -07:00
Mads Kiilerich
ea3cfbc6fb merge: check current wc branch for 'nothing to merge', not its p1
The working directory will usually be clean or very clean, and wc will usually
have the same branch as its parent. This change will thus usually not make any
difference and is done as a separate change to show that. It will be used in a
later change.
2017-03-12 16:41:46 -07:00
Pierre-Yves David
98f81e8c4f merge: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:32 -08:00
Mads Kiilerich
01ac38526d merge: use repo.wvfs.unlinkpath 2015-01-14 01:15:26 +01:00
Mads Kiilerich
a936a7f3a7 vfs: use repo.wvfs.unlinkpath 2015-01-14 01:15:26 +01:00
Durham Goode
5d0340324a merge: remove uses of manifest.matches
This gets rid of the manifest.matches calls in merge.py in favor of the new api.
This is part of getting rid of manifest.matches since it is O(manifest).
2017-03-07 18:38:20 -08:00
Martin von Zweigbergk
4ad88a61e0 update: for "noconflict" updates, print "conflicting changes" on conflict
With experimental.updatecheck=noconflict, if the update is aborted
because of conlicts, "uncommitted changes" is not quite
accurate. Let's use "conflicting changes" instead. Also fix the hint
to recomment --clean, not --merge, since that's what we do for other
failed updates.
2017-03-06 23:21:27 -08:00
Martin von Zweigbergk
066bf0dbb3 update: allow setting default update check to "noconflict"
The new value allows update (linear or not) as long as they don't
result in file merges.

I'm hoping that this value can some day become the default.
2017-02-13 00:05:55 -08:00
Martin von Zweigbergk
5b3eb48725 update: accept --merge to allow merging across topo branches (issue5125) 2017-02-13 12:58:37 -08:00
Martin von Zweigbergk
4904a44779 merge: combine the "merge" cases in docstring table 2017-02-27 15:09:19 -08:00
Martin von Zweigbergk
dbab66ea10 merge: combine "dirty" cases in docstring table 2017-02-27 15:07:01 -08:00
Martin von Zweigbergk
f2dcab33cd merge: clarify non-linear default updates in docstring table
Non-linear updates won't happen by default, regardless of -c/-C.
2017-02-27 15:29:34 -08:00
Martin von Zweigbergk
2230022a53 merge: combine the two "can't happen" cases in docstring table 2017-02-27 15:02:36 -08:00
Martin von Zweigbergk
2b1e4cc1c6 merge: move "incompatible options" case first in docstring table 2017-02-27 15:00:13 -08:00
Martin von Zweigbergk
a3d141c00e merge: make "linear" an input in docstring table
Instead of having two ouputs, it seem simpler to have an addition
input. This will allow further simplification.
2017-02-27 14:58:53 -08:00
Martin von Zweigbergk
1d7591a0e3 merge: drop redundant column in docstring table
The "same" and "cross" columns now have the same values, so let's
combine them into "non-linear".
2017-02-27 14:33:17 -08:00
Martin von Zweigbergk
7fa2f6b954 merge: drop obsolete non-linear cases from docstring table
Since 5a430b57b16e (update: change default destination to tipmost
descendant (issue4673) (BC), 2016-02-02), non-linear updates can no
longer happen if the user doesn't specify a destination, so we can
drop these case from the table in the docstring of merge.update().
2017-02-27 14:27:22 -08:00
Martin von Zweigbergk
7e61f1a33b destutil: remove duplicate check and leave it to merge.update()
The check is done in merge.update() already and the next few patches
will add more checks there. Some of the additional checks will need
information about the merge that will not be available in destutil.

Since commands.postincoming() catches UpdateAbort(), we need to change
merge.update() to raise that more specific exception.

This goes directly again c6bcc960108f (destupdate: move the check
related to the "clean" logic in the function, 2015-10-05), but it will
simplify the next few patches, and we can always move it out again
(preferably move, not copy) after if we still think it's better that
way.
2017-02-09 09:52:32 -08:00
Martin von Zweigbergk
38e7618603 update: fix typo/stale comment to match code
The comment about "obsolete.background" seems to have been about
obsolete.foreground ever since it was introduced in fbdfa64ceced
(update: allow dirty update to foreground (successors), 2013-04-16),
so let's change it.
2017-02-09 09:55:31 -08:00
Martin von Zweigbergk
04e8402860 merge: remove unused handling of default destination in merge.update()
As far as I can tell, all the callers of merge.update() have been
migrated over to use destutil to find the default destination when the
revision was not specified. So it's time to delete the code for
handling a node value of None. Let's add an assertion that node is not
None, so any extensions relying on it will not silently misbehave.
2017-02-08 23:03:33 -08:00
Martin von Zweigbergk
25855165d1 update: localize logic around which ancestor to use
The merge code works by applying the changes between an ancestor and
the working copy onto the destination. To achieve an update, it sets
the ancestor to be the parent of the working copy. To achieve a clean
update (update -C), it sets the ancestor to be the working copy itself
(so there are no changes to carry over). The logic for this was spread
out a bit. Let's move it all to one place so it's easier to follow the
reason for it. Also add some documentation.
2017-02-08 14:49:37 -08:00
Mads Kiilerich
6945cf0f5b merge: more safe detection of criss cross merge conflict between dm and r
0b5f1f2efc77 introduced handling of a crash in this case. A review comment
suggested that it was not entirely obvious that a 'dm' always would have a 'r'
for the source file.

To mitigate that risk, make the code more conservative and make less
assumptions.
2017-02-01 02:10:30 +01:00
Mads Kiilerich
120b66d101 merge: fix crash on criss cross merge with dir move and delete (issue5020)
Work around that 'dm' in the data model only can have one operation for the
target file, but still can have multiple and conflicting operations on the
source file where the other operation is a 'rm'. The move would thus fail with
'abort: No such file or directory'.

In this case it is "obvious" that the file should be removed, either before or
after moving it. We thus keep the 'rm' of the source file but drop the 'dm'.

This is not a pretty fix but quite "obviously" safe (famous last words...) as
it only touches a rare code path that used to crash. It is possible that it
would be better to swap the files for 'dm' as suggested on
https://bz.mercurial-scm.org/show_bug.cgi?id=5020#c13 but it is not entirely
obvious that it not just would create conflicts on the other file. That can be
revisited later.
2017-01-31 03:25:59 +01:00
Gábor Stefanik
b631d16eab graft: support grafting changes to new file in renamed directory (issue5436) 2016-12-05 17:40:01 +01:00
Pulkit Goyal
97f340e354 py3: use pycompat.getcwd() instead of os.getcwd()
We have pycompat.getcwd() which returns bytes path on Python 3. This patch
changes most of the occurences of the os.getcwd() with pycompat one.
2016-11-23 00:03:11 +05:30
Augie Fackler
a9f44c7fb0 mergemod: drop support for merge.update without a target
This was to be deleted after 3.9.
2016-11-21 21:52:19 -05:00
Durham Goode
9fc9a7cf64 merge: change modified indicator to be 20 bytes
Previously we indicated that the .hgsubstate file was dirty by adding a '+' to
the end of its hash in the wctx manifest. This made is complicated to have new
manifest implementations that rely on the node length being fixed.

In previous patches we added added and modified node placeholders, so let's use
those to indicate dirty here as well. It doesn't look like anything ever
depended on this '+' (aside from it being different to the parent), so nothing
else needed to change here.
2016-11-10 02:21:15 -08:00
Durham Goode
fb55c2fbf3 dirstate: change added/modified placeholder hash length to 20 bytes
Previously the added/modified placeholder hash for manifests generated from the
dirstate was a 21byte long string consisting of the p1 file hash plus a single
character to indicate an add or a modify. Normal hashes are only 20 bytes long.
This makes it complicated to implement more efficient manifest implementations
which rely on the hashes being fixed length.

Let's change this hash to just be 20 bytes long, and rely on the astronomical
improbability of an actual hash being these 20 bytes (just like we rely on no
hash every being the nullid).

This changes the possible behavior slightly in that the hash for all
added/modified entries in the dirstate manifest will now be the same (so simple
node comparisons would say they are equal), but we should never be doing simple
node comparisons on these nodes even with the old hashes, because they did not
accurately represent the content (i.e. two files based off the same p1 file
node, with different working copy contents would have the same hash (even with
the appended character) in the old scheme too, so we couldn't depend on the
hashes period).
2016-11-10 02:19:16 -08:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
Gábor Stefanik
a47c5119e6 update: enable copy tracing for backwards and non-linear updates
As a followup to the issue4028 series, this fixes a variant of the issue
that can occur when updating with uncommited local changes.

The duplicated .hgsub warning is coming from wc.dirty(). We would previously
skip this call because it's only relevant when we're going to perform copy
tracing, which we didn't do before.

The change to the update summary line is because we now treat the rename as a
proper rename (which counts as a change), rather than an add+delete pair
(which counts as a change and a delete).
2016-08-25 22:02:26 +02:00
Stanislau Hlebik
b83f0c0687 update: warn if cwd was deleted
During update directories are deleted as soon as they have no entries.
But if current working directory is deleted then it cause problems
in complex commands like 'hg split'. This commit adds a warning
that will help users figure the problem faster.
2016-10-04 04:06:48 -07:00
Mads Kiilerich
ecb497971e merge: clarify warning for (not) merging flags without ancestor
Give hints why it can't merge and what it will do instead.
2016-10-12 12:22:18 +02:00
Mads Kiilerich
dc79a99eb6 merge: only show "cannot merge flags for %s" warning if flags are different 2016-10-12 12:22:18 +02:00
Yuya Nishihara
512724e1f5 merge: update doc of manifestmerge() per ce7e15f82b44
p1 was renamed to wctx by ce7e15f82b44.
2016-10-02 17:31:32 +09:00
Simon Farnsworth
dfbb92b63b merge: use labels in subrepo merge
This is the last place that doesn't respect conflict labels in merge output.
Teach subrepos to use subrepo merge output too.
2016-10-08 01:25:28 -07:00
Martin von Zweigbergk
2fbf01764c util: rename checkcase() to fscasesensitive() (API)
I always read the name "checkcase(path)" as "do we need to check for
case folding at this path", but it's actually (I think) meant to be
read "check if the file system cares about case at this path". I'm
clearly not the only one confused by this as the dirstate has this
property:

  def _checkcase(self):
      return not util.checkcase(self._join('.hg'))

Maybe we should even inverse the function and call it fscasefolding()
since that's what all callers care about?
2016-08-30 09:22:53 -07:00
Siddharth Agarwal
52c9a999c5 merge: remove files with extra actions from merge action list
See the comment for a detailed explanation why.

Even though this is a bug, I've sent it to 'default' rather than 'stable'
because it isn't triggered in any code paths in stock Mercurial, just with the
merge driver included. For the same reason I haven't included any tests here --
the merge driver is getting a new test.
2016-08-23 17:58:53 -07:00
Simon Farnsworth
1b7185f6d1 merge: always use other, not remote, in user prompts
Now that we store and display merge labels in user prompts (not just
conflict markets), we should rely on labels to clarify the two sides of a
merge operation (hg merge, hg update, hg rebase etc).

"remote" is not a great name here, as it conflates "remote" as in "remote
server" with "remote" as in "the side of the merge that's further away". In
cases where you're merging the "wrong way" around, remote can even be the
"local" commit that you're merging with something pulled from the remote
server.
2016-08-12 05:56:40 -07:00
Simon Farnsworth
906104f96d merge: use labels in prompts to the user
Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:

This means that merge prompts like:
  no tool found to merge a
  keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
  remote changed a which local deleted
  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
  no tool found to merge a
  keep (l)ocal [working copy], take (o)ther [destination], or leave (u)nresolved? u
and
  remote [source] changed a which local [dest] deleted
  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.
2016-08-12 06:01:42 -07:00
Kostia Balytskyi
989ebc4f0d update: fix bug when update tries to modify folder symlink
In cbefa73a359814e6784a63f90b78c7afd39bc7d5, I introduced a new bug:
when a symlink points to a folder in commit A and to another folder
in commit B, while updating from A to B, Mercurial will try to use
removedir on this symlink, which will fail. This is a very bad bug,
since it basically renders symlinks to folders unusable in repos.

Added test case fails without a fix and passes with it.
2016-07-21 15:55:47 -07:00
Kostia Balytskyi
78766f7ff1 update: teach hg to override untracked dir with a tracked file on update
This is a fix to an old problem when Mercurial got confused by an
untracked folder with the same name as one of the files in a commit
hg was trying to update to. It is pretty safe to remove this folder if
it is empty. Backing up an empty folder seems to go against Mercurial's
"don't track dirs" philosophy.
2016-07-01 17:42:55 +02:00
Augie Fackler
ad67b99d20 cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
All versions of Python we support or hope to support make the hash
functions available in the same way under the same name, so we may as
well drop the util forwards.
2016-06-10 00:12:33 -04:00
FUJIWARA Katsunori
390f95833b merge: make messages translatable
These messages have been overlooked by check-code, because they start
with non-alphabet character (' ').

Making these messages translatable seems reasonable, because all other
'ui.note()'-ed messages in calculateupdates() are already
translatable.

This is also a part of preparation for making "missing _() in ui
message" detection of check-code more exact.
2016-05-26 01:57:34 +09:00
timeless
a1cb3173a2 py3: convert to next() function
next(..) was introduced in py2.6 and .next() is not available in py3

https://docs.python.org/2/library/functions.html#next
2016-05-16 21:30:53 +00:00
Pierre-Yves David
f6e86ab7ff devel: officially deprecate update without destination
When we introduce the develwarning, we did not had an official deprecation API
and infrastructure. We can now officially deprecate the old way with a version
deadline.
2016-05-11 09:31:47 +02:00
Pierre-Yves David
6b9ad81f0e devel: use the new 'config' argument for the update develwarn 2016-05-08 10:43:41 +02:00
Simon Farnsworth
74ca86ac73 merge: save merge part labels for later reuse
We permit the caller of merge operations to supply labels for the merge
parts ("local", "other", and optionally "base"). These labels are used in
conflict markers to reduce confusion; however, the labels were not
persistent, so 'hg resolve' would lose the labels.

Store the labels in the mergestate.
2016-03-19 18:37:10 -07:00
Simon Farnsworth
ad7f9b0b86 merge: fix error message
Obvious copy-and-paste error
2016-02-26 19:13:10 +00:00