Commit Graph

16 Commits

Author SHA1 Message Date
Durham Goode
6d8f64bc0d treemanifest: change native tree walking to allow depth a parameter
Summary:
We're experiencing cases where users are pulling down far more trees
than they need. Let's enable the ability to download a certain depth of trees.

In this diff we just implement the actual iteration limiting in native code. In
a future diff we'll make the appropriate python changes and add a test.

Reviewed By: quark-zju

Differential Revision: D8523215

fbshipit-source-id: ccfeadee1525b86b1a5578631dbafe666de41f4c
2018-06-27 18:06:13 -07:00
Mark Thomas
af99203255 cstore: add treemanifest.listdir
Summary:
Add a new function to `cstore.treemanifest` to list the contents of a directory
in the tree manifest.

Reviewed By: ryanmce

Differential Revision: D8332425

fbshipit-source-id: db74f11a691cd6b8ac7d51aec6b7da8149c22027
2018-06-12 09:23:44 -07:00
Wez Furlong
31bcfbe58e hg: disable check-code tests for C code
Summary:
They're actively fighting against the clang-format config
and don't have an auto-fix.

Reviewed By: quark-zju

Differential Revision: D8283622

fbshipit-source-id: 2de45f50e6370a5ed14915c6ff23dc843ff14e8a
2018-06-05 19:21:43 -07:00
Durham Goode
c244d056b9 treemanifest: auto-format code
Summary: This fixes various clang formatter lint warnings.

Reviewed By: phillco, singhsrb

Differential Revision: D8283573

fbshipit-source-id: c466ccaf8d5e50a7421fd34e43cf49559431d416
2018-06-05 16:40:44 -07:00
Durham Goode
1ac8657f83 treemanifest: require setting the start path for SubTreeIterator
Summary:
In a future diff we'll be adding the ability to iterate over just a
subsection of a tree. In order for the resulting paths to be correct, we need to
be able to prime the start path. To do so, let's add a path argument to the
SubTreeIterator, and set it to empty string everywhere it's currently used.

Reviewed By: quark-zju

Differential Revision: D8216727

fbshipit-source-id: 1969f380f7ad13f54a7dbcd2283b0428c4480ab4
2018-06-04 18:23:03 -07:00
Durham Goode
aa1e1a5604 treemanifest: remove resultEntry from iterators
Summary:
Now that markPermanent no longer requires a ManifestEntry to update the
node, the resultEntry field on all the iterators is unused. Let's delete it.

Reviewed By: quark-zju

Differential Revision: D8156808

fbshipit-source-id: 21aeb050c91552c7e8973a33dd7e347457125a64
2018-06-04 18:23:03 -07:00
Durham Goode
4708242f44 treemanifest: remove logic that updates ManifestEntry.node
Summary:
Now that the node field is accessed via a getter that can lazily
compute it, let's get rid of the logic that proactively sets it. This will make
it easier to refactor the subtree iterator in a later diff.

Reviewed By: quark-zju

Differential Revision: D8156809

fbshipit-source-id: aabc3f68cc41baea0c166b9a2bd68bea6b1a6a03
2018-06-04 18:23:03 -07:00
Durham Goode
63834775d7 treemanifest: move ManifestEntry node behind an accessor
Summary:
Previously the ManifestEntry node field was public and consumers could
read it directly. This required that the node field be updated manually, which
added complications to other code paths. In a future diff we'll be simplifying
the SubTreeIterator code to not require setting node, and to do so we make node
calculated in this accessor.

Reviewed By: quark-zju

Differential Revision: D8156807

fbshipit-source-id: e1908b2149bc0ec8fb1279e37b8a66988ff125c6
2018-06-04 18:23:03 -07:00
Durham Goode
0bbc6b6666 treemanifest: switch native iterators to use ManifestPtr
Summary:
This switches the treemanifest native iterators to use the ManifestPtr
class instead of Manifest*. ManifestPtr does ref counting, and in a future diff
we'll use this ability to have the subtree iterator iterate over a portion of a
larger tree so we can serve just parts of trees to gettreepack requests.

Reviewed By: quark-zju

Differential Revision: D8156806

fbshipit-source-id: 4dbb60d008ac8d0c789c3f2db8f7e567c5869539
2018-06-04 18:23:03 -07:00
Durham Goode
06e89ef39e treemanifest: check memcmp < 0 instead of memcmp == -1
Summary:
The memcmp contract is that the result is >0, 0, or <0. If <0 it's not
guaranteed to be -1, so let's broaden the check a bit.

Reviewed By: phillco

Differential Revision: D8190843

fbshipit-source-id: 78b864a639851a041c1a393f21a979d13eaa2e9c
2018-05-30 18:20:57 -07:00
David Lai
137fdc5b1c convert string compare to use equality operators
Summary:
The changes in this diff changes string comparisons using the compare method to
using equality operators.

Motivation:
- readability, simplifies code
- compare method is intended for sorting functions

This is clang check used: [Link Here](https://clang.llvm.org/extra/clang-tidy/checks/readability-string-compare.html)

Reviewed By: yfeldblum

Differential Revision: D7674416

fbshipit-source-id: dce375fb4b401f0e012ad4fc99b5dc4babe07f89
2018-04-19 13:54:59 -07:00
Adam Simpkins
86989ea19d treemanifest: fix call to memcpy() with null pointer
Summary:
memcpy() must not be called with a null source pointer, even when the length
argument is 0:
https://www.imperialviolet.org/2016/06/26/nonnull.html

The current behavior causes `hg commit` to crash when compiled with UBSAN
enabled.

Reviewed By: chadaustin, wez

Differential Revision: D7055450

fbshipit-source-id: 40afb40cb346d608fa0e59012bc329b5702ec651
2018-04-13 21:51:14 -07:00
Durham Goode
a493c04794 hg: remove assert from treemanifest code
Summary:
This assert appears to have always been wrong, but only respected when
built by clang. The SubtreeIterator class is created with an empty string in the
path member, and the only entry to the class is the next function which
immediately asserts that path is not empty. Since the only place path is set is
later in the function, there's no way it could start off as anything other than
empty.

Reviewed By: quark-zju

Differential Revision: D6891356

fbshipit-source-id: c55e616461d4a29308ca6e22be51ea02962d9df3
2018-04-13 21:51:03 -07:00
Jun Wu
86f264853a ctreemanifest: fix a use-after-free
Summary: This looks obvious to fix.

Reviewed By: DurhamG

Differential Revision: D6885215

fbshipit-source-id: 35cd0dcc0d53969b1ef08d4bd7bc99b186a53457
2018-04-13 21:51:03 -07:00
Durham Goode
228e6a901e cstore: move to hgext/extlib/
Summary: Moves cstore to hgext/extlib/ and makes it build.

Test Plan: make local && run-tests.py

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6678852
2018-01-08 17:55:53 -08:00
Durham Goode
3ae4bd8cf5 ctreemanifest: move to hgext/extlib/
Summary:
Moves ctreemanifest into hgext/extlib/. It will be built in a later
step when we add cstore to the build.

Test Plan: make local && cd tests && ./run-tests.py

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6678844
2018-01-08 17:55:53 -08:00