Commit Graph

596 Commits

Author SHA1 Message Date
Mads Kiilerich
f3cdae8f42 largefiles: don't mute and obfuscate http errors when putlfile fails
'unexpected putlfile response: None' when an http error occurs is not very
helpful.

Instead, leave the handling of urllib2.HTTPError exceptions to other layers.
2015-10-23 21:27:29 +02:00
Mads Kiilerich
24ee58b9f9 largefiles: check hash of files in the store before copying to working dir
If the store somehow got corrupted, users could end up in weird situations that
were very hard to recover from or lead to propagation of the corruption.

Instead, spend the extra time checking the hash when copying to the working
directory. If it doesn't match, emit a warning, and don't put wrong content in
the working directory.
2015-10-23 21:27:29 +02:00
Mads Kiilerich
602d83e7e6 largefiles: fix explicit commit of normal/largefile switch
Commit of corresponding normal/largefiles pairs would only commit the standin.
That is usually fine, except if either the normal file or the standin is a
remove while the other is an add. In that case it would either give duplicate
colliding entries or lose the file.

Instead, commit both filenames if one of them is a remove.
2015-10-21 00:18:11 +02:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
FUJIWARA Katsunori
54ce7de850 dirstate: show develwarn for write() invocation without transaction
This is used to detect 'dirstate.write()' invocation without the value
gotten by 'repo.currenttransaction()' (mainly focused on 3rd party
extensions).
2015-10-17 01:15:34 +09:00
Mads Kiilerich
2de7a8b7cf largefiles: better handling of merge of largefiles that not are available
Before, when merging revisions with missing largefiles, the missing largefiles
would be fetched as a part of the merge. If that failed (for example because
the main repository temporarily was unavailable), the largefile would be left
missing. However, the next commit would abort and (seemed to) fail when
markcommitted tried to mark the standin file as normal and thus had to hash the
largefile that didn't exist. (Actually, the commit would succeed but the
largefile update that follows right after the commit transaction would abort -
quite confusing.)

To fix that, make sure that synclfdirstate only marks files as normal if they
actually exist.
2015-10-12 19:22:34 +02:00
Siddharth Agarwal
dd90f817f9 filemerge: introduce a premerge flag and function
This flag will let us get to our overall goal of performing all premerges
before any merges.
2015-10-11 20:47:04 -07:00
Siddharth Agarwal
82f2aec334 filemerge: also return whether the merge is complete
In future patches, we'll pause merges after the premerge step. After the
premerge step we'll return complete = False.
2015-10-11 12:56:21 -07:00
Siddharth Agarwal
da75e232c9 filemerge: add a wrapper around the filemerge function
We'll introduce a separate premerge function that calls the same code.
2015-10-11 12:31:08 -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
Matt Mackall
eb810eca5f merge with stable 2015-10-01 12:17:46 -05:00
Matt Harbison
f5215c2c04 largefiles: restore archiving largefiles with hgweb (issue4859)
This regressed in f07f4c45a8f2, when trying to conditionally disable archiving
of largefiles.

I'm not sure if wrapfunction() is the right way to do this, but it seems to
work.  The mysterious issue with lfstatus getting out of sync in the proxy and
the unfiltered view crops up again here.  See the referenced cset for more info.
2015-09-29 23:29:44 -04:00
Pierre-Yves David
a551464cdd largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:49:02 -07:00
Pierre-Yves David
ffcbdf7cc8 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:48:24 -07:00
Pierre-Yves David
cdc21e7de4 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:48:02 -07:00
Pierre-Yves David
4838705431 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:46:37 -07:00
Pierre-Yves David
40bf417522 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:46:12 -07:00
Pierre-Yves David
ef62bb6e54 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:44:59 -07:00
Pierre-Yves David
4dc7b8ccac largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:44:32 -07:00
Pierre-Yves David
a7ba280694 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:41:43 -07:00
Pierre-Yves David
28f9483962 largefiles: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:40:53 -07:00
Matt Harbison
dd27c92fee largefiles: ensure lfutil.getstandinmatcher() only matches standins
Previously, simply having the largefiles extension loaded without any largefiles
added would crash when amending with -I.  The problem was with no files in the
matcher, the pattern list of files joined with 'standindir' was empty, and
scmutil.match() would match everything.  In lfutil.composestandinmatcher(), the
match function is used to test if the file is a standin, and after getting a
false positive, proceeds to call lfutil.splitstandin().  This returns None
because it isn't a standin, which blows up when passed to rmatcher.matchfn().

Manually overriding _always in getstandinmatcher() probably isn't necessary
anymore, but we leave well enough alone on stable.  This regressed in
78632d61a993.
2015-08-12 12:26:39 -04:00
Matt Harbison
66766c7b03 largefiles: allow the archiving of largefiles to be disabled
There are currently no users of this, but it is a necessary step before
converting extdiff to use archive.  It may be useful to add an argument to
extdiff in the future and allow largefiles to be diffed, but archiving
largefiles can have significant overhead and may not be very diffable, so
archiving them by default seems wrong.

It is a mystery to me why the lfstatus attribute needs to be set on the
unfiltered repo.  However if it is set on the filtered repo instead (and the
filtered repo is passed to the original command), the lfstatus attribute is
False in the overrides for archival.archive() and hgsubrepo.archive() when
invoking the archive command.  This smells like the buggy status behavior (see
9fc565fa1621, which was reverted in e1574a4a2cad).  Neither the status nor
summary commands have this weird behavior in their respective overrides.
2015-07-11 23:26:33 -04:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Matt Harbison
0dc20be5d4 archive: support 'wdir()'
This is a step toward replacing the extdiff internals with archive, in order to
support 'extdiff -S'.  Only Mercurial subrepos are supported for now.

If a file is missing from the filesystem, it is silently skipped.  Perhaps it
should warn, but it cannot abort when working with extdiff because deleting a
file is a legitimate diff.
2015-06-16 23:06:57 -04:00
Matt Harbison
c3c21b7f9c largefiles: restore the original converter class after lfconvert --to-normal
Not sure how much this really matters, but much of the largefiles code that
monkey-patches like this restores things when it finishes.
2015-06-12 16:11:42 -04:00
Matt Harbison
41b0ff8118 largefiles: ignore hidden changesets with 'verify --large --lfa'
Previously, if there were any hidden changesets, the --lfa argument would cause
the command to abort with a hint about using --hidden when it tripped over a
hidden changeset.
2015-06-06 22:10:18 -04:00
Matt Harbison
66999fb4d6 largefiles: use the optional badfn argument when building a matcher
The monkey patching in cat() can't be fixed, because it still delegates to the
original bad().  Overriding commands.cat() should go away in favor overriding
cmdutil.cat() anyway, and that matcher can be wrapped with matchmod.badmatch().
2015-06-05 22:53:15 -04:00
Matt Harbison
39e618db88 scmutil: add an optional parameter to matcher factories for a bad() override
Even though scmutil.matchandpats() is documented to warn about bad files,
several callers silence the warning.
2015-06-05 19:24:32 -04:00
Matt Harbison
cb8f521952 largefiles: replace match.bad() monkey patching with match.badmatch()
No known issues with the previous code since it restored the original method,
but this is cleaner.

The monkey patching in cat is harmless, because it is created locally, and
doesn't pass it anywhere (subrepo cat isn't supported with largefiles).
2015-06-04 22:11:18 -04:00
Matt Harbison
8c17041c7c largefiles: drop the unused lfcommands._addchangeset() 2015-05-28 14:14:11 -04:00
Matt Harbison
3ab2bc3f24 largefiles: use the convert extension for 'lfconvert --to-normal'
The logic in the convert extension is more advanced, supporting extra features
like converting revision IDs in 'extras' (e.g. 'amend_source'), supports
updating hashes in commit messages, and outputs an SHA map file.  Rather than
try to duplicate all of that, just use the existing code.

Even though the convert extension supports user supplied options like filemap,
etc, those features aren't available on the lfconvert interface.  Therefore, it
is safe to use the filemap mechanism (in memory) to handle the standin -> file
rename.  The convert extension handles the destination locking for this path.

There was a comment in test-lfconvert.t about the hash on rev 5 being different
because it was doing a better job than "hg remove" + "hg merge" + "hg commit".
It isn't clear to me what was happening or why, but now the hashes match the
original repo exactly after a roundtrip, which seems like a good idea.  If there
really was something beneficial about the previous behavior, perhaps merge can
be changed so that everyone benefits.

Converting to a largefiles repo still uses the original (limited) lfconvert
logic.
2015-05-28 13:34:37 -04:00
Martin von Zweigbergk
8714aec6c0 largefiles: avoid match.files() in conditions
See 559ee9ecae07 (match: introduce boolean prefix() method,
2014-10-28) for reasons to avoid match.files() in conditions.
2015-05-19 13:08:21 -07:00
Martin von Zweigbergk
94f4135a12 largefiles: pass in whole matcher to getstandinmatcher()
The choice between the "always" case and the other case is done in
getstandinmatcher() and the next patch will change how it's determined
based on the matcher, so let's prepare by passing in the matcher, not
just the matcher's files.
2015-05-26 11:06:43 -07:00
Martin von Zweigbergk
c576c59596 largefiles: drop unused 'pats' parameter from getstandinmatcher()
The parameter wasn't used even when it was imported from elsewhere in
7e9e4773f809 (hgext: add largefiles extension, 2011-09-24).
2015-05-26 09:46:48 -07:00
Drew Gottlieb
04e229c0e2 match: rename _fmap to _fileroots for clarity
fmap isn't a very descriptive name for the set of the match's files.
2015-05-08 12:30:51 -07:00
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Matt Mackall
8e5f3996ed largefiles: use try/except/finally 2015-05-15 09:55:15 -05:00
Matt Harbison
45986628ce largefiles: drop os.path.join() in subrepo archive override
This is related to df069d92be27, but not required for that to function correctly
because 'prefix' always ends with '/', so os.path.join(prefix, _path) simply
concatenates the strings.  Take the opportunity to drop the os.path usage, and
avoid confusion by using the same pattern as the overridden subrepo method.
2015-05-04 23:04:12 -04:00
Matt Harbison
4ce249627a largefiles: don't mangle filesets when fixing up the log matcher
The fileset-generated.t test previously failed with this:

  +  hg: parse error: unknown identifier: .hglf/modified
  +  (did you mean 'modified'?)
  +  [255]

Filesets will find the standins on their own, without any help.  While that's
useful for some things like modified(), clean(), etc., it is wrong for things
like size().  Proper fileset support for largefiles is not trivial, but this was
failing with just the extension enabled on a normal repo.
2015-04-18 13:08:41 -04:00
Matt Harbison
72ef386079 largefiles: don't crash when cloning to a remote repo
The immediate crash was when checking for requirements immediately after this,
but lfcommands.downloadlfiles() will also crash if --all-largefiles is
specified.  That has been in place since atleast e01343f7da6f (2.3-rc) without
anyone noticing.

I can't tell from the peer classes if there's a way to make the custom largefile
functionality work in this case, but atleast it doesn't crash.
2015-04-18 00:34:38 -04:00
Mads Kiilerich
4e94ae8e25 largefiles: always consider updatelfiles 'checked' parameter set
mergeupdate already set the flag to update all. This will thus only change
overriderevert and scmutilmarktouched ... where the flag effectually also were
true. The test coverage thus shows no change.

As the flag always is set, it is removed.

This is mainly a change for keeping the code simple and consistent and correct,
but it should also make it faster in many cases.
2015-01-17 03:34:57 +01:00
Mads Kiilerich
45a6e1e82f largefiles: for update -C, only update largefiles when necessary
Before, a --clean update with largefiles would use the "optimization" that it
didn't read hashes from standin files before and after the update. Instead of
trusting the content of the standin files, it would rehash all the actual
largefiles that lfdirstate reported clean and update the standins that didn't
have the expected content. It could thus in some "impossible" situations
automatically recover from some "largefile got out sync with its standin"
issues (even there apparently still were weird corner cases where it could
fail). This extra checking is similar to what core --clean intentionally do
not do, and it made update --clean unbearable slow.

Usually in core Mercurial, --clean will rely on the dirstate to find the files
it should update. (It is thus intentionally possible (when trying to trick the
system or if there should be bugs) to end up in situations where --clean not
will restore the working directory content correctly.) Checking every file when
we "know" it is ok is however not an option - that would be too slow.

Instead, trust the content of the standin files. Use the same logic for --clean
as for linear updates and trust the dirstate and that our "logic" will keep
them in sync. It is much cheaper to just rehash the largefiles reported dirty
by a status walk and read all standins than to hash largefiles.

Most of the changes are just a change of indentation now when the different
kinds of updates no longer are handled that differently. Standins for added
files are however only written when doing a normal update, while deleted and
removed files only will be updated for --clean updates.
2015-04-15 15:22:16 -04:00
Durham Goode
610230ad03 copies: add matcher parameter to copy logic
This allows passing a matcher down the pathcopies() stack to _forwardcopies().
This will let us add logic in a later patch to avoid tracing copies when not
necessary (like when doing hg diff -r 1 -r 2 foo.txt).
2015-04-16 11:29:30 -07:00
Yuya Nishihara
1209d3b6f0 largefiles: use common function to build content of .hg_archival.txt
This fixes the missing "changessincelatesttag" field introduced by
7203a55cb648.
2015-04-08 22:42:37 +09:00
Drew Gottlieb
6d2651f8ba treemanifest: optimize treemanifest._walk() to skip directories
This makes treemanifest.walk() not visit submanifests that are known not to
have any matching files. It does this by calling match.visitdir() on
submanifests as it walks.

This change also updates largefiles to be able to work with this new behavior
in treemanifests. It overrides match.visitdir(), the function that dictates
how walk() and matches() skip over directories.

The greatest speed improvements are seen with narrower scopes. For example,
this commit speeds up the following command on the Mozilla repo from 1.14s
to 1.02s:
  hg files -r . dom/apps/

Whereas with a wider scope, dom/, the speed only improves from 1.21s to 1.13s.

As with similar a similar optimization to treemanifest.matches(), this change
will bring out even bigger performance improvements once treemanifests are
loaded lazily. Once that happens, we won't just skip over looking at
submanifests, but we'll skip even loading them.
2015-04-07 15:18:52 -07:00
Matt Harbison
673b9701b1 largefiles: use the share source as the primary local store (issue4471)
The benefit of retargeting the local store to the share source is that all
shares will always have access to the largefiles any one of them commit, even if
the user cache is deleted (which is documented to be OK to do).  Further, any
push into the source (and now any shares), will likewise make the largefile(s)
visible to all related repositories.

In order to maintain compatibility with existing repos, where the largefiles
would be cached only in the local share, fallback to searching the local share
if it isn't found at the share source.

The unshare command should probably be taught to copy the source store into the
store for the repo being unshared to complete the loop.


This patch changes the test like this:

  @@ -159,6 +159,5 @@
     $ hg share -q src share_dst --config extensions.share=
     $ hg -R share_dst update -r0
     getting changed largefiles
  -  large: largefile $HASH not available from file:///$TESTTMP\share_dst
  -  0 largefiles updated, 0 removed
  +  1 largefiles updated, 0 removed
     1 files updated, 0 files merged, 0 files removed, 0 files unresolved


The issue writeup mentions pushing a largefile from a remote repo to the main
local repo, and the largefile is then not available in any shares.  Since the
push doesn't cache the largefile in $USERCACHE, the trashed $USERCACHE in this
test is equivalent.
2015-04-04 19:06:43 -04:00
Matt Harbison
b6603acaf3 largefiles: use lfutil.findstorepath() when verifying a local repo 2015-04-04 19:34:36 -04:00