Commit Graph

684 Commits

Author SHA1 Message Date
Pulkit Goyal
3c7388da12 py3: replace pycompat.getenv with encoding.environ.get
pycompat.getenv returns os.getenvb on py3 which is not available on Windows.
This patch replaces them with encoding.environ.get and checks to ensure no
new instances of os.getenv or os.setenv are introduced.
2017-01-15 13:17:05 +05:30
Pulkit Goyal
770a0e2938 py3: replace os.getenv with pycompat.osgetenv
os.getenv deals with unicodes on Python 3, so we have pycompat.osgetenv to
deal with bytes. This patch replaces occurrences on os.getenv with
pycompat.osgetenv
2016-12-19 02:54:49 +05:30
Pulkit Goyal
1f6538b90b py3: replace os.name with pycompat.osname (part 2 of 2) 2016-12-19 00:28:12 +05:30
Gregory Szorc
2112fb0fd2 wireproto: perform chunking and compression at protocol layer (API)
Currently, the "streamres" response type is populated with a generator
of chunks with compression possibly already applied. This puts the onus
on commands to perform chunking and compression. Architecturally, I
think this is the wrong place to perform this work. I think commands
should say "here is the data" and the protocol layer should take care
of encoding the final bytes to put on the wire.

Additionally, upcoming commits will improve wire protocol support for
compression. Having a central place for performing compression in the
protocol transport layer will be easier than having to deal with
compression at the commands layer.

This commit refactors the "streamres" response type to accept either
a generator or an object with "read." Additionally, the type now
accepts a flag indicating whether the response is a "version 1
compressible" response. This basically identifies all commands
currently performing compression. I could have used a special type
for this, but a flag works just as well. The argument name
foreshadows the introduction of wire protocol changes, hence the "v1."

The code for chunking and compressing has been moved to the output
generation function for each protocol transport. Some code has been
inlined, resulting in the deletion of now unused methods.
2016-11-20 13:50:45 -08:00
Mads Kiilerich
d18a73f120 largefiles: clarify variable name holding file mode
A follow-up to 9ce3ccc6ef9c.

'st' sounds like the whole stat result while 'mode' is a better name for the
actual file mode.
2016-10-18 16:45:39 +02:00
Mads Kiilerich
4409f61ab2 largefiles: handle that a found standin file doesn't exist when removing it
I somehow ended up in a situation where hg crashed on an unlink I introduced in
8fd3fc1ef4c6.

I don't know how it happened and can't reproduce it. It seems like it only can
happen when the file is removed between the time of check in a working
directory context walk that finds a standin file, and the time of use when we
try to remove it because the corresponding largefile doesn't exist.

But better safe than sorry: replace the plain unlink with unlinkpath with
ignoremissing=True. That will also remove remaining empty directories, which
arguably is more correct.
2016-10-27 20:06:33 +02:00
Kevin Bullock
734a4f1625 merge default into stable for 4.0 code freeze 2016-10-18 14:15:15 -05:00
Mads Kiilerich
8f6d6ccc08 largefiles: fix 'deleted' files sometimes persistently appearing with R status
A code snippet that has been around since largefiles was introduced was wrong:
Standins no longer found in lfdirstate has *not* been removed -
they have probably just been deleted ... or not created.

This wrong reporting did that 'up -C' didn't undo the change and didn't sync
the two dirstates.

Instead of reporting such files as removed, propagate the deletion to the
standin file and report the file as deleted.
2016-10-17 17:12:24 +02:00
Mads Kiilerich
231fdaf8a2 largefiles: more safe handling of interruptions while updating modifications
Largefiles are fragile with the design where dirstate and lfdirstate must be
kept in sync.

To be less fragile, mark all clean largefiles as unsure ("normallookup") before
updating standins. After standins have been updated and we know exactly which
largefile standins actually was changed, mark the unchanged largefiles back to
clean ("normal").

This will make the failure mode more safe. If interrupted, the next command
will continue to perform extra hashing of all largefiles. That will do that all
largefiles that are out of sync with their standin will be marked dirty and
they will show up in status and can be cleaned with update --clean.
2016-10-16 02:29:45 +02:00
Mads Kiilerich
39f2a13215 util: increase filechunkiter size to 128k
util.filechunkiter has been using a chunk size of 64k for more than 10 years,
also in years where Moore's law still was a law. It is probably ok to bump it
now and perhaps get a slight win in some cases.

Also, largefiles have been using 128k for a long time. Specifying that size
multiple times (or forgetting to do it) seems a bit stupid. Decreasing it to
64k also seems unfortunate.

Thus, we will set the default chunksize to 128k and use the default everywhere.
2016-10-14 01:53:15 +02:00
Mads Kiilerich
f926541834 largefiles: always use filechunkiter when iterating files
Before, we would sometimes use the default iterator over large files. That
iterator is line based and would add extra buffering and use odd chunk sizes
which could give some overhead.

copyandhash can't just apply a filechunkiter as it sometimes is passed a
genuine generator when downloading remotely.
2016-10-12 12:22:18 +02:00
Mads Kiilerich
7afa73604d largefiles: use context for file closing
Make the code slightly smaller and safer (and more deeply indented).
2016-10-08 00:59:41 +02:00
Mads Kiilerich
73724460ec largefiles: when setting/clearing x bit on largefiles, don't change other bits
It is only the X bit that it matters to copy from the standin to the largefile
in the working directory. While it generally doesn't do any harm to copy the
whole mode, it is also "wrong" to copy more than the X bit we care about. It
can make a difference if someone should try to handle largefiles differently,
such as marking them read-only.

Thus, do similar to what utils.setflags does and set the X bit where there are
R bits and obey umask.
2016-10-08 00:59:40 +02:00
FUJIWARA Katsunori
7a8d36afcf doc: trim newline at the end of exception message 2016-08-01 06:08:25 +09:00
liscju
347bb0767e largefiles: check file in the repo store before checking remotely (issue5257)
Problem was files to check were gathered in the repository where
the verify was launched but verification was done on the remote
store. It was observed when user committed in cloned repository
and ran verify before pushing - committed files were marked
as non existing.

This commit fixes this by checking in the remote store only files
that are not existing in the repository store where verify was launched.

Solution is similiar to 909b9d8f9ae7
2016-06-23 22:37:17 +02:00
liscju
36f41df99d largefiles: remove additional blank lines
It does not conform to the coding style.
2016-06-27 10:33:33 +02:00
liscju
a37f11d3d7 largefiles: fix misleading comments in lfutil instore and storepath
Problem in both cases is cache in largefiles has assigned
meaning - user cache which is additional place to get/put
files. Those two function works on store - the main place
to store largefiles in the repository - .hg/largefiles and
using "cache" to describe it is misleading.
2016-06-24 09:08:16 +02:00
liscju
7e9f22c475 largefiles: remove additional blank line between methods in localstore
According to the coding style it should be a single blank line
between functions.
2016-06-24 11:51:00 +02:00
liscju
1d5b38f7bf largefiles: make storefactory._openstore public
In storefactory opening store is the main functionality,
so it shouldn't be marked as private with underscore.
2016-06-14 11:21:41 +02:00
Matt Mackall
3eee63391d merge with stable 2016-06-14 14:52:58 -05:00
Augie Fackler
ad67b99d20 cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
All versions of Python we support or hope to support make the hash
functions available in the same way under the same name, so we may as
well drop the util forwards.
2016-06-10 00:12:33 -04:00
Henrik Stuart
5de4cefa8f largefiles: fix support for local largefiles while using share extension
Prior to revision 149be6a0072e, largefiles were saved in the local repository,
even if it was using the share extension. After that change, all largefiles are
now stored in the shared repository. However, the backward compatibility for
existing largefiles already placed in the local repository was never tested,
and has been broken since.
2016-06-07 08:32:33 +02:00
liscju
934bafbfb7 largefiles: rename match_ to matchmod import in lfutil 2016-05-20 01:42:04 +02:00
liscju
7467d15811 largefiles: rename match_ to matchmod import in reposetup 2016-05-12 11:49:23 +02:00
liscju
fb39d8bea4 largefiles: rename match_ to matchmod import in overrides 2016-05-12 11:48:39 +02:00
liscju
fb266ed15a largefiles: rename match_ to matchmod import in lfcommands 2016-05-12 11:36:51 +02:00
liscju
4242fcbf91 py3: make largefiles/wirestore.py use absolute_import 2016-05-10 15:20:04 +02:00
liscju
6e333c2c20 py3: make largefiles/uisetup.py use absolute_import 2016-05-10 15:14:41 +02:00
liscju
38919bdfd2 py3: make largefiles/reposetup.py use absolute_import 2016-05-10 15:04:22 +02:00
liscju
616103a23f py3: make largefiles/remotestore.py use absolute_import 2016-05-10 15:00:22 +02:00
liscju
98325536ee py3: make largefiles/proto.py use absolute_import 2016-05-10 14:41:58 +02:00
liscju
e5e8e7152a py3: make largefiles/overrides.py use absolute_import 2016-05-10 14:26:36 +02:00
liscju
3b9e08b77b py3: make largefiles/localstore.py use absolute_import 2016-05-10 14:20:51 +02:00
liscju
835eadbfd6 py3: make largefiles/lfutil.py use absolute_import 2016-05-10 15:09:22 +02:00
liscju
37b813e4a9 py3: make largefiles/lfcommands.py use absolute_import 2016-05-07 15:44:46 +02:00
liscju
d3eea62c87 py3: make largefiles/basestore.py use absolute_import 2016-05-06 14:30:23 +02:00
liscju
41cd14dafa py3: make largefiles/__init__.py use absolute_import 2016-05-06 14:28:32 +02:00
liscju
d655e60e3c largefiles: move basestore._openstore into new module to remove cycle 2016-06-04 16:53:44 +02:00
liscju
a5a56dc8d5 largefiles: send statlfile remote calls only for nonexisting locally files
Files that are already in local store should be checked locally. The problem
with this implementation is how difference in messages between local and remote
checks should look like. For now local errors for file missing and content
corrupted looks like this:

'changeset cset: filename references missing storepath\n'
'changeset cset: filename references corrupted storepath\n'

for remote it looks like:

'changeset cset: filename missing\n'
'changeset cset: filename: contents differ\n'

Contents differ error for remote calls is never raised currently - for now
statlfile implementation lacks checking file content.
2016-05-09 10:05:32 +02:00
liscju
45a5b8ca24 largefiles: makes verify batching stat calls to remote
Instead of sending stat calls for each files separately, it sends
one batch call with stat invocations for all files.
2016-05-03 23:48:31 +02:00
liscju
31a5cfa252 largefiles: change basestore._verifyfile to take list of files to check
Makes it easier to use batch stat calls in remotestore to decrease
number of round trips.
2016-05-03 23:31:32 +02:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
timeless
109fcbc79e pycompat: switch to util.urlreq/util.urlerr for py3 compat 2016-04-06 23:22:12 +00:00
Mads Kiilerich
069bac6a3e largefiles: introduce push --lfrev to control which revisions are pushed
The default of pushing all largefiles referenced in outgoing revisions is safe,
but also expensive and sometimes not what is needed. We thus introduce a
--lfrev option, similar to what pull already has.

By specifying an empty set of revisions (or null), it is possible to get lazy
(and insecure!) pushes of revisions without referenced largefiles, similar to
how pull works.
2016-03-27 13:00:28 -07:00
Mads Kiilerich
66a29f6996 largefiles: don't access repo.changelog directly in getlfilestoupload
Make it possible to pass both nodes and revisions to getlfilestoupload.
2016-04-13 01:45:45 +02:00
Mads Kiilerich
940d175900 localrepo: refactor prepushoutgoinghook to take a pushop
prepushoutgoinghook was introduced in 8dfcd476a7f7 and largefiles is the only
in-tree use of it. Refactor it to be more useful for other use cases in
largefiles.
2016-04-13 01:09:11 +02:00
timeless
897045e273 largefiles: use double quotes for arguments
You can't use single quotes in cmd.exe. See f4369d3e818c.
2016-01-12 09:30:39 +00:00
liscju
bb92aaa17c largefiles: replace invocation of os.path module by vfs in reposetup.py
This commit is part of bigger effort described in 'Windows UTF-8' plan.
2016-03-19 15:31:13 +01:00
liscju
7b0ac0d003 largefiles: replace invocation of os.path module by vfs in overrides.py
This commit is part of bigger effort described in 'Windows UTF-8' plan.
It is not changing all invocations but the ones where change is
obviously correct and doesn't require complicated changes.
2016-03-19 14:50:40 +01:00
Mads Kiilerich
6d22385d0b largefiles: add some docstrings 2016-03-19 08:28:24 -07:00