Commit Graph

150 Commits

Author SHA1 Message Date
Na'Tosha Bard
d2bd6a2acb largefiles: fix output of hg summary (issue3060) 2012-01-08 12:35:47 +01:00
Na'Tosha Bard
0bd0abc6e9 largefiles: fix confusion upon removal of added largefile (issue3176)
This patch makes "hg remove" work the same way on largefiles as it does on
regular Mercurial files.  If you try to remove an added largefile, the removal
fails and you are instead prompted to use "hg forget" to undo the add.
2012-01-08 11:19:51 +01:00
Michal Sznajder
1dd342b724 largefiles: clarify help when options are ignored until first add is done 2011-12-28 00:01:48 +01:00
Matt Mackall
c0c746bcbd largefiles: copy files in binary mode (issue3164) 2011-12-20 11:43:38 -06:00
Martin Geisler
19be7012dc largefiles: handle merges between normal files and largefiles (issue3084)
The largefiles extension prevents users from adding a normal file
named 'foo' if there is already a largefile with the same name.
However, there was a loop-hole: when merging, it was possible to bring
in a normal file named 'foo' while also having a '.hglf/foo' file.

This patch fixes this by extending the manifest merge to deal with
these kinds of conflicts. If there is a normal file 'foo' in the
working copy, and the other parent brings in a '.hglf/foo' file, then
the user will be prompted to keep the normal file or the largefile.
Likewise for the symmetric case where a normal file is brought in via
the second parent. The prompt looks like this:

  $ hg merge
  foo has been turned into a largefile
  use (l)argefile or keep as (n)ormal file?

After the merge, either the '.hglf/foo' file or the 'foo' file will
have been deleted. This would cause status to return output like:

  $ hg status
  M foo
  R foo

To fix this, the lfiles_repo.status method is changed so that a
removed normal file isn't shown if there is largefile with the same
name, and vice versa for largefiles.
2011-12-09 17:35:00 +01: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
3a9a310829 largefiles: fix 'hg status' abort after merge
If a largefile is introduced on the branch that is merged into the
working copy, then 'hg status' would abort with an error like:

   $ hg status
   abort: .hglf/foo@33fdd332ec: not found in manifest!

The problem was that the largefiles status code only looked in the
first parent for the largefile. Largefiles are now always reported as
modified if they don't exist in the first parent -- this matches the
behavior of localrepo.status for normal files.
2011-12-09 17:34:58 +01:00
Na'Tosha Bard
5fa005e186 largefiles: correctly download new largefiles when merging
There is a bug in the merge process where, if a new largefile is introduced
in a merge and the user does not have that largefile in his repo's local store
nor in his system cache, the working copy will retain the old largefile.  Upon
the commit of the merge, the standin is re-written to contain the hash of the
old largefile, and the lfdirstate retains a "Modified" status for the file.
The end result is that the largefile can show up in the merge commit as
"Modified", but the standin has no diff.  This is wrong in two ways:

  1) Such a "wedged" history with a nonsense change in a commit should not be
      possible
  2) It effectively reverts a largefile to an old version when doing a merge

This is caused by the fact that the updatelfiles() command always checks the
current largefile's hash against the hash stored in the current node's standin.
This is correct behavior in every case except for a merge.  When merging, we
must assume that the standin in the working copy contains the correct hash,
because the original hg.merge() has already updated it for us.

This patch fixes the issue by patching the repo object to carry a "_ismerging"
attribute, that the updatelfiles() command checks for.  When this attribute is
found, it checks against the working copy's standin, rather than the standin
in the current node.
2012-01-11 16:53:51 +01:00
Levi Bard
d1dde129fb largefiles: remove pasted code
Refactor and remove pasted code from lfcommands.py
2012-01-08 17:46:27 +01:00
Levi Bard
cd1e9ae0e5 largefiles: add error checking to tags conversion (issue3092)
Check for errors when parsing .hgtags during lfconvert,
and skip lines that don't parse or refer to invalid changesets.
2012-01-08 17:06:34 +01:00
Levi Bard
11d6177f07 largefiles: don't reference uninitialized variable (issue3092) 2012-01-08 17:03:39 +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
Na'Tosha Bard
05ebae9a13 largefiles: implement addremove (issue3064)
Implementing addremove correctly in largefiles is tricky, becuase the original
addremove function does not call into any of the add or remove function we've
already overridden in the extension.  So the trick is to implement addremove
without duplicating any code.

This patch implements addremove by pulling out the interesting parts of
override_add() and override_remove() into generic utility functions, and
using those to handle the largefiles in addremove.  Then a matcher is
installed that will ignore all largefiles, and the original addremove
function is called to take care of the regular files in addremove.

A small bit of monkey patching is used to make sure that remove_largefiles()
notifies the user when a file is removed by addremove and also makes sure
the removal of largefiles doesn't interfer with the original addremove's
operation of removing the standin.
2012-01-07 12:42:54 +01:00
Levi Bard
68127050e4 largefiles: Fix parser warning: redefinition of unused 'node' from line 14 2012-01-08 11:23:21 +01:00
Martin Geisler
a6341e1149 merge with stable 2012-01-08 14:50:20 +01:00
Na'Tosha Bard
2695ae39d0 largefiles: remove invalid comment (issue3065)
This comment is invalid.  The hg.update() function will abort in the case of
any genuine error, so there is nothing to check.  If we have gotten to this
point in execution, nothing critical has gone wrong, and if any standins
have been updated, we must pull new largefiles.
2012-01-07 23:37:19 +01:00
Dan Villiom Podlaski Christiansen
175ef36b21 largefiles: remove a chunk of commented out code 2012-01-07 15:27:34 +01:00
Kevin Gessner
c57b4c7195 largefiles: display remote errors from putlfile (issue3123) (issue3149) 2012-01-05 07:26:22 -08:00
Matt Mackall
c9f57cde0f merge with stable 2011-12-29 14:45:18 -06:00
Michal Sznajder
09c755f459 largefiles: tiny code clean up
lfutil.islfilesrepo is a preffered way for testing if repo is largefiles enabled
2011-12-27 23:56:20 +01:00
Na'Tosha Bard
60040a8402 largefiles: fix rename (issue3093) 2011-11-30 15:11:00 +01:00
Matt Mackall
6e77a4d58a merge with i18n 2011-11-30 17:16:43 -06:00
Mads Kiilerich
2af29b7753 largefiles: avoid use of uinitialized variable in case of errors 2011-11-25 02:09:48 +01: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
Martin Geisler
ebb23d0eaa largefiles: add comment about non-atomic working directory
When updating the working copy with a normal 'hg update', we also
don't use atomic writes.
2011-11-24 18:11:43 +01:00
FUJIWARA Katsunori
d9039e2664 largefiles: use "ui.configlist()" to get largefiles.patterns configuration
current lfconvert implementation uses combination of "ui.config()" and
"str.split(' ')" to get largefiles.patterns configuration.

but it can not handle multiline configuration in hgrc files correctly.

lfconvert should use "ui.configlist()" instead of it, as same as
override_add does.
2011-11-24 17:54:50 +09:00
Mads Kiilerich
eb44c968ee largefiles: file storage should be relative to repo, not relative to cwd
Revealed by the test in 43cf449a75e4.
2011-11-22 19:52:23 +01:00
Martin Geisler
28455d6a6b largefiles: fix 'hg clone . ../foo' OSError abort
Operating on a non-existant file can cause both IOError and OSError,
depending on the function used: open raises IOError, os.lstat raises
OSError.

The largefiles code called dirstate.normal, which in turn calls
os.lstat, so OSError is the right exception to catch here.
2011-11-22 17:51:43 +01:00
FUJIWARA Katsunori
970e57770c largefiles: treat status of cache missed largefiles as "missing" correctly
"hg status" may treat cache missed largefiles as "removed" incorrectly.

assumptions for problem case:

  - there is no cache for largefile "L"
  - at first, update working directory to the revision in which "L" is
    not yet added,
  - then, update working directory to the revision in which "L" is
    already added

and now, "hg status" treats "L" as "removed".

current implementation does not allocate entry for cache missed
largefile in ".hg/largefiles/dirstate", but files without
".hg/largefiles/dirstate" entry are treated as "removed" by largefiles
extension.

"hg revert" can not recover from this situation, but "rm -rf
.hg/largefiles", because it causes dirstate rebuilding.

this patch invokes normallookup() for cache missed largefiles to
allocate entry in ".hg/largefiles/dirstate", so "hg status" can treat
it as "missing" correctly.
2011-11-11 02:33:01 +09:00
Hao Lian
e92210d64e largefiles: ensure destination directory exists before findfile links to there
When (1) findfile links a largefile from the user cache to the store
and (2) the store directory doesn't exist yet, findfile errors out. A
simple call to util.makedirs fixes it.
2011-11-03 10:59:32 -04:00
Matt Mackall
9580de9b45 util: add a doctest for empty sha() calls 2011-10-31 15:41:39 -05:00
Hao Lian
1705e29378 largefiles: replace tempfile.NamedTemporaryFile with tempfile.mkstemp
This is consistent with the rest of Mercurial's code, mirroring the
try-finally-unlink structure elsewhere. Furthermore, it fixes the case where
largefiles throws an IOError on Windows when the temporary file is opened a
second time by copytocacheabsolute.

This patch creates the temporary file in the repo's largefiles store rather than
/tmp, which might be a different filesystem.
2011-10-20 17:24:59 -04:00
Matt Mackall
2f72e8b497 largefiles: avoid checking requirements on every command
When largefiles is enabled, commands on large repositories which don't
require largefiles could be slowed down substantially. Disable
checking this for every command.
2011-10-29 17:38:13 -05:00
Na'Tosha Bard
0e6729399b largefiles: fix bad bug where transplanting a changeset with a largefile will result in an old largefile being comitted later on 2011-10-28 18:48:24 +02:00
Martin Geisler
af63514154 largefiles: fix uppercase in abort message 2011-10-28 15:00:21 +02:00
Hao Lian
a546b17ca3 largefiles: remove lfutil.createdir, replace calls with util.makedirs 2011-10-25 11:45:28 -04:00
Eli Carter
fbbaf602df largefiles: bugfix for symlink handling with testcase
The code was using the size of a symlink's target, thus wrongly making symlinks
to large files into largefiles themselves.  This can be demonstrated by
deleting the symlink and then doing an 'hg up' or 'hg up -C' to restore the
symlink.
2011-10-26 13:48:33 -05:00
Thomas Arendsen Hein
a8bcd5c9b6 largfiles: drop unused import 2011-10-24 13:58:01 +02:00
Martin Geisler
2ad46f5487 largefiles: improve markup in module help text 2011-10-24 10:08:58 +02:00
Martin Geisler
9fd08bafd7 largefiles: remove redundant documentation
The extension help text already covered what was in usage.txt and
design.txt is now moved to the wiki:

  http://mercurial.selenic.com/wiki/LargefilesExtension
2011-10-24 09:54:02 +02:00
Greg Ward
1ef2baf38c largefiles: use ui.configpath() where appropriate 2011-10-23 14:25:48 -04:00
Greg Ward
220535eb62 largefiles: drop more unnecessary compatibility checks 2011-10-23 10:23:31 -04:00
Thomas Arendsen Hein
13fb03d281 largefiles: use util.sha1() instead of hashlib.sha1() everywhere 2011-10-23 21:59:15 +02:00
Greg Ward
04bcf1ecd1 largefiles: rearrange how lfconvert detects non-local repos
Mainly this is so we can test that code; it has the side benefit of not
requiring network I/O to reject non-local repo URLs.
2011-10-22 14:20:17 -04:00
Greg Ward
8c2e55bcd4 largefiles: test lfconvert error handling; remove redundant code 2011-10-22 14:17:19 -04:00
Matt Mackall
be346e0be1 largefiles: py2.4 doesn't have BaseException
..and it's the wrong base class anyway.
2011-10-21 16:52:16 -05:00
Greg Ward
a3607c833a largefiles: rename lfconvert --tonormal option to --to-normal 2011-10-20 21:56:30 -04:00
Benjamin Pollack
2e57592170 largefiles: remove all uses of os.path.relpath for 2.4 compatibility 2011-10-20 17:40:25 -04:00
Benjamin Pollack
8d2d1f2b4b largefiles: use XDG and OS X-specific cache locations by default (issue3067) 2011-10-20 17:05:13 -04:00
Benjamin Pollack
164bde4288 largefiles: remove redundant any_ function 2011-10-19 20:40:55 -04:00
Benjamin Pollack
ec794ad869 largefiles: make the store primary, and the user cache secondary
This uses the now-properly-named functions and methods from the previous
patch to actually deliver the desired behavior
2011-10-20 13:24:11 -04:00
Benjamin Pollack
417391117f largefiles: rename functions and methods to match desired behavior
The original intent was that the largefiles would primarily be in the
repository, with the global cache being only that--a cache.  The naming
conventions and actual intent have both strayed.  In this first patch, the
naming conventions are switched to match the actual intent, as are the
configuration options.
2011-10-20 13:24:09 -04:00
Benjamin Pollack
8e3ea85821 largefiles: fix documentation to match desired behavior 2011-10-20 13:24:08 -04:00
Eli Carter
5a07405554 largefiles: fix newline for lfconverted repos 2011-10-18 17:28:26 -05:00
Eli Carter
d76a96462f largefiles: remove 1.9 compat code 2011-10-19 15:37:03 -05:00
Greg Ward
6e7f580a2b largefiles: fix some badly named function parameters
overrides.py contains several functions that temporarily override
scmutil.match(), which always takes a changectx object as the first
parameter. But these overrides name that parameter either 'repo' or
'ctxorrepo', which is misleading. So rename them to 'ctx' and remove
the special type-sensitive handling of the one called 'ctxorrepo'.
2011-10-16 10:24:45 -04:00
Greg Ward
522fc48c21 largefiles: tidy imports
- no need to defensively import scmutil
- remove duplicate
- unwrap non-long line
2011-10-16 10:29:51 -04:00
Greg Ward
31a67df419 largefiles: rename config setting 'size' to 'minsize' 2011-10-18 20:06:23 -04:00
Eli Carter
2df068a441 largefiles: include 'largefiles' in converted repository requirements 2011-10-18 16:40:59 -05:00
Hao Lian
e500c9817f largefiles: string formatting typo in basestore._openstore where comma is used instead of modulo 2011-10-18 17:09:03 -04:00
Eli Carter
728847b43f largefiles: fix typo 2011-10-18 09:59:04 -05:00
Wagner Bruna
2177ac62f8 largefiles: fix typo 2011-10-17 19:10:28 -02:00
Wagner Bruna
663e6b1cd3 largefiles: make parameter more i18n-friendly 2011-10-17 19:10:42 -02:00
Matt Mackall
8268e6a737 largefiles: remove fixme from docs 2011-10-17 14:14:28 -05:00
Thomas Arendsen Hein
a33744a24e largefiles: use separate try/except and try/finally as needed for python2.4
7e9e4773f809 introduced a try/except/finally block, which breaks compatibility
with python2.4
2011-10-16 11:28:03 +02:00
Matt Mackall
228f9f6b08 merge with stable 2011-12-21 14:36:08 -06:00
Matt Mackall
7cf4e6eacb merge with stable 2011-12-16 19:05:59 -06:00
Matt Mackall
ee2f119c93 merge with stable 2011-12-15 16:50:21 -06:00
Na'Tosha Bard
112b1abe18 largefiles: optimize status when files are specified (issue3144)
This fixes a performance issue with 'hg status' when files are specified
on the command-line.  Previously, a large amount of largefiles code was
executed, even if files were specified on the command-line and those files
were not largefiles.  This patch fixes the problem by first checking if
non-largefiles were specified on the command-line and, just letting the
normal status function handle the case if they were.

On a brand new machine, the execution time for 'hg status filename' on
a repository with largefiles was:

real    0m0.636s
user    0m0.512s
sys     0m0.120s

versus the following (the same repository, with largefiles disabled):

real    0m0.215s
user    0m0.180s
sys     0m0.032s

After this patch, the performance of 'hg status filename' on the same
repository, with largefiles enabled is:

real    0m0.228s
user    0m0.189s
sys     0m0.036s

This performance boost is also true when patterns (rather than specific
files) are specified on the command-line.

In the case where patterns are specified in addition to a file list, we
just defer to the normal codepath in order to not spend extra time
expanding the patterns to just risk having to expand them again later.
2011-12-15 16:23:26 +01:00
Martin Geisler
f89c093d08 merge with stable 2011-12-09 17:58:12 +01:00
Martin Geisler
1fbdd9520a largefiles: use lfutil functions
Using regular expressions to cut off a (fixed) string prefix is overly
complicated and wasteful.
2011-12-09 17:34:57 +01:00
Martin Geisler
313aade451 largefiles: fix indentation 2011-12-09 17:34:56 +01:00
Martin Geisler
9b8776da45 largefiles: remove pre-1.7 compatibility code
Mercurial 1.7 added the --subrepos flag to status and archive and the
largefiles code was still compatible with the old method signatures.
2011-12-07 16:25:51 +01:00
Na'Tosha Bard
15aa924ecd largefiles: optimize performance of status on largefiles repos (issue3136) 2011-12-07 12:56:44 +01:00
Matt Mackall
9e27ec8fc4 merge with stable 2011-12-01 15:57:10 -06:00
Matt Mackall
3d60dfdd1c merge with stable 2011-11-30 17:15:39 -06:00
Mads Kiilerich
ae8c3f9869 merge with stable 2011-11-25 02:11:12 +01:00
Martin Geisler
b8431ebcdb largefiles: simplify lfutil.writehash
This was unnecessarily verbose: there is no need to unlink the file
when we open it for write anyway, and there is no need to check if the
file exists after we created it.
2011-11-24 18:22:45 +01:00
Greg Ward
9201e11906 largefiles: cosmetics, whitespace, code style
This is mainly about keeping code under the 80-column limit with as
few backslashes as possible. I am deliberately not making any logic or
behaviour changes here and have restrained myself to a few "peephole"
refactorings.
2011-10-13 21:42:54 -04:00
Greg Ward
f01e46c64d largefiles: more work on cleaning up comments
- always say "largefile", not "lfile"
- cleanup mangled syntax, hopefully correctly
  (punctuation: it's your friend!)
- wrap to 75 columns (where feasible)
2011-10-13 20:45:49 -04:00
Greg Ward
8b7a685468 largefiles: improve error reporting
- tweak wording of some error messages
- use consistent capitalization
- always say 'largefile', not 'lfile'
- fix I18N problems
- only raise Abort for errors the user can do something about
2011-10-13 20:24:29 -04:00
Greg Ward
5f73b6d815 largefiles: improve comments, internal docstrings
- fix some ungrammatical/unclear/incorrect comments/docstrings
- rewrite some really unclear comments/docstrings
- make formatting/style more consistent with the rest of Mercurial
  (lowercase without period unless it's really multiple sentences)
- wrap to 75 columns
- always say "largefile(s)", not "lfile(s)" (or "big files")
- one space between sentences, not two
2011-10-12 20:59:27 -04:00
Na'Tosha Bard
6b1f4db174 largefiles: speed up commit by only rewriting standins for modified largefiles 2011-10-13 12:11:25 +02:00
Greg Ward
45dea8085f largefiles: improve help
Extension help taken from the URL formerly in the text
(https://developers.kilnhg.com/Repo/Kiln/largefiles/largefiles/File/usage.txt)
and improved.
2011-10-11 21:10:03 -04:00
Greg Ward
7c5da0f076 largefiles: use ui.configlist() to split largefiles.patterns 2011-10-11 21:11:01 -04:00
Greg Ward
86647ec1cf largefiles: allow minimum size to be a float
Some old-fashioned people (e.g. me) think that incompressible
binary files >100 kB count as "large".
2011-10-11 21:07:08 -04:00
Greg Ward
184d4727fd largefiles: factor out lfutil.getminsize() 2011-10-11 21:11:01 -04:00
Na'Tosha Bard
842085d82b largefiles: cleanup import, now that we can assume > 1.9 for bundled extension 2011-10-11 14:01:24 +02:00
Na'Tosha Bard
a090606e6c largefiles: remove pre-1.9 code from extension first bundled with 1.9 2011-10-11 10:42:56 +02:00
Na'Tosha Bard
bc15926c15 largefiles: fix commit of specified file on non-windows 2011-10-06 11:10:06 +02:00
Greg Ward
067c6211ff largefiles: don't break existing tests (syntax error, bad imports) 2011-10-01 16:39:51 -04:00
Matt Mackall
897fb58472 largefiles: mark a string for translation 2011-09-29 17:16:42 -05:00
Matt Mackall
ec48bece64 largefiles: fix multistatement line 2011-09-29 17:15:54 -05:00
Matt Mackall
54e711350f largefiles: eliminate naked exceptions 2011-09-29 17:14:47 -05:00
Matt Mackall
26db63c0a5 largefiles: fix over-long lines 2011-09-29 17:04:57 -05:00
Matt Mackall
4a1439d51a largefile: fix up hasattr usage 2011-09-29 16:48:48 -05:00
various
88e172f652 hgext: add largefiles extension
This code has a number of contributors and a complicated history prior to its
introduction that can be seen by visiting:

https://developers.kilnhg.com/Repo/Kiln/largefiles/largefiles
http://hg.gerg.ca/hg-bfiles

and looking at the included copyright notices and contributors list.
2011-09-24 17:35:45 +02:00