Commit Graph

432 Commits

Author SHA1 Message Date
Siddharth Agarwal
ecd3be8cef update: add error message for dirty non-linear update with no rev
Previously, the error message for a dirty non-linear update was the same (and
relatively unhelpful) whether or not a rev was specified. This patch and an
upcoming one will introduce separate, more helpful hints.
2013-09-23 20:07:30 -07:00
Siddharth Agarwal
55e7463f51 update: improve error message for clean non-linear update 2013-09-23 17:43:33 -07:00
Matt Mackall
72d6ff963c update: add tracking of interrupted updates (issue3113)
This takes advantage of the new checkunfinished infrastructure
2013-07-25 00:33:28 -05:00
Bryan O'Sullivan
16cdb3e1a8 merge: add a files method to the mergestate class
This will be used in the upcoming shelve extension.
2013-06-03 17:20:37 -07: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
Siddharth Agarwal
bc3c1061f7 manifestmerge: local unknown, remote created: don't traverse symlinks
To figure out what to do with locally unknown files, Mercurial attempts to read
them if they exist. When an attempt is made to read a file that exists but
traverses a symlink, Mercurial aborts.

With this patch, we first ensure that the file doesn't traverse a symlink
before opening it. This is fine because a file being "remote created" means the
symlink doesn't exist remotely, which means it will be deleted in the apply
phase.
2013-05-08 14:11:01 -07:00
FUJIWARA Katsunori
baa57a476c icasefs: rewrite case-folding collision detection (issue3452)
Before this patch, case-folding collision detection uses
"copies.pathcopies()" before "manifestmerge()", and is not aware of
renaming in some cases.

For example, in the case of issue3452, "copies.pathcopies()" can't
detect renaming, if the file is renamed at the revision before common
ancestor of merging. So, "hg merge" is aborted unexpectedly on case
insensitive filesystem.

This patch fully rewrites case-folding collision detection, and
relocate it into "manifestmerge()".

New implementation uses list of actions held in "actions" and
"prompts" to build provisional merged manifest up.

Provisional merged manifest should be correct, if actions required to
build merge result up in working directory are listed up in "actions"
and "prompts" correctly.

This patch checks case-folding collision still before prompting for
merge, to avoid aborting after some interactions with users. So, this
assumes that user would choose not "deleted" but "changed".

This patch also changes existing abort message, because sorting before
collision detection changes order of checked files.
2013-04-30 05:01:32 +09: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
Pierre-Yves David
11445bce46 update: allow dirty update to foreground (successors)
Update to "foreground" are no longer seen as cross branch update. "Foreground"
are descendants or successors (or successors of descendants (or descendant of
successors (etc))). This allows to update with uncommited changes that get
automatically merged.

This changeset is a small step forward. We want to allow dirty update to
"background" (precursors) and takes obsolescence in account when finding the
default update destination. But those requires deeper changes and will comes in
later changesets.
2013-04-16 15:33:18 +02:00
Siddharth Agarwal
559322b2a6 manifestmerge: handle workdir removed, remote removed with flags
This can happen when a file with flags is removed or deleted in the working
directory and also not present in m2. The obvious solution is to add a
__delitem__ override to manifestdict that removes the file from flags if
necessary, but that has a significant performance cost in some cases, e.g.
hg status --rev rev1 --rev rev2 <file>.
2013-04-10 12:34:42 -07:00
Siddharth Agarwal
6857870aa1 manifestmerge: drop redundant flags calls 2013-03-24 16:56:25 -07:00
Siddharth Agarwal
65dea36afd manifestmerge: use dicthelpers.diff and join
This patch improves manifestmerge performance significantly.

In a repository with 170,000 files, the following results were observed on a
clean working directory. Revision '.' adds one file.

hg perfmergecalculate -r .
- before: 0.41 seconds
- after: 0.13 seconds

hg perfmergecalculate -r .^
- before: 0.53 seconds
- after: 0.24 seconds

Comparing against '.' is much faster than comparing against '.^' because with
'.', the wctx and p2 manifest strings have the same identity, so comparisons
are simply pointer equality. With '.^', the strings have different identities
so we need to perform memcmps.

Any operation that uses manifestmerge benefits.
- hg update . goes from 2.04 seconds to 1.75
- hg update .^ goes from 2.52 seconds to 2.25
- hg rebase -r . -d .~6 (involves 4 merges) goes from 11.8 seconds to 10.8
2013-03-25 17:41:06 -07:00
Siddharth Agarwal
b321ec2b67 manifestmerge: rename n to n1 and n2
An upcoming patch will combine the two loops into one, so it's important to
distinguish between nodes in m1 and nodes in m2.
2013-03-24 16:43:25 -07:00
Kevin Bullock
e1d6f97b9f applyupdates: assign variable before we try to use it (issue3855)
The variable 'fd' was getting used with a value left over from a prior
iteration, causing a KeyError: '.hgsubstate'.
2013-03-18 16:37:20 -05:00
Durham Goode
474ac2b31e rebase: fix --collapse when a file was added then removed
When a series of commits first adds a file and then removes it,
hg rebase --collapse prompts whether to keep the file or delete it. This is
due to it reusing the branch merge code. In a noninteractive terminal it
defaults to keeping the file, which results in a collapsed commit that is
has a file that should be deleted. This bug resulted in developers accidentally
commiting unintentional changes to our repo twice today, so it's fairly
important to get fixed.

This change allows rebase --collapse to tell the merge code to accept the
latest version every time without prompting.

Adds a test as well.
2013-03-15 11:23:29 -07:00
Siddharth Agarwal
ddf37d440b manifestmerge: fix order in which manifests are fetched
If the manifest of an earlier revision on the same delta chain is read before
that of a later revision, the revlog remembers that we parsed the earlier
revision and continues applying deltas from there onwards. If manifests are
parsed the other way round, we have to start over from the fulltext.

For a fresh clone of mozilla-central, updating from 29dd80c95b7d to its parent
aab96936a177 requires approximately 400 fewer zlib.decompress calls, which
results in a speedup from 1.10 seconds to 1.05.
2013-02-10 16:55:01 +00:00
Siddharth Agarwal
e15d936707 merge: run _forgetremoved after manifestmerge
_forgetremoved can trigger manifest construction, but we only want it to
happen after manifestmerge, so that our attempt to read the manifests in the
right order in an upcoming patch actually works.
2013-02-10 12:16:46 +00:00
Bryan O'Sullivan
7bc15afd4e merge: don't fiddle with name lookups or i18n in hot loops
We perform attribute dereferences and i18n lookups before looping.
2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
9f400d1ba0 merge: apply non-interactive working dir updates in parallel
This has a big effect on the performance of working dir updates.

Here are the results of update from null to the given rev in several
repos, on a Linux 3.2 system with 32 cores running ext4, with the progress
extension enabled.

repo             rev           plain  parallel   speedup
hg               76a842fb67cc    0.9       0.3       3
mozilla-central  fe1600b22c77   42.8       7.7       5.5
linux-2.6        9ef4b770e069   31.4       4.9       6.4
2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
614bf1f422 merge: report non-interactive progress in chunks
Instead of a monotonic count, getupdates yields the number of files it
has updated since it last reported, and its caller sums the numbers when
updating progress.

Once we run these updates in parallel, this will allow worker processes
to report progress less often, reducing overhead.
2013-02-09 15:22:09 -08:00
Bryan O'Sullivan
a4f361dc0f merge: handle subrepo merges and .hgsubstate specially
In an upcoming patch, we will update .hgsubstate in a non-interactive
worker process. Merges of subrepo contents will still need to occur in the
master process (since they may be interactive), so we move that code into
a place where it will always run in what will become the master process.
2013-02-09 15:22:08 -08:00
Bryan O'Sullivan
5278db7f07 merge: split out mostly-non-interactive working dir updates
In a later patch, we'll run these updates in parallel.
2013-02-09 15:21:58 -08:00
Bryan O'Sullivan
88fa66b36f merge: don't call copies.mergecopies unless we need to
This reduces the amount of time we spend calculating when doing a clean
non-merge update. In a large repo, the time dropped from 10.1 seconds
to 3.4.
2013-02-09 21:24:36 +00:00
Bryan O'Sullivan
f7ffd2b365 merge: rename p1 to wctx in manifestmerge
This is always a workingctx, and this name is more in line with other
functions in this module.
2013-02-09 21:24:24 +00:00
Siddharth Agarwal
52f9cd4b20 manifestmerge: handle abort on local unknown, remote created files
This replaces the _checkunknown call in calculateupdates with a more
performant version. On a repository with over 150,000 files, this speeds up an
update by 0.6-0.8 seconds, which is up to 25%.

This does not introduce any UI changes. There is existing test coverage for
every case, mostly in test-merge*.t.
2013-02-09 15:36:00 +00: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
4310c010e8 merge: inline act()
The act function had become very trivial and mainly shuffled arguments around
and made it harder to see what really was going on.
2013-02-04 02:46:53 +01: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
c2bd1c416f merge: backout manifest sorting and workarounds for cost of it
Backout f6ac62c2cfa7 and 14f4258e3526 which no longer are needed.
2013-02-04 02:46:38 +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
3da557a087 merge: make all action tuples have the same length - keep args as tuple 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
adb98eb255 merge: fix UnboundLocalError (issue3791)
A wrong variable name was introduced in 84dc2a17eab4 for a case without test
coverage.

The variable name is fixed and a test case is introduced.
2013-01-30 19:29:36 +01:00
Matt Mackall
000c66e909 merge: only sort manifests in debug mode (issue3769) 2013-01-20 17:18:00 -06:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Mads Kiilerich
bc50dd6c71 merge: process files in sorted order 2013-01-15 02:59:12 +01:00
Mads Kiilerich
60e6a66d4b merge: remove "case" comments
The comments introduced in a1723fcd2b2d seems important ... but the context has
apparently been lost and they do not have any value now.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
37a2d73d5e merge: merge file flags together with file content
The 'x' flag and the 'l' flag are very different. It is usually not a problem
to change the 'x' flag of a normal file independent of the content, but one
does not simply change the type of a file to 'l' independent of the content.

This removes the fmerge function that merged both 'x' and 'l' independent of
content early in the merge process. This correctly introduces some conflicts
instead of silent incorrect merges. 3-way flag merge will now be done in the
resolve process, right next to file content merge. Conflicts can thus be
resolved with (slightly inconvenient) resolve commands like 'resolve f --tool
internal:other'. It thus brings us closer to be able to re-solve manifest merge
after the merge and avoid prompts during merge.

This also removes the "conflicting flags for a - (n)one, e(x)ec or sym(l)ink?"
prompt that nobody could answer and that made it easy to mix symlink targets
and file contents up. Instead it will give a file merge where a sufficiently
clever merge tool can help resolving the issue.
2013-01-09 02:02:45 +01:00
Mads Kiilerich
befdd21355 merge: remove old pre-audit code checking for absolute paths
Audit will handle this in a more elegant way.
2013-01-10 03:40:45 +01:00
Mads Kiilerich
233c071ef3 merge: drop reference to file contents immediately after write
Like 6c6ada8fd4c5 this reduces memory usage on large merges.
2013-01-10 00:45:51 +01:00
Mads Kiilerich
a09e5b862c merge: changing the mode of a file is also an update
It was a change in the file system that wasn't reported in the summaries.
2013-01-10 00:44:23 +01:00
Mads Kiilerich
b4877a560f merge: use util.unlinkpath for removing moved files
- more like how removed files are removed.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
39b66595ef merge: .hgsubstate is special as merge destination, not as merge source 2013-01-15 01:05:12 +01:00
Mads Kiilerich
360ab16fc3 merge: remove redundant unlink after merge
The early prescan for move/remove and removal of moved files in applyupdates
was introduced with mergestate 5ff549be1f0c and rendered this chunk of code
irrelevant.

The impact of the chunk was reduced in 0309b0586c65 - but it could have been
removed completely.
2013-01-09 00:01:33 +01:00
Mads Kiilerich
106702cb3a merge: rename list of actions from action to actions 2013-01-09 00:01:33 +01:00
Mads Kiilerich
2c466c126f merge: consistently use "x" instead of 'x' for internal action types
This makes it simpler to search for places where the action types are handled.
2013-01-09 00:01:33 +01:00
Mads Kiilerich
0fea0bfee8 merge: consistently use repo.wopener.audit instead of creating a new auditor 2013-01-09 00:01:33 +01:00
Mads Kiilerich
275333d6c9 util: fold ENOENT check into unlinkpath, controlled by new ignoremissing flag
Refactor a common pattern.
2012-12-28 11:55:57 +01:00
Siddharth Agarwal
8e266eb31f copies: separate moves via directory renames from explicit copies
Currently the "copy" dict contains both explicit copies/moves made by a
context and pending moves that need to happen because the other context moved
the directory the file was in. For explicit copies, the dict stores a
destination to source map, while for pending moves via directory renames, it
stores a source to destination map. The merge code uses this fact in a non-
obvious way to differentiate between these two cases.

We make this explicit by storing these pending moves in a separate dict. The
dict still has a source to destination map, but that is called out in the
docstring.
2012-12-26 14:50:17 -08:00
Kevin Bullock
9fbb5bfee2 merge: fix mistake in moved _checkcollision call from 9d2a09d53599 2012-12-06 22:07:44 -06:00
David Schleimer
3dbabdb2fc merge: support calculating merge actions against non-working contexts
This is not currently used.  It is instead a pre-requisite to
performing non-conflicting grafts in memory, which a subsequent patch
will do.
2012-12-04 12:54:18 -08:00
David Schleimer
00a1d6a1fe merge: refactor action calculation into function
This pulls the code used to calculate the changes that need to happen
during merge.update() into a separate function.  This is not useful on
its own, but is instead preparatory to performing grafts in memory
when there are no potential conflicts.
2012-12-04 12:54:18 -08:00
FUJIWARA Katsunori
2cf8855a64 icasefs: make case-folding collision detection as deletion aware (issue3648)
Before this patch, case-folding collision is checked simply between
manifests of each merged revisions.

So, files may be considered as colliding each other, even though one
of them is already deleted on one of merged branches: in such case,
merge causes deleting it, so case-folding collision doesn't occur.

This patch checks whether both of files colliding each other still
remain after merge or not, and ignores collision if at least one of
them is deleted by merge.

In the case that one of colliding files is deleted on one of merged
branches and changed on another, file is considered to still remain
after merge, even though it may be deleted by merge, if "deleting" of
it is chosen in "manifestmerge()".

This avoids fail to merge by case-folding collisions after choices
from "changing" and "deleting" of files.

This patch adds only tests for "removed remotely" code paths in
"_remains()", because other ones are tested by existing tests in
"test-casecollision-merge.t".
2012-10-31 16:50:22 +09:00
Thomas Arendsen Hein
91a8201c52 merge: warn about file deleted in one branch and renamed in other (issue3074)
For divergent renames the following message is printed during merge:
note: possible conflict - file was renamed multiple times to:
 newfile
 file2

When a file is renamed in one branch and deleted in the other, the file still
exists after a merge. With this change a similar message is printed for mv+rm:

note: possible conflict - file was deleted and renamed to:
 newfile
2012-05-23 20:50:16 +02:00
Brodie Rao
d36ae7f264 localrepo: add branchtip() method for faster single-branch lookups
For the PyPy repo with 744 branches and 843 branch heads, this brings
hg log -r default over NFS from:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
        3249            0      1.3222      1.3222   <open>
        3244            0      0.6211      0.6211   <method 'close' of 'file' objects>
        3243            0      0.0800      0.0800   <method 'read' of 'file' objects>
        3241            0      0.0660      0.0660   <method 'seek' of 'file' objects>
        3905            0      0.0476      0.0476   <zlib.decompress>
        3281            0      2.6756      0.0472   mercurial.changelog:182(read)
       +3281            0      2.5256      0.0453   +mercurial.revlog:881(revision)
       +3276            0      0.0389      0.0196   +mercurial.changelog:28(decodeextra)
       +6562            0      0.0123      0.0123   +<method 'split' of 'str' objects>
       +6562            0      0.0408      0.0073   +mercurial.encoding:61(tolocal)
       +3281            0      0.0054      0.0054   +<method 'index' of 'str' objects>
        3241            0      2.2464      0.0456   mercurial.revlog:818(_loadchunk)
       +3241            0      0.6205      0.6205   +<method 'close' of 'file' objects>
       +3241            0      0.0765      0.0765   +<method 'read' of 'file' objects>
       +3241            0      0.0660      0.0660   +<method 'seek' of 'file' objects>
       +3241            0      1.4209      0.0135   +mercurial.store:374(__call__)
       +3241            0      0.0122      0.0107   +mercurial.revlog:810(_addchunk)
        3281            0      2.5256      0.0453   mercurial.revlog:881(revision)
       +3280            0      0.0175      0.0175   +mercurial.revlog:305(rev)
       +3281            0      2.2819      0.0119   +mercurial.revlog:847(_chunkraw)
       +3281            0      0.0603      0.0083   +mercurial.revlog:945(_checkhash)
       +3281            0      0.0051      0.0051   +mercurial.revlog:349(flags)
       +3281            0      0.0040      0.0040   +<mercurial.mpatch.patches>
       13682            0      0.0479      0.0248   <method 'decode' of 'str' objects>
       +7418            0      0.0228      0.0076   +encodings.utf_8:15(decode)
          +1            0      0.0003      0.0000   +encodings:71(search_function)
        3248            0      1.3995      0.0246   mercurial.scmutil:218(__call__)
       +3248            0      1.3222      1.3222   +<open>
       +3248            0      0.0235      0.0184   +os.path:80(split)
       +3248            0      0.0084      0.0068   +mercurial.scmutil:92(__call__)
Time: real 2.750 secs (user 0.680+0.000 sys 0.360+0.000)

down to:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
          55           31      0.0197      0.0163   <__import__>
          +1            0      0.0006      0.0002   +mercurial.context:8(<module>)
          +1            0      0.0042      0.0001   +mercurial.revlog:12(<module>)
          +1            0      0.0002      0.0001   +mercurial.match:8(<module>)
          +1            0      0.0003      0.0001   +mercurial.dirstate:7(<module>)
          +1            0      0.0057      0.0001   +mercurial.changelog:8(<module>)
           1            0      0.0117      0.0032   mercurial.localrepo:525(_readbranchcache)
        +844            0      0.0015      0.0015   +<binascii.unhexlify>
        +845            0      0.0010      0.0010   +<method 'split' of 'str' objects>
        +843            0      0.0045      0.0009   +mercurial.encoding:61(tolocal)
        +843            0      0.0004      0.0004   +<method 'setdefault' of 'dict' objects>
          +1            0      0.0003      0.0003   +<method 'close' of 'file' objects>
           3            0      0.0029      0.0029   <method 'read' of 'file' objects>
           9            0      0.0018      0.0018   <open>
         990            0      0.0017      0.0017   <binascii.unhexlify>
          53            0      0.0016      0.0016   mercurial.demandimport:43(__init__)
         862            0      0.0015      0.0015   <_codecs.utf_8_decode>
         862            0      0.0037      0.0014   <method 'decode' of 'str' objects>
        +862            0      0.0023      0.0008   +encodings.utf_8:15(decode)
         981            0      0.0011      0.0011   <method 'split' of 'str' objects>
         861            0      0.0046      0.0009   mercurial.encoding:61(tolocal)
        +861            0      0.0037      0.0014   +<method 'decode' of 'str' objects>
         862            0      0.0023      0.0008   encodings.utf_8:15(decode)
        +862            0      0.0015      0.0015   +<_codecs.utf_8_decode>
           4            0      0.0008      0.0008   <method 'close' of 'file' objects>
         179          154      0.0202      0.0004   mercurial.demandimport:83(__getattribute__)
         +36           11      0.0199      0.0003   +mercurial.demandimport:55(_load)
         +72            0      0.0001      0.0001   +mercurial.demandimport:83(__getattribute__)
         +36            0      0.0000      0.0000   +<getattr>
           1            0      0.0015      0.0004   mercurial.tags:148(_readtagcache)
Time: real 0.060 secs (user 0.030+0.000 sys 0.010+0.000)
2012-05-13 14:04:04 +02:00
Patrick Mezard
d99bfab018 rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.

I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.

The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.

The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.

And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 15:14:58 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Matt Mackall
300b5fdbe1 merge: check for untracked files more precisely (issue3400)
This fixes the regression, but still leaves the long-standing issue
that merge doesn't cope with trying to merge files and directories.
2012-04-27 13:18:09 -05:00
Patrick Mezard
d7a11b26ae update: fix case-collision with a clean wd and no --clean
a317664437ee introduced some logic to avoid case-collision detection between
source and destination revisions when it does not make sense: clean or to be
cleaned working directories. Unfortunately, part of it was flawed and the
related test was broken by another bug.

This patch disables cross revision case collision detection for updates without
option or with --check, if the working directory is clean.
2012-04-23 14:32:59 +02:00
FUJIWARA Katsunori
15d40e6d68 icasefs: make case-folding collision detection as rename aware (issue3370)
if the file in target context causes case-folding collision against
one in working context, current implementation aborts merging with it,
even thouhg collding one (in target) is the file renamed from collided
one (in working).

this patch uses file copy information to know whether colliding file
is renamed from collided one or not: if so, collision between them is
ignored.

this patch also avoids collision detection between current context and
target context, if working context is clean (with --check/-c) or will
be clean (with --clean/-C).
2012-04-16 01:11:29 +09:00
Matt Mackall
6d3a783a57 merge: fix unknown file merge detection for case-folding systems
This was triggering some test failures on Mac.
2012-03-26 16:41:54 -05:00
Matt Mackall
61779234ab merge with stable 2012-03-15 13:11:42 -05:00
Matt Mackall
89d8d8b996 merge: accept missing revisions in symlink flag merge (issue3316) 2012-03-14 14:45:41 -05:00
Matt Mackall
2a84e7e364 merge with stable 2012-03-13 16:29:13 -05:00
Matt Mackall
5eda7202ad merge: handle linear update to symlink correctly (issue3316)
This fixes a regression introduced by df049e784ab6. If no file-level
merge is needed, we can update flags directly, otherwise we have a
conflict to resolve in filemerge.
2012-03-13 16:28:08 -05:00
Matt Mackall
26807610cb copies: remove checkdirs options
This removes the undocumented merge.followdirs option, which has
always been true.
2012-02-25 14:22:58 -06:00
Matt Mackall
630fa7d8fc merge: defer symlink flag merging to filemerge (issue3200)
Previously, we could change a normal file into a corrupt symlink when
trying to merge a symlink flag. Now, we leave the flag alone and let
filemerge deal with it (usually by a prompt).

We also drop a redundant flag setting after filemerge (now dealt with
by ms.resolve) that would cause similar corruption.
2012-01-26 20:34:57 -06:00
Matt Mackall
1b38343e48 update: just merge unknown file collisions
The unknown file collision rule was introduced as an extension of the
"should be clean when merging" rule. Unfortunately, it got applied to
the normal update path, which should be happy to merge local changes.

This patch gives us merges for unknown file collisions on update,
while preserving abort for merge and update -c.
2012-02-09 17:54:47 -06:00
Matt Mackall
e3a172f2f0 merge: don't use unknown()
This removes use of unknown files for building the synthetic working
directory manifest used by manifestmerge. Instead, we adopt the
strategy used by _checkunknown.

Side-effect: unknown files are no longer moved by remote directory
renames, and now are left alone like ignored files.
2012-02-09 17:04:17 -06:00
Matt Mackall
f454042775 merge: refactor unknown file conflict checking
Previously, we would do a full working directory walk including
unknown files to perform a merge. In many cases, this was painful
because unknown files greatly outnumbered tracked files and generally
had no useful effect on the merge.

Here we instead wait until we find a file in the destination that's
not tracked locally and detect if it exists and is not ignored. This
is usually cheaper but can be -more- expensive in the case where we're
adding a huge number of files. On the other hand, the cost of statting
the new files should be dwarfed by the cost of eventually writing
them.

In this version, case collisions are detected implicitly by
os.path.exists and wctx[f] lookup.
2012-02-09 16:50:19 -06:00
Matt Mackall
1ceb79342c update: use normal update path with --check (issue2450)
This avoids clobbering unknown files on update by not using overwrite mode.
2012-02-09 13:16:20 -06:00
Jordi Gutiérrez Hermoso
b28181a568 merge: report all files in _checkunknown
When doing hg up, if there is a file conflict with untracked files,
currently only the first such conflict is reported. With this patch,
all of them are listed.

With this patch error message is now reported as

    a: untracked file differs
    b: untracked file differs
    abort: untracked files in working directory conflict with files in
    requested revision

instead of

    abort: untracked file in working directory differs from file in
    requested revision: 'a'

This is a follow up to an old attempt to do this here:

    http://selenic.com/pipermail/mercurial-devel/2011-August/033625.html
2012-01-11 15:53:42 -05:00
Matt Mackall
9bfa890ee6 copies: split the copies api for "normal" and merge cases (API) 2012-01-04 15:48:02 -06:00
Matt Mackall
7cf4e6eacb merge with stable 2011-12-16 19:05:59 -06:00
FUJIWARA Katsunori
1a00d3603f merge: check filename case collision between changesets for branch merging
this patch makes branch merging abort when merged changesets have same
file in different case on case insensitive filesystem.

this patch does not prevent linear update which merges between target
and working contexts, because 'branchmerge' is False in such case.
2011-12-16 21:21:27 +09:00
Matt Mackall
03f5247248 merge with stable 2011-12-15 14:37:36 -06:00
FUJIWARA Katsunori
ee602b5c96 icasefs: use util.normcase() instead of str.lower() or os.path.normpath() 2011-12-12 17:10:19 +09:00
Mads Kiilerich
ba2b5b0d23 update: don't clobber untracked files with wrong casing 2011-11-20 23:09:32 +01: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
Kevin Bullock
4b1f198355 merge: make 'nothing to merge' aborts consistent
Makes the 'nothing to merge' abort messages in commands.py consistent with
those in merge.py. Also makes commands.merge() and merge.update() use hints.
The tests show the changes.
2011-12-07 11:23:01 -06:00
Martin Geisler
5767d9d56f merge: use repo.ui directly instead local variable
The non-standard 'u = repo.ui' shorthand was only used two times and
there were many other full references to repo.ui.
2011-08-17 14:11:46 +02:00
FUJIWARA Katsunori
a423a1ab9d i18n: use UTF-8 string to lower filename for case collision check
Some character sets, cp932 (known as Shift-JIS for Japanese) for
example, use 0x41('A') - 0x5A('Z') and 0x61('a') - 0x7A('z') as second
or later character.

In such character set, case collision checking recognizes different
files as CASEFOLDED same file, if filenames are treated as byte
sequence.

win32mbcs extension is not appropriate to handle this problem, because
this problem can occur on other than Windows platform only if
problematic character set is used.

Callers of util.checkcase() use known ASCII filenames as last
component of path, and string.lower() is not applied to directory part
of path. So, util.checkcase() is kept intact, even though it applies
string.lower() to filenames.
2011-07-28 14:36:07 +09:00
Augie Fackler
a3d0340408 update: check wc.dirty() before setting overwrite=True
merge.update() was missing a few dirtiness checks from workingcontext,
including subrepo cleanliness checks. Using wc.dirty() instead of
one-off checks for various forms of dirtiness will be significantly
safer.
2011-06-17 15:21:02 -05:00
Brendan Cully
ea84333a75 Make pull -u behave like pull && update
Previously, pull would not update if new branch heads were received,
whereas pull && update would move to the tipmost branch head.

Also change the "crosses branches" abort in merge.update from
"crosses branches (merge branches or use --check to force update)"
to
"crosses branches (merge branches or update --check to force update)"

since it can no longer assume the user is running hg update.
2011-05-31 11:52:22 -07:00
Matt Mackall
97c6e7b48d dirstate: rename forget to drop
It has substantially different semantics from forget at the command
layer, so change it to avoid confusion.

We can't simply combine it with remove because we need to explicitly
drop non-added files in some cases like commit.
2011-05-26 17:15:35 -05:00
Adrian Buehlmann
a11d19c5ad applyupdates: audit merged files
protects changing flags on merged files (util.setflags call on line 341)
2011-05-22 11:03:15 +02:00
Adrian Buehlmann
18e5c7b1c9 applyupdates: audit path on flag changes
we're using the auditor of the repo wopener, since this is a path that belongs
to the tree we're updating to
2011-05-21 23:21:12 +02:00
Adrian Buehlmann
4c8d0e46fa applyupdates: audit unlinking of renamed files and directories 2011-05-21 02:05:00 +02:00
Adrian Buehlmann
c415440828 rename util.set_flags to setflags 2011-05-06 15:22:31 +02:00
Adrian Buehlmann
e981d64ef2 rename path_auditor to pathauditor
The Mercurial 1.9 release is moving a lot of stuff around anyway and we are
already moving path_auditor from util.py to scmutil.py for that release.

So this seems like a good opportunity to do such a rename. It also strengthens
the current project policy to avoid underbars in names.
2011-05-06 09:54:06 +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
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Adrian Buehlmann
307196b733 move path_auditor from util to scmutil 2011-04-20 22:43:31 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Matt Mackall
a9a1073611 merge: add ancestor to the update function
This makes it easier to do rebase-like operations.
2011-04-04 15:25:20 -05:00
Matt Mackall
f8809566c2 merge with stable 2011-03-23 09:20:40 -05:00
Matt Mackall
c989b5dd89 merge: avoid unlinking destination of merge when case changes (issue2715) 2011-03-22 12:00:38 -05:00
Matt Mackall
81bd0b7967 merge: back out single-parent fast-forward merge
This backs out

 changeset:   13158:17d1b96c0f12
 user:        Mads Kiilerich <mads@kiilerich.com>
 date:        Tue Dec 07 03:29:21 2010 +0100
 summary:     merge: fast-forward merge with descendant

Before named branches, the invariants were:

a) "merges" always have two parents
b) p1 is not linearly related to p2

Adding named branches made (b) problematic, so the above patch was
introduced, which fixed (b) but broke (a).

After discussion, we decided that the invariants should be:

a) "merges" always have two parents
b) p1 is not linearly related to p2 OR p1 and p2 are on different branches
2011-03-07 15:03:10 -06:00
Matt Mackall
f9bf397695 merge: drop resolve state for mergers with identical contents (issue2680) 2011-03-05 16:34:59 -06:00