Commit Graph

388 Commits

Author SHA1 Message Date
Durham Goode
d7722fcc7c stores: reverse order of cache and local stores
In the old days we would check the cache first, then the local store. This was
important because the cache is more likely to contain correct data (since it
comes from the final pushed version of commits), versus local data which may
contain information about stripped commits.

As part of the big store refactor, this order got switched unintentionally. So
let's switch it back.
2016-06-16 10:22:31 -07:00
Jeroen Vaelen
07efaadb9d [remotefilelog] use hashlib to compute sha1 hashes
Summary:
hg-crew's c27dc3c3122 and c27dc3c3122^ were breaking our extensions:

```
$ hg log -r c27dc3c3122^
changeset:   9010734b79911d2d2e7405d91a4df479b35b3841
user:        Augie Fackler <raf@durin42.com>
date:        Thu, 09 Jun 2016 21:12:33 -0700
s.ummary:     cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
```

```
$ hg log -r c27dc3c3122
changeset:   0d55a7b8d07bf948c935822e6eea85b044383f00
user:        Augie Fackler <raf@durin42.com>
date:        Thu, 09 Jun 2016 21:13:23 -0700
s.ummary:     util: drop local aliases for md5, sha1, sha256, and sha512
```

I did a grep over facebook-hg-rpms to see what was affected:
```
$ grep "util\.\(md5\|sha1\|sha256\|sha512\)" -r ~/facebook-hg-rpms
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/basestore.py:            sha = util.sha1(filename).digest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/basestore.py:                sha = util.sha1(filename).digest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/shallowutil.py:    pathhash = util.sha1(file).hexdigest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/shallowutil.py:    pathhash = util.sha1(file).hexdigest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/debugcommands.py:    filekey = util.sha1(file).hexdigest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/historypack.py:        namehash = util.sha1(name).digest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/historypack.py:        node = util.sha1(filename).digest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/historypack.py:        files = ((util.sha1(filename).digest(), offset, size)
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/fileserverclient.py:    pathhash = util.sha1(file).hexdigest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/fileserverclient.py:    pathhash = util.sha1(file).hexdigest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/remotefilelog/basepack.py:        self.sha = util.sha1()
/home/jeroenv/facebook-hg-rpms/remotefilelog/tests/test-datapack.py:        return util.sha1(content).digest()
/home/jeroenv/facebook-hg-rpms/remotefilelog/tests/test-histpack.py:        return util.sha1(content).digest()
Binary file /home/jeroenv/facebook-hg-rpms/hg-crew/.hg/store/data/mercurial/revlog.py.i matches
/home/jeroenv/facebook-hg-rpms/fb-hgext/sparse.py:            return util.sha1(fh.read()).hexdigest()
/home/jeroenv/facebook-hg-rpms/fb-hgext/sparse.py:        sha1 = util.sha1()
/home/jeroenv/facebook-hg-rpms/fb-hgext/sparse.py:        sha1 = util.sha1()
/home/jeroenv/facebook-hg-rpms/fb-hgext/sparse.py:        sha1 = util.sha1()
/home/jeroenv/facebook-hg-rpms/fb-hgext/sparse.py:    sha1 = util.sha1()
/home/jeroenv/facebook-hg-rpms/mutable-history/hgext/simple4server.py:        sha = util.sha1()
/home/jeroenv/facebook-hg-rpms/mutable-history/hgext/evolve.py:        sha = util.sha1()
```
This diff is part of the fix.

Test Plan:
Ran the tests.
```
$MERCURIALRUNTEST -S -j 48 --with-hg ~/local/facebook-hg-rpms/hg-crew/hg
```

Reviewers: #sourcecontrol, ttung

Differential Revision: https://phabricator.intern.facebook.com/D3440041

Tasks: 11762191
2016-06-15 15:48:16 -07:00
Durham Goode
d860baf210 cachegroup: fix pack path use of cachegroup
Summary:
The pack path logic did not use the correct unix group when
remotefilelog.cachegroup was specified. This fixes that.

Test Plan:
I manually tested it by deleting a pack dir and running repack. This
is hard to create an automated test for since the feature isn't really cross
platform, and we don't have a way to know what groups they have on their
machine.

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3400756

Tasks: 11584114

Signature: t1:3400756:1465342537:ed023f6dc830117df5e85e294a41486f072714c9
2016-06-08 09:09:06 -07:00
Durham Goode
c2d89eeebc test: add test to cover copyfrom issue
The previous commit fixed a bug where copyfrom data was represented incorrectly
in the local .hg/store/data remotefilelog blobs when the ancestor data was read
from a pack file. This commit adds a test for that situation.
2016-06-06 15:07:27 -07:00
Durham Goode
7cb6908a76 copyfrom: fix copy metadata in local blobs
The new pack stores return None for the copyfrom field, instead of the expected
''. We need the local file blob generator to handle this case, instead of just
putting None in the copyfrom field.
2016-06-06 14:16:06 -07:00
Durham Goode
3d127ad4a3 repack: cleanup empty directories
Summary:
Now that repack can clean up old remotefilelog blobs, let's have it also delete
any empty directories that get left behind.

Test Plan: Updated an existing test to cover it

Reviewers: mitrandir, lcharignon, #sourcecontrol, ttung, simonfar

Reviewed By: simonfar

Subscribers: simonfar

Differential Revision: https://phabricator.intern.facebook.com/D3385546

Signature: t1:3385546:1464972782:5ca63cf0a5589bb8a537957f50b4bc5ec4e0f0f5
2016-06-06 10:04:18 -07:00
Durham Goode
cfba85e8f3 Fix missing test glob 2016-06-03 17:32:39 -07:00
Durham Goode
6f3d6c53f5 utils: unify cachepath access through a util function
Summary:
Previously a bunch of different places accessed the cachepath through ui.config
directly. This is a problem because we need to resolve any environment variables
in the path, and some spots didn't do this. So let's unify all accesses through
a helper function that takes care of the environment variables.

Test Plan: Added a test

Reviewers: mitrandir, lcharignon, #sourcecontrol, ttung, simonfar

Reviewed By: simonfar

Subscribers: simonfar

Differential Revision: https://phabricator.intern.facebook.com/D3385583

Signature: t1:3385583:1464971813:5b9ee5ed3d6ff9f1a78cb9e0269e433844758c9d
2016-06-03 09:45:58 -07:00
Durham Goode
01595d2684 repack: allow background repacks to repack non-pack stores
Previously, background repacks would only repack pack files, which meant there
was no automated way to repack loose remotefilelog files without manually
running 'hg repack'. This allows incremental repacks to also pack the loose
files.

It also changes the config knob for background repacks, so we can enable pack
file usage without the server having to support it just yet.
2016-06-01 10:06:35 -07:00
Durham Goode
8b6c78b675 unionstore: allow incomplete delta chains
A previous patch allowed the unionmetadatastore to return partial histories if a
certain config provided. This allowed repack to get partial history information.
This patch does the same for deltachains. This isn't currently used, but will be
used in the future to allow repacking packs with partial delta chains by just
lifting them out of one pack and putting them directly in another.
2016-05-26 02:15:46 -07:00
Durham Goode
2450b3f243 unionstore: allow partial history output from union stores
Previousy, a union store required that it be able to compute the entire history
of the revision. This caused problems in repack, since it may only have a
partial history. Instead of throwing a KeyError and giving the repack algorithm
no history information at all, we add a config knob to let the repack logic
specify that it's ok with partial histories.

The next patch will do the same for contentstore.
2016-05-26 02:13:53 -07:00
Durham Goode
a2646d8da9 packs: change LookupError to KeyError
We've unified on KeyError being the error thrown when the pack is missing the
desired filename+filehash, but there were a few old places still using
LookupError. This patch changes them to also be KeyError.

This fixes an issue where a repack could throw a LookupError when it only had a
partial history of a file. Now that we throw a KeyError, the exception is caught
and handled appropriately.
2016-05-26 02:07:11 -07:00
Durham Goode
304c6f5bd0 pack: move common pack logic into basepack
Summary:
This moves the common logic from datapack and historypack into a common
basepack. At the moment the only common logic is the constructor, which handles
version checking, fanout initialization, and mmap stuff.

Test Plan: Ran the tests

Reviewers: mitrandir, #mercurial, ttung, mjpieters

Reviewed By: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3306558

Signature: t1:3306558:1463474571:35d3d2e71849b8111e5455da2dd4810725a35523
2016-05-24 02:15:58 -07:00
Durham Goode
bb3a62a266 pack: move common pack store logic to basepackstore
Summary:
This takes the duplicate logic from datapackstore and historypackstore and moves
it into a common subclass.

Test Plan: Ran the tests

Reviewers: ttung, mitrandir, #mercurial, mjpieters

Reviewed By: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3306551

Signature: t1:3306551:1463474958:ddd36a43c2a3cbb34254c2b0153c0f3c5d431edb
2016-05-24 02:15:58 -07:00
Durham Goode
5343c35df7 pack: make mutablebasepack the base for mutablehistorypack
Summary:
Now that we have a mutablebasepack base class, we can get rid of all the
redundant logic in mutablehistorypack. This also has the side effect and making
the historypack's fanout table dynamically size, just like the datapack already
does. That required a few changes to the historypack reader class as well.

Test Plan: Ran the tests

Reviewers: mitrandir, #mercurial, ttung

Differential Revision: https://phabricator.intern.facebook.com/D3306546
2016-05-24 02:15:58 -07:00
Martin von Zweigbergk
14962d6e74 fileserverclient: make iterbatch() case work with new store
The iterbatch() handling added in f93aa99d4f1e (fileserverclient: use
new iterbatch() method, 2016-03-22) was broken by 31e88bf6faf0 (store:
change fileserviceclient to write via new store, 2016-04-04). Fix it
by copying the pattern introduced elsewhere in that change.
2016-05-18 22:39:20 -07:00
Durham Goode
7cce219abb pack: move common logic out of mutabledatapack into base class
Summary:
mutabledatapack and mutablehistorypack share a lot of common code, especially
around the index and fanout table. Let's move much of the code to a common
mutablebasepack class and out of mutabledatapack. In the next patch I will make
mutablehistorypack a subclass of mutablebasepack and delete all the duplicate
logic.

Test Plan: Ran the tests

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: quark, rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306542

Signature: t1:3306542:1463611860:16bc68416c9bbed87748a50f55a3bac7c618fdf1
2016-05-20 09:31:37 -07:00
Durham Goode
142c8f9f66 packfetch: remove copy metadata from data before sending over the wire
Summary:
In normal Mercurial, the filelog entry's contents contains extra metadata that
stores the copy source. In the new pack format, that information is stored in
the history store, not in the data store. Therefore we need to change the server
side logic that responds to requests for packs to move that information over to
the history side before it sends the data.

Test Plan: Added a test

Reviewers: ttung, mitrandir, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306539

Signature: t1:3306539:1463609462:0c1e33e0892f96effcc96c8f78401cf0d8ab5cbd
2016-05-20 09:31:34 -07:00
Durham Goode
b6871085ab repack: add incremental repacking for history packs
Summary:
Previously we only had incremental repacking for data packs. This patch adds it
for history packs as well. The algorithm here is simpler, since the amount of
history data is generally much smaller than the amount of delta data.

The algorithm is basically: if there are 2 things bigger than 100MB, repack
them; else repack up to 100MB of smaller things.

The datapack hashes changed because having the history available during a repack
allows us to make different decisions about delta ordering, etc.

Test Plan: Updated the tsets

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306535

Signature: t1:3306535:1463696613:f40ed10c9dfed40d7bc455582592a7aed108ec3a
2016-05-20 09:31:31 -07:00
Durham Goode
93fbca3e39 repack: add automatic incremental background repacking after pull
Summary:
This runs the incremental background repacking logic after hg pull.

As part of adding tests, I also added a 'hg debugwaitonrepack' function that
will wait until any pending repack is done before returning, so the tests can
wait on repacks without so many sleeps.

Test Plan: Adds a test

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306526

Signature: t1:3306526:1463696933:9e27daf0c08076468e8f365a3c372fa7d4f56bde
2016-05-20 09:31:28 -07:00
Durham Goode
7227563c61 repack: add incremental repack
Summary:
This adds a --incremental flag to the hg repack command. This flag causes repack
to look at the distribution of pack files in the repo and performs the most
minimal repack to keep the repo in good shape. Currently it's only implemented
for datapacks.

The new remotefilelog.datagenerations config contains a list of the sizes for
the different generations of pack files. For instance:

  [remotefilelog]
  datagenerations=1GB
    100MB
    1MB

Designates 4 generations - packs over 1GB, packs over 100MB, packs over 1MB, and
implicitly packs undex 1MB. The incremental algorithm will try to keep each
generation to less than 3 pack files (prioritizing the larger generations
first). When performing a repack it will grab at least 2 packs, and will grab
more if the total pack size is less than 100MB (since repacking at that level is
pretty cheap).

I have no idea if this is a good algorithm. We'll how to see and iterate.

Test Plan: Adds a test

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306523

Signature: t1:3306523:1463697129:c87f4a397ef357b5ca4a80d01e9a6ca4d61f9d3d
2016-05-20 09:31:25 -07:00
Durham Goode
a36b9bd403 repack: move repack logic to static functions
Summary:
A future patch will be adding incremental repack, so let's move our repack logic
to the repack module so it's easier to refactor and extend.

Also adds a message for when a background repack kicks off (since we'll be
calling that from other places eventually).

Test Plan: Adds a test

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306521

Signature: t1:3306521:1463602886:cece3d517f0672b829702866482c902812f9ae27
2016-05-20 09:31:22 -07:00
Durham Goode
39fb6f6f14 packs: prevent creation of empty packs
Summary:
Previously creating a mutable pack then not adding anything to it, would result
in a 1 byte pack file. This patch fixes it so it doesn't produce any pack file.
A future patch found this bug and includes a test that executes this code path.

Test Plan: Future patch adds a test

Reviewers: mitrandir, #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3306520

Signature: t1:3306520:1463602354:f47e9478ea686b0b86525b5979dec9ce56301b2a
2016-05-20 09:31:19 -07:00
Durham Goode
02c488a9f6 util: close temporary file descriptor
When we moved away from the core mercurial atomic temp logic, we forgot to close
the file descriptor that was opened by mkstemp.
2016-05-20 08:41:04 -07:00
Olivier Trempe
9f5acf47bd windows: chmod file to be writable before deleting
On windows, you cannot delete a file if it is readonly. Since remotefilelog
makes heavy use of readonly files, we need to chmod them to be writable before
deleting them.

We only do this on windows, since on unix based systems if the current user is
not the owner of the file (and is just accessing the file via a shared group),
they cannot chmod the file.

Renames some variables to disambiguate the stat module as well.
2016-05-20 08:37:49 -07:00
Olivier Trempe
66b95b7f12 windows: PWD environment variable not available
The PWD environment variable isn't available on windows, so let's just not
bother checking the current directory for repos in that case.
2016-05-20 08:33:34 -07:00
Olivier Trempe
bf52350bbe windows: os.getuid not supported
Windows does not support os.getuid, so avoid using it.
2016-05-20 08:08:57 -07:00
Olivier Trempe
abf6481106 windows: grp module not supported
On windows the grp module is not present, so we need to avoid importing it. This
means the shared group feature of remotefilelog is not supported on windows.
2016-05-20 08:08:57 -07:00
Olivier Trempe
a1a32e5f37 windows: use binary mode for reading and writing files
On windows, there is text mode and binary mode for reading and writing files.
Since we're dealing with files as just blob data, we always want binary mode.
2016-05-20 08:08:57 -07:00
Martin von Zweigbergk
41226c0217 debugindex: use normal handling for --dir
'debugindex --dir' is used for looking up the revlog of a directory
manifest, so it should use the normal (local file system) handling,
not remotefilelog.
2016-01-04 21:32:21 -08:00
Durham Goode
a4c87d13eb test: fix bad test output
There are two tests around shallow-to-shallow pulls. One for local pulls and one
for ssh pulls.  The local pulls correct showed that two base revs should be
fetched (one for the base of the x changes, and one for the base of the y
changes). The ssh pull test incorrectly marked this as 4 and it was failing for
me.

This implies that at some point it was actually fetching 4 items, but given that
the master repo only has two commits, and that they only touch files x and y,
I'm not sure how 4 is possible, so changing it to two seems to be strictly
better.
2016-05-18 07:30:03 -07:00
Durham Goode
65a4e0eab6 test: add sort to all find commands
Summary:
Turns out the find output is not deterministic, so it was producing different
results in some environments. Let's throw in a sort call for all find output.

Test Plan: Ran the tests

Reviewers: mitrandir, #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D3306533
2016-05-18 07:22:10 -07:00
Durham Goode
56411349f7 datapack: make fanout size dynamic
Summary:
Previously all fanout tables were 2^16 in length. For small packs, this resulted
in very sparse fanout tables that had to be linearly scanned to find the end of
the search bounds, which was slow.

With this patch, the data index now dynamically chooses what fanout table size
to use.  If the pack has over 2^16 / 10 entries, we use 2^16, otherwise we use
2^8. The reasoning is in the code.

The patch is a bit large because we had to take a bunch of constants and
duplicate them, and change their accessors to access them through member
variables.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3279000

Signature: t1:3279000:1463170357:9746d19dde14743bac9a8c40cafbc618504c420f
2016-05-16 10:59:09 -07:00
Durham Goode
c9621d3d1a repack: don't require complete history during data repack
Summary:
Previously, when repacking deltas we would require a full history of the node so
we could order the hashes optimally. In some situations though, we don't have
the full history available (like if we're only repacking a subset of packs), so
we need to be able to repack even without full history.

This patch handles the case where a given delta doesn't have history
information. We just store it as a full text.

This becomes useful in an upcoming series that will introduce incremental
packing that only packs a subset of the packs.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3278346

Signature: t1:3278346:1463086170:54c0fbefe78f9cafa7efc4b6f037887a924ab4a5
2016-05-16 10:59:09 -07:00
Durham Goode
9c3aa14c26 repack: remove copyfrom detection
Summary:
In an old version of the code, we would walk the entire history of a node during
data repack, which meant we had to keep track of when we saw a rename, and stop
walking there. Since then, we've changed the code to no longer walk the entire
history, and instead walk just the parts it was told to repack for this
particular file. This means we no longer ever walk across a copy, and therefore
don't need this copy detection logic.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3278443

Signature: t1:3278443:1463086137:c6d9eb6637bf3b8636a3df7e531f265d51cab0de
2016-05-16 10:59:09 -07:00
Durham Goode
12ec6ebcb4 store: force remote stores to always check the shared cache
Summary:
In a remotecontent/metadatastore a `get` request first runs prefetch, then reads
the resulting data from the shared cache store. Before this patch, the prefetch
would not download a value if it existed in the local data store, which means
nothing would be added to the shared cache store, and the `get` would fail. This
patch changes the remote stores to always prefetch based only on the contents of
the shared cache, so data will always be written.

This issue showed up when attempting to repack pack files that contained
references to nodes that were in the local store (which it didn't have access
to) but not the shared cache.

Test Plan:
Manually verified my issue disappeared. This isn't actually an issue
anymore, since future patches refactor the way repack works to not rely on the
remote stores, so this shouldn't be hit again. But it's a safe change
regardless.

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3278362

Signature: t1:3278362:1463086099:987d2fdd1c75e518f815c3159473e8cb22a15ba0
2016-05-16 10:59:09 -07:00
Durham Goode
e13e9ef243 historypack: fix handling of section lookup key errors
Summary:
In the old days _findsection would return None if the section wasn't found. We
have since changed it to throw a KeyError like all the other operations in the
packs. We need to update getmissing to eat that error like usual.

Test Plan: ran the repack that was failing, it succeeded.  Added a unit test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277245

Signature: t1:3277245:1463085831:0b32f852f49bd45ef2dfd3298313b9c2b87f75b6
2016-05-16 10:59:09 -07:00
Durham Goode
a5ed23b7ca fileserverclient: separate data and history in prefetching
Summary:
Previously the fileserverclient logic only checked the data store when
determining whether to prefetch a given key or not. This meant that if the file
was in the data store but not the history store, it could result in a history
lookup failing to prefetch.

The fix is to separate the notions of data and history in the prefetch logic. By
default we just check the data store like before, but an optional argument
allows us to specify checking the history store as well (and we change the
remotemetadatastore to pass that argument).

Test Plan:
Ran the tests. Also ran the repack scenario in my large repo that
reproed the issue. In another diff, I'm going to come back and add a suite of
tests around the various repack permutations that I've seen cause issues.

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277239

Signature: t1:3277239:1463085690:49ad478048cd13836b60f7ac9190e2294f5e9c64
2016-05-16 10:59:09 -07:00
Durham Goode
5bb799ed73 prefetch: add progress to pack prefetch
Summary:
Add a simple progress bar on the client when receiving a pack from the
server.

Test Plan: Ran it

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277265

Signature: t1:3277265:1463085643:aa0960092958c4f56a6d1c3a3901348dba48aa91
2016-05-16 10:59:09 -07:00
Durham Goode
5e4370b46d packs: add debug commands to view pack contents
Summary: Some simple debug commands to print the contents of each pack.

Test Plan: Ran it manually, and added a simple test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277233

Signature: t1:3277233:1463085196:c54fc875d536a96150bb1461b77247a5d7a9402c
2016-05-16 10:59:09 -07:00
Durham Goode
ad5352432e packs: change iterkeys() to __iter__
Summary:
In a future patch we'll add debug commmands to view the contents of packs. Let's
repurpose iterkeys to just be __iter__ and have it return most of the data about
each entry.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir, quark

Differential Revision: https://phabricator.intern.facebook.com/D3277225

Signature: t1:3277225:1463170015:c1acbc7f435f1cf8d07fea4f32bf742a22de5716
2016-05-16 10:59:09 -07:00
Durham Goode
e617c24532 datapack: add index marker for no delta base
Summary:
Previously, we assumed every delta in a pack had a complete chain in that pack,
so the index had no way to indicate a deltabase offset that didn't exist in the
pack.

Let's add a new marker to indicate that the delta base doesn't exist in this
pack.

Test Plan: Tested in my large repo repack scenario.  Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277222

Signature: t1:3277222:1463084346:1687cfa174e98c2cf3022de9e9c3808881f689cd
2016-05-16 10:59:09 -07:00
Durham Goode
05ceb8b419 store: basic wire protocol for bundle delivery
Summary:
This adds a new wire protocol command to allow clients to request a set
of file contents and histories from the server and receive them in pack format.
It's pretty simple and always returns all the history for every node requested
(which is a bit overkill), but it's labeled v1 and we can iterate on it.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3277212

Signature: t1:3277212:1463421279:459cc84265502175b47df293647aab7e7a830185
2016-05-16 10:59:09 -07:00
Durham Goode
2a938a761c store: add copyfrom information to history index
Summary:
Previously we were throwing away copy information when we repacked things into
pack files. The hope was that we could store copy information somewhere else,
and keep the history pack using fixed length entries. Since storing copy
information elsewhere is a long ways off, let's just go ahead and put copy info
in the pack file.

This makes the entries non-fixed length, which means any iteration over them has
to read the length of each entry. This also affects the historypack filename
hashes since they are content based, so the tests had to change.

This matches the old remotefilelog behavior more closely (which is why no code
had to change outside the pack logic).

Test Plan: Added a test

Reviewers: #mercurial, mitrandir, ttung

Reviewed By: mitrandir

Subscribers: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3262185

Signature: t1:3262185:1462562602:935683692276c7fa569d381b18aa3b18656793b1
2016-05-16 10:59:09 -07:00
Durham Goode
24c9c438d3 history: remove dependency on 80 character pack entry
Summary:
In a future diff we will be changing the format of history pack entries
to have a variable length file path in them. Before doing that, let's remove the
places that depend on each entry being exactly 80 characters.

Test Plan: Ran the tests

Reviewers: #mercurial, mitrandir, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D3262154

Signature: t1:3262154:1462820474:b7f5666001b3b7f8863b4de4826266204f3e87aa
2016-05-16 10:59:09 -07:00
Durham Goode
e4fb7d66bb history: remove getparents and getlinknode apis
Summary:
These APIs weren't actually used, and the questions can be answered via
the existing getancestors() api anyway.

They were originally put in place because they are the type of question that
doesn't require the full ancestor tree, so we could answer them without doing in
traversal. In an upcoming patch we add the concept of copyfrom back into the
historypack, and getparents becomes confusing since it doesn't expose knowledge
of copy information. So I just decided to delete it all until we need it.

In the future we may want a 'gethistoryinfo(filename, node)' api that just
returns (p1, p2, linknode, copyfrom), to fulfill that original need of history
information without a full ancestor traversal.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3261734

Signature: t1:3261734:1462413665:987c4703e53468a75346aa323188107a5c070fde
2016-05-16 10:59:09 -07:00
Durham Goode
e7a294e65f utils: change writefile to use custom atomic temp logic
Summary:
The mercurial atomic temp logic makes some assumptions about modes and copies
the mode bits from the existing file. If the existing file is readonly, that
means the atomic temp fails to open the file for writing after it's initially
created.

Since we only actually need like 4 lines from the atomic temp code, I just
implemented it on our end, with custom logic for mode handling.

Test Plan: Ran the tests

Reviewers: #mercurial, ttung, quark

Reviewed By: quark

Differential Revision: https://phabricator.intern.facebook.com/D3288589

Signature: t1:3288589:1462993609:653a0a63266b9129b0e18807858e5de02310ecf9
2016-05-11 13:33:06 -07:00
Durham Goode
ce493adf83 repack: add --background option
Summary:
This allows triggering a repack that can be run in the background. In the future
we will trigger this automatically under certain circumstances (like too many
pack files).

Test Plan: Added a test

Reviewers: #mercurial, ttung, quark

Reviewed By: quark

Subscribers: quark

Differential Revision: https://phabricator.intern.facebook.com/D3261161

Signature: t1:3261161:1462398568:5ae25f3e5a9acd0f4b34490b34a62be33cc69e3c
2016-05-04 14:53:23 -07:00
Durham Goode
8e290a5d4a repack: add lock to limit it to only one repack
Summary:
This adds a lock that limits us to running only one repack at a time. We also
add a simple prerepack hook to allow the tests to insert a sleep to test this
functionality.

Test Plan: Added a test

Reviewers: #mercurial, ttung, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D3260428

Signature: t1:3260428:1462393311:3e1bf5dd047e7f3521679ca7640b448f5e784913
2016-05-04 14:53:19 -07:00
Durham Goode
c2cdcde2fb store: read recent packs first
Summary:
Since recent packs are likely to contain more recent data, let's put them at the
front of the pack list so they are checked first.

In a future diff I'll come back and refact the common code between datapack and
historypack into one base class.

Test Plan:
Ran the tests. Used the debugger to verify that the sort order was
correct.

Reviewers: #mercurial, ttung, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3259823

Signature: t1:3259823:1462388395:8ee48a7b02c6abc079878e53c5b336675249cb91
2016-05-04 14:53:16 -07:00