Commit Graph

82 Commits

Author SHA1 Message Date
Durham Goode
8180b78c83 ctree: implement treemanifest.walk
Summary:
This implements the walk function, which is almost identical to iterkeys, except
it filters the result using a provided matcher.

Test Plan:
As before, not sure how to execute this from in mercurial, but it's
pretty small so we'll test it with the full mercurial test suite once we can do
edits.

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3775631
2016-09-08 11:40:08 -07:00
Durham Goode
83e26c7a23 ctree: implement treemanifest.iterentries
Summary:
This implements the ability to iterate of the entries of the manifest. We reuse
the key iter, but add a boolean option for returning the full (path, node, flag)
tuple instead of just the path.

Test Plan:
I'm not sure of how to execute this via an hg command, so for now I'm
just going to

doitlive

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3775619
2016-09-08 11:42:34 -07:00
Durham Goode
ac2b28669a ctree: initialize variables before use 2016-09-08 11:40:08 -07:00
Tony Tung
68dd0c9944 [ctree] conversion method to hex from bin.
Summary: This is needed when we execute a `set`, which comes in with a binary node, but is stored as a hex string.

Test Plan: make local; used in later diff.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3831923:1473292766:bd4c1fdde356a8de5b4b74328e3805b7e1eae752
2016-09-07 17:50:30 -07:00
Tony Tung
bdf87070fa [ctree] clean up warnings
Summary:
1. remove unused `fetcher` variables.
2. std::string's second arg is a size_t, not a Py_ssize_t.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3830569:1473292747:823b5c06490c45c0bfcc59373e7935af0c1b3630
2016-09-07 17:50:16 -07:00
Tony Tung
0986a590b3 [ctree] funnel all access to the root manifest via getManifest() method
Summary: Since a lot of accesses are coming from within the treemanifest class, I renamed the cached variable as rootManifest_DO_NOT_ACCESS_DIRECTLY to make people think twice before accessing it.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/fb-hgext/tests/perftest.py  testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir, mjpieters

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

Signature: t1:3823297:1473213565:54657eeecff35549c71dc0af91c71cca9d426ac1
2016-09-07 13:00:55 -07:00
Tony Tung
199a37f983 [ctreemanifest] constructor should allow for the construction of an empty manifest
Summary:
The root node is now optional.  If it's not specified, an empty tree is constructed.

Added an unit test to cover this code path.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/fb-hgext/tests/perftest.py --config remotefilelog.fastdatapack=True testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"` still runs.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3803569:1472759620:02c1f723fe3b7f4cdca9da6399fc2296c6d5a022
2016-09-06 12:40:32 -07:00
Tony Tung
3c8381a899 [cfastmanifest] only create a Manifest object for ManifestEntry::initialize if it's a directory
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3803565:1472759508:750a6c87d271260df7d6a3af1e1de48707145839
2016-09-06 12:40:15 -07:00
Tony Tung
1a4389406c [ctreemanifest] add node as a param for addChild
Summary: This allows us to set the node hash when we add the child.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3803564:1472759281:a5e413ba7cf12319c4460da213ad8be7a0eed673
2016-09-06 12:39:07 -07:00
Tony Tung
96a13a14bf [ctreemanifest] const-ify the manifest directory flag
Summary:
DRY.  Also, it's safer.

Depends on D3772947

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3796249:1472663415:944a5209e0fecd0f9e6a5c54bf40df430b53016e
2016-09-06 12:38:54 -07:00
Tony Tung
6226cfb0f6 [ctreemanifest] no need for treemanifest_XXX now that we're part of the treemanifest class
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir, mjpieters

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

Signature: t1:3803563:1472759119:8b609f8725dae5c7658160427cd1d6709abe3355
2016-09-06 12:38:40 -07:00
Tony Tung
31dc781871 [ctreemanifest] move treemanifest_find inside treemanifest object
Summary: It's logical.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3803562:1472759066:83bb06dd04a993677bc59598610d3e0a82480eb8
2016-09-06 12:38:28 -07:00
Tony Tung
fb19ea1321 [ctreemanifest] move treemanifest_get inside the treemanifest class
Summary: This removes a bunch of extra arguments we were passing in because the treemanifest knows about it already.  Also inlined the entire resolve-the-root-manifest operation into a separate method.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/fb-hgext/tests/perftest.py --config remotefilelog.fastdatapack=True testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir, mjpieters

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

Signature: t1:3800793:1472758998:c4617894c947f84268a3fa1d0cdde03793889640
2016-09-06 12:38:15 -07:00
Tony Tung
dac5c4103c [ctreemanifest] store the fetcher instead of the store object
Summary: We don't actually care about the store.  We want to invoke the fetcher.  At some future point, we could replace the fetcher with something that goes to the network or whatever, or unit tests can point to something special.

Test Plan: make local && `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/fb-hgext/tests/perftest.py --config remotefilelog.fastdatapack=True testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3800789:1472758892:67cee86424da4b7b903f2495e31bdd03d793b21a
2016-09-06 12:11:11 -07:00
Tony Tung
f17f92c8a0 [cfastmanifest] move Find structures to the top of the file
Summary: 1 pass compiler!

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir, mjpieters

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

Signature: t1:3800784:1472758844:2cb86d11f422837e88230821b77c802def049e32
2016-09-06 12:10:35 -07:00
Tony Tung
b5d0b9f6ea [ctree] move diff C++ code to treemanifest.{cpp,h}
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir, mjpieters

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

Tasks: 12889491

Signature: t1:3795008:1472663226:63a578eacb007b832007d752c80215117f8d4879
2016-09-06 12:09:55 -07:00
Tony Tung
b168ae251e [ctree] replace _treemanifest_find with treemanifest_get
Summary: treemanifest_find is now a generic method to traverse a tree (like tree_path in cfastmanifest).  It manages the tree by adding and removing intermediate nodes (if requested).  Unlike _treemanifest_find, it uses lower-level APIs such as findChild and addChild, which uses std::list::iterator to avoid duplication of work.  Previously, we would need to traverse the entire list of children to find a child, and then if it's not found, traverse the entire list again to properly locate it.  Now we just find the exact location where the child is or should be, and then save that.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/remotefilelog:~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/remotefilelog/tests/perftest.py testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mjpieters, durham, mitrandir

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

Signature: t1:3772947:1472758787:8e8597c30f2cf1512ac7195bfa44ed62c201deb2
2016-09-06 12:09:42 -07:00
Jun Wu
3bd6e0c1e4 ctreemanifest: fix treemanifest_diffrecurse
Summary:
Seems like a logic error.

```
remotefilelog/ctreemanifest/py-treemanifest.cpp:289:34: error: self-comparison always evaluates to false [-Werror=tautological-compare]
           ((bool)selfentry->flag != (bool)selfentry->flag)
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
```

Test Plan: `make local`

Reviewers: #sourcecontrol, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3797686:1472656256:f8637d6787b0726743d8ced96dc179dc090bf029
2016-08-31 15:37:25 +01:00
Durham Goode
121c178e45 ctree: fix matcher use in py-treemanifest
There was a dumb bug where we attempted to use the matcher if it was NULL,
instead of only using the matcher when it was not NULL.  We just need to remove
the bad !.
2016-08-30 17:44:25 -07:00
Durham Goode
afe0a91adc ctree: return -1 instead of NULL for contains error 2016-08-29 16:19:52 -07:00
Durham Goode
7639fb3427 ctree: fix ref counting for args that are put in PythonObj wrappers
Summary:
It turns out PyArg_ParseTuple doesn't create new refs, so if we put any
arguments in PythonObj wrappers, they will be incorrectly decremented during
destruction. Let's increment the ref before putting any args in PythonObj.

Test Plan:
N/A, I just eyeballed this. I did look at all other uses of
PyArg_ParseTuple to verify no other cases had this issue.

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3766116
2016-08-29 16:19:52 -07:00
Durham Goode
ae1de63bcd ctree: implement treemanifest.__contains__
Summary:
With this implemented, it's now possible to run 'hg diff' and have it use
exclusively our treemanifest implementation.

Test Plan:
Ran 'hg diff -r master^ -r master' with some future patches and
verified the result was correct (it originally failed entirely because
__contains__ was not implemented).

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3766114
2016-08-29 16:19:52 -07:00
Durham Goode
a10476dec4 ctree: implement treemanifest.filesnotin
Summary: The filesnotin function is necessary for hg diff, so let's implement it.

Test Plan:
Ran 'hg diff -r master^ -r master' with some future patches and
verified the result was correct (it originally failed entirely because
filesnotin was not implemented).

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3766108
2016-08-29 16:19:52 -07:00
Durham Goode
38ad2b9ab5 ctree: fix treemanifest.diff signature
Summary:
Turns out that manifest.diff accepts kwargs, so we need to support that
signature. We'll come back and actually implement clean=True support later.

Test Plan:
Ran 'hg diff -r master^ -r master' with some future patches and
verified the result was correct (it originally failed entirely because diff had
the wrong signature).

Reviewers: #fastmanifest, ttung

Reviewed By: ttung

Subscribers: ttung

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

Signature: t1:3766104:1472156875:0ce2a16286b1e4fd6b0f2260249e3318270d8814
2016-08-29 16:19:52 -07:00
Durham Goode
2ed42c2e18 ctree: implement treemanifest.matches
Summary:
This implements the matches function of treemanifest. These are necessary for hg
diff to work.

Test Plan:
Ran 'hg diff -r master^ -r master' with some future patches and
verified the result was correct (it originally failed entirely because matches
was not implemented).

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3766101
2016-08-29 16:19:52 -07:00
Durham Goode
9038e49502 ctree: move py_fileiter creation to a function
Summary:
File iteration is becoming a common pattern, so let's move py_fileiter creation to a
common area. This also move the fileiter initialization logic into the
constructor so it's not duplicated anymore either.

Test Plan:
Ran 'hg files' and 'hg manifest' with future patches that allowed hg
to use the treemanifest and verified they still worked.

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3775597
2016-08-29 16:19:52 -07:00
Durham Goode
231b2d487f ctree: move file iterator to a separate function
Summary:
This moves the file iterator to a separate function so that it may be reused in
other areas. It also further separates the iterator from the python specific
logic.

Two notable changes to the logic:
1. It now returns the node and flag as well as the path.

2. Instead of copying iter->path straight into a python string for returning,
the caller provides a path, node, and flag character array as arguments and the
result is copied into that array. This results in a little more string copying
during iteration, but since the character array is stack allocated it the actual
performance impact is neglible.

Test Plan:
Ran the perf test, verified fulliter perf didn't change (2.2s before
and after).  Also used pdb to verify the results were valid and expected paths.

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3760071
2016-08-29 16:19:52 -07:00
Durham Goode
215719861a ctree: implement treemanifest.flags
Summary:
This implements the flags api. After this, hg manifest --debug can work with
treemanifest.

Test Plan:
In a future patch, I was able to run 'hg manifests' on a commit and
have it return the manifest contents by reading the treemanifest.

Reviewers: #fastmanifest

Differential Revision: https://phabricator.intern.facebook.com/D3755343
2016-08-29 16:19:52 -07:00
Durham Goode
e8cbd159b6 ctree: implement __getitem__
Summary: This implements treemanifest.__getitem__ in the C api.

Test Plan:
In a future patch, I was able to run 'hg manifests' on a commit and
have it return the manifest contents by reading the treemanifest.

Reviewers: #fastmanifest, ttung

Reviewed By: ttung

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

Signature: t1:3755338:1471930178:933e1d56f98c6e615624e2501a01a6ae925c2f8d
2016-08-29 16:19:52 -07:00
Durham Goode
c0d1a3e372 ctree: remove unnecessary rootpath variables
Summary: After a recent refactoring these are now unused.

Test Plan: make local

Reviewers: #fastmanifest, ttung

Reviewed By: ttung

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

Signature: t1:3756194:1471929972:bdace32b744bfaaf03228f13de0fb6ffec240dab
2016-08-29 16:19:52 -07:00
Durham Goode
ffa54597c6 ctree: move Python.h to be included first
Summary:
If we don't include Python.hg before some of the standard library (like list),
it causes a build error on some machines ('error: "_POSIX_C_SOURCE" redefined').
So let's move all Python.h to the front.

Also add a missing stdexcept include that's needed for the use of
std::logic_error

Test Plan: make local on centos6

Reviewers: #fastmanifest, ttung

Reviewed By: ttung

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

Signature: t1:3756191:1471929906:8afc09ee74b5ab5512fc87fadbed311cf15cb768
2016-08-29 16:19:52 -07:00
Tony Tung
5e5270d3a7 [ctree] initialize the ManifestEntry in addChild after adding to the list
Summary: When a ManifestEntry is destroyed, we reap the heap-allocated resources it holds.  However, this (erroneously) happens when we create a ManifestEntry and add it to the list of children.  What we really need is a move constructor from C++11.  The workaround is to initialize a blank ManifestEntry, add it to the proper location, and then populate it afterwards.

Test Plan: addChild (in a later diff) no longer tramples over memory it no longer owns.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3772915:1472174144:a4baac5cb5f6e01a38042c5c6cd92570c8f8e100
2016-08-26 13:49:17 -07:00
Tony Tung
4244eaa191 [ctree] addChild should return a ManifestEntry *
Summary: This gives us a bit of flexibility when we call this method, as references cannot be reassigned.

Test Plan: compiles

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3772844:1472174021:565d7f25a27c2fd78ce14b86b5bc499c74d47976
2016-08-26 13:49:17 -07:00
Tony Tung
13ec463298 [ctree] a newly instantiated ManifestEntry should point to a new Manifest
Test Plan: haven't used this yet, but it makes a whole lot of sense.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3770366:1472173969:b83e10e27a63b863a3566d2df7cc861417b8208e
2016-08-26 13:49:17 -07:00
Tony Tung
4b0840f5ea [ctree] add two new methods to Manifest
Summary:
1. `children()`, which returns the number of children the manifest has.
2. `removeChild()`, which removes the entry that the iterator references.

Test Plan: used in later diffs

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3770363:1472173823:737043b4613a669b402dcfd7921ac55278c3ece9
2016-08-26 13:49:17 -07:00
Tony Tung
96f89fa049 [ctree] fix findChild
Summary: The strings are not necessarily null-terminated and length needs to be considered.

Test Plan: used in later diff to find a path.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir

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

Signature: t1:3770358:1472173786:9a2f681c90476aafd481c301ff65ac8b199214ec
2016-08-26 13:49:17 -07:00
Tony Tung
79f0ebb34a [ctree] create a new method appendbinfromhex
Summary:
appendbinfromhex appends the binary representation of a 40-byte hex string onto a std::string.  This allows us to reuse a std::string rather than to allocate a new one every time.

Also:

1. converted binfromhex to use this method.
2. updated the docblocks to actually reflect reality.

Test Plan: `make local && cd ~/work/fbsource && PYTHONPATH=~/work/mercurial/facebook-hg-rpms/remotefilelog:~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/remotefilelog/tests/perftest.py testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3770048:1472105520:eac79a42360ebfa258519346b68fc4541c2dbb7c
2016-08-26 13:49:17 -07:00
Tony Tung
a6bc389217 [ctree] free memory when destroying a treemanifest object
Summary: Everyone who holds heap-allocated memory gets destructors!

Test Plan: valgrind and confirmed no memory leaking from ctreemanifest

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Tasks: 12818084

Signature: t1:3763327:1472105103:8ac9d9694be4bf3b09e19e4381737622c94a2dac
2016-08-26 14:00:37 -07:00
Tony Tung
118cc2f8f0 [ctree] cache the root manifest upon retrieval
Summary: In most cases, this is pretty straightforward.  The only unusual case is `_treemanifest_find`, which does the actual resolution of the root manifest (unlike diff and iter).

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir

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

Signature: t1:3763324:1472173572:3dcda9b318ad818d2f51e8c3472c7770739faafe
2016-08-26 13:49:17 -07:00
Tony Tung
5436c47a0d [ctree] rename node to rootNode
Summary: This more accurately describes its purpose.

Test Plan: simple refactor, so thus just make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir

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

Signature: t1:3763323:1472104318:b48246777db0527c7022066438c211f54c88703e
2016-08-26 13:49:17 -07:00
Tony Tung
75c02e78a9 [ctree] initialize all the fields in ManifestEntry constructor
Summary: It makes a destructor possible.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3763322:1472104242:e76ef1943c2082ddecff872c6472de4706505922
2016-08-26 13:49:17 -07:00
Tony Tung
de4ad14a9c [ctree] make path a reference in diff
Summary: It's a fixed reference that we use, so no need for a pointer.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/remotefilelog:~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/remotefilelog/tests/perftest.py testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3753463:1471905506:802315db9d2aa34363c7b0bccaefcbcda21b1a1e
2016-08-22 15:47:46 -07:00
Tony Tung
aab04b7fcf [ctree] have ManifestIterator::next return the entry directly
Summary: Since we're no longer returning a struct, we no longer need to return the value through a pointer argument.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/remotefilelog:~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/remotefilelog/tests/perftest.py testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Tasks: 12818084

Signature: t1:3752376:1471891162:e7cc159d2077d77d234902e4598b9661f15840c0
2016-08-22 15:47:31 -07:00
Tony Tung
fc7dffd109 [ctree] change the ManifestIterator to return ManifestEntry *
Summary: This allows us to modify the ManifestEntry stored in memory.  This also requires us to remove the const qualifier in a number of places.

Test Plan: `PYTHONPATH=~/work/mercurial/facebook-hg-rpms/remotefilelog:~/work/mercurial/facebook-hg-rpms/fb-hgext/:~/work/mercurial/facebook-hg-rpms/remotenames/:~/work/mercurial/facebook-hg-rpms/lz4revlog/ /opt/local/bin/python2.7 ~/work/mercurial/facebook-hg-rpms/hg-crew/hg --config extensions.perftest=~/work/mercurial/facebook-hg-rpms/remotefilelog/tests/perftest.py testtree --kind flat,ctree,fast --test fulliter,diff,find --build "master~5::master"`

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Tasks: 12818084

Signature: t1:3752366:1471891101:1d42a04d85b7e8db34644dc8fbf1bb3481fbb7bc
2016-08-22 15:47:16 -07:00
Tony Tung
a3b14127d3 [ctree] extract treemanifest code to its own file
Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3733819:1471542946:8b322a7099eceb41826bb9e0edeca52e2daceb4c
2016-08-22 15:45:06 -07:00
Tony Tung
4b9e4ad3ee [ctree] rename treemanifest.cpp to py-treemanifest.cpp
Summary: py-treemanifest.cpp will be mostly just python binding stuff.

Test Plan: make local

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3733832:1471542792:d6f1130b5c16487f4d0173cedd91857fd3711c1d
2016-08-22 15:44:50 -07:00
Tony Tung
e953a3cc27 [ctree] get rid of manifestkey
Summary: Directly pass in the path + len and the node.  Note that the path is now a char* + len, because this allows us to use the path in treemanifest_find directly, rather than to construct a new path.

Test Plan: run existing perftest without crash.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3738280:1471890923:c13283f1c61dc020ba1918ee9b25c24dfd2fc19b
2016-08-22 15:42:03 -07:00
Tony Tung
8205ab233f [ctree] methods to find and add children
Test Plan: used in later diff.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir

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

Signature: t1:3732102:1471905481:000ff5d976c348bac9f993f9c0b56f4b9c8b84f0
2016-08-22 15:41:52 -07:00
Tony Tung
33f0d41725 [ctree] modularize the code
Summary:
I like many small files.

There is one place where I'm making a functional change (convert.h) to satisfy angry compilers.

Test Plan: make local.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: mitrandir

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

Signature: t1:3732584:1471542758:d0b7804753ea4fd39a507090338ae3c5104dc7fa
2016-08-22 15:40:56 -07:00
Tony Tung
b05f64d3f0 [ctree] add constructor for ManifestEntry that allocates memory and places its data
Summary: For adding new children to Manifests, we need to be able to create new ManifestEntries.  Since these ManifestEntries will not be backed by datapack data structures, we need ManifestEntries that have its own memory allocation.

Test Plan: used in later diff.

Reviewers: #fastmanifest, durham

Reviewed By: durham

Subscribers: durham, mitrandir

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

Signature: t1:3732101:1471541200:17b60af0977109757610168637a276f5dd999f8b
2016-08-22 13:58:42 -07:00