Commit Graph

28 Commits

Author SHA1 Message Date
Durham Goode
c0aee83142 treemanifest: fix build breaks on OSX 2016-10-17 11:47:47 -07:00
Simon Farnsworth
195bbe3fcb Fix compile-breaking format string issue
Summary: "%d" is the wrong format specifier for size_t, and thus this does not build.

Test Plan: make local and see build succeed

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Signature: t1:4030507:1476726943:44c480a1e231fe98354d386116b112d508436093
2016-10-17 11:31:18 -07:00
Durham Goode
8557048507 treemanifest: implement iteritems()
This implements the iteritems api. As part of this change we needed to expand
our existing iterator options to allow separating nodes from flags.
2016-10-14 16:01:12 -07:00
Durham Goode
8eea28cd2e treemanifest: implement treemanifest.keys() 2016-10-14 16:01:12 -07:00
Durham Goode
c3bc594c82 treemanifest: fix and test treemanifest.matches()
It had a bug where it thought the node was hex but it was already binary.
2016-10-14 16:01:12 -07:00
Durham Goode
2b41307ebe treemanifest: fix treemanifest.flags() when the file doesn't exist
manifest.flags() actually returns the default value if the filename doesn't
exist. So we need to replicate that behavior.

As part of this fix, I changed treemanifest.get() to return a boolean indicating
whether the file was found or not.
2016-10-14 16:01:12 -07:00
Durham Goode
f7249fd2e2 treemanifest: implement treemanifest.__nonzero__
This implements the __nonzero__ function, which is necessary for things like
`if mymanifest:`
2016-10-14 16:01:12 -07:00
Durham Goode
ae6de9bbdb treemanifest: implement treemanifest.dirs()
This implements the dirs function, which returns a collection set that can
answer the question of if a directory is in the manifest. Currently we do a
naive solution of using util.dirs(), which iterates over all the files. Given
that we have a tree already, we should be able to return something smarter in
the future.
2016-10-14 16:01:12 -07:00
Durham Goode
c171077ebd treemanifest: add None check for treemanifest.contains()
Mercurial sometimes checks if "None in mf", so we need to make sure we return
False in that situation.
2016-10-14 16:01:12 -07:00
Durham Goode
a68bd8bc73 treemanifest: add error checking for all argument strings
We weren't checking if the passed in string arg was successfuly parsed. This
patch adds checks for all of those instances.
2016-10-14 16:01:12 -07:00
Durham Goode
75c7cb42a1 treemanifest: implement hasdir()
Implements the py-treemanifest.hasdir() function
2016-10-14 16:01:12 -07:00
Durham Goode
89ad596f78 treemanifest: allow find() to get files and directories
Previously find would only return files. For treemanifest.hasdir() we needed it
to find directories as well. This patch adds a new enum for indicating if the
find should return files, directories, or both.
2016-10-14 16:01:12 -07:00
Durham Goode
445c6b0d4e treemanifest: fix diff on transient trees
The diff algorithm assumed every tree already had a node. If we are iterating
over an uncommitted tree, it may have tree entries with NULL as their node. We
need to always recurse in these cases.
2016-10-14 16:01:12 -07:00
Durham Goode
cd423fd42a treemanifest: implement 'clean' on diff
hg has an optional 'clean' arg on diff, which causes it to also return files
that aren't different between the two diffs. This implements it on our
treemanifest diff algorithm.
2016-10-14 16:01:12 -07:00
Durham Goode
7f2988ce25 treemanifest: implements text()
Implements the py-treemanifest.text() function
2016-10-14 16:01:12 -07:00
Durham Goode
f108eebde4 treemanifest: implements __setitem__
Implements the py-treemanifest.__setitem__ function. This also handles the
__delitem__ case.
2016-10-14 16:01:12 -07:00
Durham Goode
d96c188d00 treemanifest: implement setflag()
Implements the py-treemanifest.setflag() function
2016-10-14 16:01:12 -07:00
Durham Goode
ea9c99a376 treemanifest: implement get()
Implements the py-treemanifest.get() function
2016-10-14 16:01:12 -07:00
Durham Goode
9819c37220 treemanifest: update entry nodes even if they haven't changed
During serialization, if we encountered a tree entry that had a NULL node, but
the contents matched the prior version, we considered it unchanged and did not
replace the null pointer with a pointer to the actual hash. This meant when it's
parent tried to serialize it, it would encounter a null pointer exception and
crash. Now we always fill in the node during popResult, since by definition it
will be null there (since the only way for something to be pushed is for it to
be null).
2016-10-14 16:01:12 -07:00
Durham Goode
24071807b7 treemanifest: change find() to do copy-on-write
The find() function is used to perform set and delete operations on a tree. Now
that we track Manifests via mutability and ref counting, we can change find() to
do copy-on-write.
2016-10-14 16:01:12 -07:00
Durham Goode
e8554fc3d9 treemanifest: add concept of mutability to manifest, and use it during edits
This adds the concept of mutable and immutable Manifests. During a treemanifest
copy, any sub-manifests that are immutable (such as ones that had been loaded
from a store, or those that are in memory but have been mark immutable), do not
need to be copied. This dramatically reduces the amount of memory allocation
happening when copying trees during automatic tree creation during hg pull.
2016-10-14 16:01:12 -07:00
Durham Goode
1faefff046 treemanifest: convert all ownership Manifest references to ManifestPtr
Now that we have a ManifestPtr object, let's use it in all the places we
currently have Manifest ownership and cleanup happening. We don't need to fix up
any places that are just using Manifests from a readonly, non-lifetime related
perspective.

This gets rid of all the 'delete' calls on Manifest, except the one inside
~ManiestPtr;
2016-10-14 16:01:12 -07:00
Durham Goode
b84ba7af52 treemanifest: introduce ManifestPtr and refcount
Copying our tree manifests is currently the most expensive part of converting
manifests to trees on the fly. Let's introduce refcounting to the Manifest
lifetime, so we can share Manifests across treemanifest instances. Future diffs
will convert all uses of Manifest* to ManifestPtr, then even more future diffs
will change copy and edit operations to be copy-on-write.
2016-10-14 16:01:12 -07:00
Zachary Amsden
30c28a2667 Fix bogus update
Summary:
Forgot to commit, so test build just succeeded as it built with
uncommitted change

Test Plan: ./fb_build_rpm.py --release AAAAAA

Reviewers: simpkins

Reviewed By: simpkins

Subscribers: net-systems-diffs@, mjpieters

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

Signature: t1:3978726:1475713413:3dcb5389c562ccc1b5675d2b78bcdb2dcba38780
2016-10-05 21:34:50 -07:00
Zachary Amsden
57128e9ab7 Fix Darwin ctreemanifest build
Summary:
Apparently, clang infers that pointer variables in private
structs are unreferenced if they are aliased by parameter names in the
constructor. This doesn't appear to happen with variable passed by
reference.  Unalias the field to work-around the problem.

Test Plan: ./fb_build_rpm.py on OS/X

Reviewers: ttung, durham, simpkins

Reviewed By: simpkins

Subscribers: quark, net-systems-diffs@, mjpieters

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

Tasks: 13740577

Signature: t1:3978090:1475709499:e50c751341d172f055ed02376521bd880644b01f
2016-10-05 16:39:49 -07:00
Jun Wu
ca6d644eab ctreemanifest: fix compilation error
Summary:
This fixes the following error when being compiled by clang:

  In file included from ctreemanifest/treemanifest.cpp:10:
  ctreemanifest/treemanifest.h:247:15: error: private field 'mainRoot' is not used [-Werror,-Wunused-private-field]
      Manifest *mainRoot;
                ^

Test Plan: `make local` on OS X.

Reviewers: durham, ttung, #sourcecontrol

Subscribers: simpkins, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3949603
2016-09-30 04:51:44 +01:00
Adam Simpkins
a9cad103ae [ctreemanifest] fix ambiguous call to string::erase()
Summary:
gcc 4.9 complains that erase(0) is ambiguous, and may be either string::erase(size_t)
or string::erase(iterator) (since iterator is "char*", and for historical
reasons 0 can be interpreted as a null char*).

Fix the code to explicitly indicate that it means the erase(size_t) version.

Test Plan: Confirmed that the code built successfully with gcc 4.9.

Reviewers: durham, mitrandir, ttung

Reviewed By: ttung

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Signature: t1:3911252:1474589551:688ecab4d59053dbdf7b48a062f248d8363e17f3
2016-09-22 18:58:04 -07:00
Durham Goode
50d6b599f4 Move ctreemanifest and cdatapack out of remotefilelog
These don't really have any dependencies on remotefilelog, so let's move them
out.
2016-09-21 13:55:12 -07:00