Commit Graph

80 Commits

Author SHA1 Message Date
Mads Kiilerich
428d9fe9e0 largefiles: fix profile of unused largefilesdirstate._ignore 2013-10-03 18:01:21 +02:00
FUJIWARA Katsunori
a3f2ae29d0 largefiles: centralize the logic to get outgoing largefiles
Before this patch, "overrides.getoutgoinglfiles()" (called by
"overrideoutgoing()" and "overridesummary()") and "lfilesrepo.push()"
implement similar logic to get outgoing largefiles separately.

This patch centralizes the logic to get outgoing largefiles in
"lfutil.getlfilestoupload()".

"lfutil.getlfilestoupload()" takes "addfunc" argument, because each
callers need different information (and it is useful for enhancement
in the future).

  - "overrides.getoutgoinglfiles()" needs only filenames
  - "lfilesrepo.push()" needs only hashes of largefiles
2014-04-16 00:37:24 +09:00
Mads Kiilerich
69da8bff75 largefiles: use repo.wwrite for writing standins (issue3909) 2013-04-27 00:41:42 +02:00
Mads Kiilerich
9c2c68a468 largefiles: don't hash all largefiles when initializing a lfdirstate
The largefiles will be hashed on demand if necessary ... and sometimes it isn't
necessary.
2013-04-15 23:31:56 +02:00
Mads Kiilerich
70924c1c48 largefiles: drop limitreader, use filechunkiter limit
filechunkiter.close was a noop.
2013-04-16 01:55:57 +02:00
Mads Kiilerich
76454d8f22 largefiles: remove blecch from lfutil.copyandhash - don't close the passed fd 2013-04-15 23:43:50 +02:00
Mads Kiilerich
d9e36e98f8 largefiles: drop lfutil.blockstream - use filechunkiter like everybody else
The old chunk size is kept - just to avoid changing it.
2013-04-15 23:43:44 +02:00
Mads Kiilerich
9fb2d6a4da largefiles: refactoring - return hex from _getfile and copyandhash 2013-04-15 23:35:18 +02:00
Mads Kiilerich
092b44d44d largefiles: refactoring - create destination dir in lfutil.link 2013-04-15 23:32:33 +02:00
Mads Kiilerich
fa7d021ee4 largefiles: drop --cache-largefiles again
This goes a step further than 974959d637b7 and backs out the unreleased
--cache-largefiles option. The same can be achieved with --lfrev heads(pulled()) and
we shouldn't introduce unnecessary command line options.
2013-04-15 01:59:11 +02:00
Mads Kiilerich
34d52d8c6e largefiles: getstandinmatcher should not depend on existence of directories
Looking for a (potentially empty) directory was not reliable - both because it
is a reasonable assumption that empty directories can be removed and because it
wasn't created in all cases ... such as when pulling to an existing repository.
2013-02-28 13:45:18 +01:00
Mads Kiilerich
c066baf66c largefiles: fix commit when using relative paths from subdirectory
Remove cwd handling from getstandinmatcher - it did not belong there, as proven
by the tests.
2013-01-25 16:59:34 +01:00
Mads Kiilerich
dfd7d10cbf largefiles: fix update from a merge with removed files
A situation with this case could happen after interrupting an update. Update
would fail with:
  abort: No such file or directory: $TESTTMP/f/.hglf/sub2/large6

Update from a merge without using clean is not possible anyway, so this patch
takes a step in the right direction so it gets as far as reporting the right
error.
2013-01-11 16:30:29 +01:00
Mads Kiilerich
19813fa421 largefiles: fix revert removing a largefile from a merge
Before revert could fail with:
  abort: .hglf/large@33fdd332ec: not found in manifest!

The LookupError will now be caught and handled correctly.
2013-01-11 16:30:29 +01:00
Mads Kiilerich
f356c36feb largefiles: remove trivial portability wrappers 2012-12-13 19:19:06 +01:00
Mads Kiilerich
8c4d272590 largefiles: remove reporemove portability wrapper 2012-12-13 19:19:06 +01:00
Mads Kiilerich
59edc6b723 largefiles: remove findoutgoing portability wrapper 2012-12-13 19:19:06 +01:00
Mads Kiilerich
b9392de5ec largefiles: use constant for '.hglf/'
Problem: '.hglf' + '/' was computed in some tight loops. There is no need for
that.
2012-12-13 19:19:06 +01:00
Mads Kiilerich
6b50b212dd largefiles: use plain wjoin instead of the complex pathto 2012-12-13 19:19:06 +01:00
Mads Kiilerich
38f4eda033 largefiles: simplify lfdirstate ignore handling - it is only for tracking .hglf 2012-12-13 19:19:06 +01:00
Mads Kiilerich
ba25df8826 largefiles: rename 'admin' to more descriptive 'lfstoredir' 2012-12-13 19:19:06 +01:00
Mads Kiilerich
8c0ce2a8b9 largefiles: simplify lfutil.getstandinmatcher by inlining getmatcher 2012-12-13 19:19:06 +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
Matt Harbison
eb56660b19 largefiles: don't copy largefiles from working dir to the store while converting
Previously, if one or more largefiles for a repo being converted were not in the
usercache, the convert would abort with a reference to the largefile being
missing (as opposed to the previous patch, where the standin was referenced as
missing).  This is because commitctx() tries to copy all largefiles to the
local store, first from the user cache, and if the file isn't found there, from
the working directory.  No files will exist in the working directory during a
convert, however.  It is not sufficient to force the source repo to be local
before proceeding, because clone and pull do not download largefiles by default.

This is slightly less than ideal because while the conversion will now complete,
it won't be possible to update to revs with missing largefiles unless the user
intervenes manually, because there is no default path pointing back to the
source repo.  Ideally these files would be cached during the conversion.

This check could have been done in reposetup.commitctx() instead, but this
ensures the local store directory is created, which is necessary to enable the
standin matcher.

The rm -> 'rm -f' change in the test is to temporarily suppress an error
clearing the cache- as noted, the cache is is not repopulated during convert.
When that is fixed, this can be changed back and the verification errors will
disappear too.
2012-10-23 21:32:19 -04:00
Matt Harbison
8973167c73 largefiles: respect the rev when reading standins in copytostore() (issue3630)
When the rev isn't specified, the standin for the working copy gets read.  But
convert doesn't update the working copy for each cset it processes, so there is
no standin and the 'hg convert' would abort complaining about the standin being
missing.

Note that if the largefile is not in the user cache, 'hg convert' complains
about the largefile itself missing from the destination repo.
2012-10-23 21:07:14 -04:00
Matt Harbison
8c0a3d405b largefiles: update lfutil.findoutgoing() discovery method
It looks like this method missed the updates in 7a899bd0f9c0 (which changed the
preferred discovery method from findcommonincoming() to findcommonoutgoing()),
and 8b2938386599 (which rolls up the outgoing lists into a single object).
2012-10-08 22:43:54 -04:00
Matt Mackall
8c86a57e7c merge with stable 2012-09-27 15:51:14 -05:00
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Matt Harbison
fd44bab84b largefiles: enable islfilesrepo() prior to a commit (issue3541)
Previously, even if a file was added with --large, 'hg addremove' or 'hg ci -A'
would add all files (including the previously added large files) as normal
files.  Only after a commit where a file was added with --large would subsequent
adds or 'ci -A' take into account the minsize or the pattern configuration.
This change more closely follows the help for largefiles, which mentions that
'add --large' is required to enable the configuration, but doesn't mention the
previously required commit.

Also, if 'hg add --large' was performed and then 'hg forget <file>' (both before
a largefile enabling commit), the forget command would error out saying
'.hglf/<file> not tracked'.  This is also fixed.

This reports that a repo is largefiles enabled as soon as a file is added with
--large, which enables 'add', 'addremove' and 'ci -A' to honor the config
settings before the first commit.  Note that prior to the next commit, if all
largefiles are forgotten, the repository goes back to reporting the repo as not
largefiles enabled.

It makes no sense to handle this by adding a --large option to 'addremove',
because then it would also be needed for 'commit', but only when '-A' is
specified.  While this gets around the awkwardness of having to add a largefile,
then commit it, and then addremove the other files when importing an existing
codebase (and preserving that extra commit in permanent history), it does still
require finding and manually adding one of the files as --large.  Therefore it
is probably desirable to have a --large option for init as well.
2012-07-30 20:56:41 -04:00
Matt Harbison
1c93565f66 largefiles: fix a traceback introduced with recent peer changes
Changeset 9467184ce7e7 broke 'outgoing --large'

    ...
    File "hgext\largefiles\lfutil.py", line 56, in findoutgoing
      remote.local(), force=force)
    File "mercurial\discovery.py", line 31, in findcommonincoming
      if not remote.capable('getbundle'):
  AttributeError: 'lfilesrepo' object has no attribute 'capable'

This restores the previous functionality, though I'm not sure if there's a
better way to do this- that changeset introduces a hunk in debugdiscovery that
does this:

            if not util.safehasattr(remote, 'branches'):
                # enable in-client legacy support
                remote = localrepo.locallegacypeer(remote.local())

Is there a legacy support issue here too?
2012-07-20 23:50:52 -04:00
Martin Geisler
643b04fbb7 largefiles: lowercase messages 2012-06-12 14:18:18 +02:00
Na'Tosha Bard
65205ee295 largefiles: remove use of underscores that breaks coding convention 2012-03-09 16:11:52 +01:00
Na'Tosha Bard
064a3d8577 largefiles: move calculation of largefiles for updating to utility function 2012-03-09 16:45:49 +01:00
Matt Mackall
ee77ef5137 merge with stable 2012-02-24 16:16:48 -06:00
Martin Geisler
b8759cea3b largefiles: respect store.createmode and avoid extra file copy
Before, a tempfile was used to create a temp file was created with 600
permissions and the uploaded data was written into it. This file was
then *copied* to .hg/largefiles/<hash>.

We now simply use atomictempfile to write the data to a temp file with
the right permissions and then rename that into place.
2012-02-23 13:37:10 +01:00
Martin Geisler
c3f611d55c largefiles: use repo.store.createmode for new files in .hg/largefiles
Before, the mode was copied from the file in the working copy. This is
inconsistent with how Mercurial normally creates files inside the .hg
folder. This can lead to a situation where you can read the files
under .hg/store but not under .hg/largefiles and so a clone will fail
if it needs to access a largefile.
2012-02-23 13:22:55 +01:00
Na'Tosha Bard
8564a2aba3 largefiles: only cache largefiles in new heads
This fixes a serious performance regression in largefiles introduced in
Mercurial 2.1.  Caching new largefiles on pull is necessary, because
otherwise largefiles will be missing (and unable to be downloaded) when
the user tries to merge or rebase a new head with an old one.  But this
is an expensive operation and should only be done for heads that are new
from the pull, rather than on all heads in the repository.
2012-02-10 14:46:09 +01:00
FUJIWARA Katsunori
b1ab26d815 i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
some problematic encodings use backslash as part of multi-byte characters.

util.pconvert() can treat strings in such encodings correctly, if
win32mbcs is enabled, but str.replace() can not.
2012-02-05 22:58:31 +09:00
Na'Tosha Bard
8640514f70 largefiles: optimize update speed by only updating changed largefiles
Historically, during 'hg update', every largefile in the working copy was
hashed (which is a very expensive operation on big files) and any
largefiles that did not have a hash that matched their standin were
updated.

This patch optimizes 'hg update' by keeping track of what standins have
changed between the old and new revisions, and only updating the largefiles
that have changed.  This saves a lot of time by avoiding the unecessary
calculation of a list of sha1 hashes for big files.

With this patch, the time 'hg update' takes to complete is a function of
how many largefiles need to be updated and what their size is.

Performance tests on a repository with about 80 largefiles ranging from
a few MB to about 97 MB are shown below.  The tests show how long it takes
to run 'hg update' with no changes actually being updated.

Mercurial 2.1 release:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
getting changed largefiles
0 largefiles updated, 0 removed

real    0m10.045s
user    0m9.367s
sys    0m0.674s

With this patch:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.965s
user    0m0.845s
sys    0m0.115s

The same repsoitory, without the largefiles extension enabled:

$ time hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

real    0m0.799s
user    0m0.684s
sys    0m0.111s

So before the patch, 'hg update' with no changes was approximately 9.25s
slower with largefiles enabled.  With this patch, it is approximately 0.165s
slower.
2012-02-13 18:37:07 +01:00
Patrick Mezard
b21e9758d9 largefiles: remove unused lfutil.readhash() 2012-01-18 14:33:19 +01:00
Na'Tosha Bard
be9c0ca800 largefiles: refactor lfutil.findfiles to be more logical 2012-01-18 13:41:03 +01:00
Dan Villiom Podlaski Christiansen
b83792b911 largefiles: factor out a copyalltostore() function 2012-01-08 14:33:10 +01:00
Levi Bard
745707ea8a largefiles: fix inappropriate locking (issue3182)
Don't lock/write on operations that should be readonly (status).
Always lock when writing the lfdirstate (rollback).
Don't write lfdirstate until after committing; state isn't actually changed
until the commit is complete.
2012-01-07 19:05:59 +01:00
Na'Tosha Bard
0bbf2e33ad largefiles: correctly handle dirstate status when rebasing
When rebasing, we need to trust that the standins are always correct. The
rebase operation updates the standins according to the changeset it is
rebasing. We need to make the largefiles in the working copy match.  If we
don't make them match, then they get accidentally reverted, either during
the rebase or during the next commit after the rebase.

This worked previously only becuase we were relying on the behavior that
largefiles with a changed standin, but unchanged contents, never showed up in
the list of modified largefiles.  Unfortunately, pre-commit hooks can get
an incorrect status this way, and it also results in extra execution of code.

The solution is to simply trust the standins when we are about to commit a
rebased changeset, and politely ask updatelfiles() to pull the new contents
down.  In this case, updatelfiles() will also mark any files it has pulled
down as dirty in the lfdirstate so that pre-commit hooks will get correct
status output.
2012-01-07 18:43:34 +01:00
Matt Mackall
228f9f6b08 merge with stable 2011-12-21 14:36:08 -06:00
Matt Mackall
c0c746bcbd largefiles: copy files in binary mode (issue3164) 2011-12-20 11:43:38 -06:00
Matt Mackall
ee2f119c93 merge with stable 2011-12-15 16:50:21 -06:00
Kevin Gessner
edef96f084 largefiles: don't require a user cache (issue3088) (issue3155)
If the user cache path isn't specified in .hgrc, and it can't be constructed
from the environment, don't try to use that cache.
2011-12-15 13:19:43 -05:00
Martin Geisler
161f84c84c largefiles: copy files into .hg/largefiles atomically
Copying from the user cache into .hg/largefiles could fail halfway
though with a partially written file.
2011-11-24 18:13:18 +01:00
Martin Geisler
de1d410b06 largefiles: write .hg/largefiles/ files atomically
Before, it was possible to create a

  .hg/largefiles/hash

file with truncated content, i.e., content where

  SHA-1(content) != hash

This breaks the fundamental invariant in largefiles that the file
content for files in .hg/largefiles hash to the filename.
2011-11-24 18:12:13 +01:00