Commit Graph

430 Commits

Author SHA1 Message Date
Jyothsna Konisa
62cd0f90e1 Basic eden rage command
Summary:
1.Added new rage command to command line tools.
2.Eden rage command currently shows Logs,package version,rpm version,build revision,build upstream revision,list of running eden processes and their info,list of mount points and their info.

Reviewed By: simpkins

Differential Revision: D5220250

fbshipit-source-id: 357f46d8d08d4a1f197b705dfd1a28668dd180f0
2017-06-15 11:12:15 -07:00
Jyothsna Konisa
8da0797e92 Fix in eden debug for relative path in get_path_info()
Summary: made the relative path return "" when mount point directory is returned "."

Reviewed By: simpkins

Differential Revision: D5250543

fbshipit-source-id: bd0d648db8030cfc6ca952fccfb9972f18290b5e
2017-06-15 11:12:11 -07:00
Jasmeet Bagga
9bbee241e6 Change API between SwSwitch and HwSwitch to indicate HwSwitch might fail some
Summary:
Depend on D4492997
Currently, we assume that changes applied to HwSwitch always succeed (or the process exits). There is a case where we want to keep moving despite failures: when we get excessive number of route (probably) because of some misconfiguration. This diff is a step towards taking care of such situation.

We change the interface between SwSwitch and HwSwitch so that HwSwitch, when asked to apply delta of old and new state, returns either the new state if it succeeds, or returns a "pruned version of new state" if some elements of new state it was not able to apply.

SwSwitch now keeps track of two states, a state that has been applied in the hardware, and another one that is desired in hardware. SwSwitch strives to catch applied state to the desired state (while desired state is also changes as move state updates are arriving).

One issue with this diff: Warmboot is not preserving "unapplied" routes, i.e., unapplied routes get lost across warmboots. This will be fixed in a seperate diff.

One naming issue: I thought about keeping SwSwitch::getState() name intact, but thought that it is not a good idea to keep distinction of states opaque to callers. So, decided to change the name.

Reviewed By: ninas

Differential Revision: D4405751

fbshipit-source-id: c933b4418445ae49d5b8e21dea95e437a8e1593d
2017-06-02 13:38:22 -07:00
Andrew Gallagher
03bdaff954 codemod: format TARGETS with buildifier [4/5] (D5092623)
Reviewed By: igorsugak

fbshipit-source-id: 277a9d2bdc1d7e3ff3075bfe2d7307502fd0a507
2017-06-01 17:52:40 -07:00
Andrew Gallagher
6df267fe5c codemod: format TARGETS with buildifier [3/5] (D5092623)
Reviewed By: igorsugak

fbshipit-source-id: c3036011faa009bb2b051142b1caedfdbe77b3df
2017-06-01 16:51:16 -07:00
Yedidya Feldblum
cd1c221d92 Cut the recursive-glob in folly:folly
Summary: [Folly] Cut the recursive-glob in `folly:folly`.

Reviewed By: snarkmaster

Differential Revision: D4964956

fbshipit-source-id: c810e03e175d4f56f7bfd36833b46624b52b1c51
2017-05-30 23:07:43 -07:00
Michael Bolin
57f5d72a27 Reimplement dirstate used by Eden's Hg extension as a subclass of Hg's dirstate.
Summary:
This is a major change to Eden's Hg extension.

Our initial attempt to implement `edendirstate` was to create a "clean room"
implementation that did not share code with `mercurial/dirstate.py`. This was
helpful in uncovering the subset of the dirstate API that matters for Eden. It
also provided a better safeguard against upstream changes to `dirstate.py` in
Mercurial itself.

In this implementation, the state transition management was mostly done
on the server in `Dirstate.cpp`. We also made a modest attempt to make
`Dirstate.cpp` "SCM-agnostic" such that the same APIs could be used for
Git at some point.

However, as we have tried to support more of the sophisticated functionality
in Mercurial, particularly `hg histedit`, achieving parity between the clean room
implementation and Mercurial's internals has become more challenging.
Ultimately, the clean room implementation is likely the right way to go for Eden,
but for now, we need to prioritize having feature parity with vanilla Hg when
using Eden. Once we have a more complete set of integration tests in place,
we can reimplement Eden's dirstate more aggressively to optimize things.

Fortunately, the [[ https://bitbucket.org/facebook/hg-experimental/src/default/sqldirstate/ | sqldirstate ]]
extension has already demonstrated that it is possible to provide a faithful
dirstate implementation that subclasses the original `dirstate` while using a different
storage mechanism. As such, I used `sqldirstate` as a model when implementing
the new `eden_dirstate` (distinguishing it from our v1 implementation, `edendirstate`).

In particular, `sqldirstate` uses SQL tables as storage for the following private fields
of `dirstate`: `_map`, `_dirs`, `_copymap`, `_filefoldmap`, `_dirfoldmap`. Because
`_filefoldmap` and `_dirfoldmap` exist to deal with case-insensitivity issues, we
do not support them in `eden_dirstate` and add code to ensure the codepaths that
would access them in `dirstate` never get exercised. Similarly, we also implemented
`eden_dirstate` so that it never accesses `_dirs`. (`_dirs` is a multiset of all directories in the
dirstate, which is an O(repo) data structure, so we do not want to maintain it in Eden.
It appears to be primarily used for checking whether a path to a file already exists in
the dirstate as a directory. We can protect against that in more efficient ways.)

That leaves only `_map` and `_copymap` to worry about. `_copymap` contains the set
of files that have been marked "copied" in the current dirstate, so it is fairly small and
can be stored on disk or in memory with little concern. `_map` is a bit trickier because
it is expected to have an entry for every file in the dirstate. In `sqldirstate`, it is stored
across two tables: `files` and `nonnormalfiles`. For Eden, we already represent the data
analogous to the `files` table in RocksDB/the overlay, so we do not need to create a new
equivalent to the `files` table. We do, however, need an equivalent to the `nonnormalfiles`
table, which we store in as Thrift-serialized data in an ordinary file along with the `_copymap`
data.

In our Hg extension, our implementation of `_map` is `eden_dirstate_map`, which is defined
in a Python file of the same name. Our implementation of `_copymap` is `dummy_copymap`,
which is defined in `eden_dirstate.py`. Both of these collections are simple pass-through data
structures that translate their method calls to Thrift server calls. I expect we will want to
optimize this in the future via some client-side caching, as well as creating batch APIs for talking
to the server via Thrift.

One advantage of this new implementation is that it enables us to delete
`eden/hg/eden/overrides.py`, which overrode the entry points for `hg add` and `hg remove`.
Between the recent implementation of `dirstate.walk()` for Eden and this switch
to the real dirstate, we can now use the default implementation of `hg add` and `hg remove`
(although we have to play some tricks, like in the implementation of `eden_dirstate.status()`
in order to make `hg remove` work).

In the course of doing this revision, I discovered that I had to make a minor fix to
`EdenMatchInfo.make_glob_list()` because `hg add foo` was being treated as
`hg add foo/**/*` even when `foo` was just a file (as opposed to a directory), in which
case the glob was not matching `foo`!

I also had to do some work in `eden_dirstate.status()` in which the `match` argument
was previously largely ignored. It turns out that `dirstate.py` uses `status()` for a number
of things with the `match` specified as a filter, so the output of `status()` must be filtered
by `match` accordingly. Ultimately, this seems like work that would be better done on the
server, but for simplicity, we're just going to do it in Python, for now.

For the reasons explained above, this revision deletes a lot of code `Dirstate.cpp`.
As such, `DirstateTest.cpp` does not seem worth refactoring, though the scenarios it was
testing should probably be converted to integration tests. At a high level, the role of
`DirstatePersistence` has not changed, but the exact data it writes is much different.
Its corresponding unit test is also disabled, for now.

Note that this revision does not change the name of the file where "dirstate data" is written
(this is defined as `kDirstateFile` in `ClientConfig.cpp`), so we should blow away any existing
instances of this file once this change lands. (It is still early enough in the project that it does
not seem worth the overhead of a proper migration.)

The true test of the success of this new approach is the ease with which we can write more
integration tests for things like `hg histedit` and `hg graft`. Ideally, these should require very
few changes to `eden_dirstate.py`.

Reviewed By: simpkins

Differential Revision: D5071778

fbshipit-source-id: e8fec4d393035d80f36516ac050cad025dc3ba31
2017-05-26 12:05:29 -07:00
Eric Niebler
801fce3a91 Replace FOLLY_WARN_UNUSED_RESULT with FOLLY_NODISCARD everywhere
Summary: `[[nodiscard]]` is the future. Let's start now.

Reviewed By: yfeldblum

Differential Revision: D5108297

fbshipit-source-id: c98f44af9e282616af92f9171516b6ea18e68c6d
2017-05-24 20:40:38 -07:00
Victor Gao
f5c853a552 apply clang-tidy modernize-use-override
Summary:
This is generated by applying clang-tidy `-checks=modernize-use-override` to all the c++ code in project eden.
It enforces the use of the keywords `virtual`, `verride` and `final` in a way compliant to the style guide.

Reviewed By: igorsugak

Differential Revision: D5108807

fbshipit-source-id: 596f2d73f1137de350114416edb1c37da5423ed5
2017-05-23 16:10:26 -07:00
Eric Niebler
27c4156b1f Add FOLLY_NODISCARD for [[nodiscard]] attribute when it exists, FOLLY_WARN_UNUSED_RESULT uses FOLLY_NODISCARD.
Summary: The `nodiscard` attribute was added to standard C++ in C++17. Prefer the standard formulation when it is available; otherwise, use `__attribute__((__warn_unused_result__))` on compilers that support the GNU extensions, and `_Check_return_` on MSVC. The old `FOLLY_WARN_UNUSED_RESULT` is now expands to `FOLLY_NODISCARD`.

Reviewed By: yfeldblum

Differential Revision: D5105137

fbshipit-source-id: 9aa22e81cd9f0b89f9343433aeae3ba365227ccb
2017-05-23 09:05:33 -07:00
Michael Bolin
33ec2b7526 Add directaccess to the list of extensions we enable during integration tests.
Summary:
I was working on a new test and I got an error that `directaccess` must be
enabled for `inhibit` to work.

Reviewed By: simpkins

Differential Revision: D5077133

fbshipit-source-id: cc5235c845e3f299f96e1c901ef4aea18ca57b76
2017-05-18 20:35:36 -07:00
Wez Furlong
b06681a4da remove use of folly::window
Summary:
We're using `window` to constrain resources and maintain an upper
bound on the number of futures that we spawn.  Ironically, for a largish number
of already completed futures, this results in a recursive chain of `spawn`
calls in the `window` implementation and results in a stack overflow (the kind
that crashes a program, not the kind that answers programming questions).

This diff removes the use of `window` and replaces it with `collect`.
An earlier iteration of this diff just made all of these calls serially,
blocking the main thread.  This at least does things in parallel; both
can torture the system for pathological walks, but at least the parallel
one should complete faster.

Reviewed By: simpkins

Differential Revision: D4932774

fbshipit-source-id: 40d39a85029f38ff69a530070efb879a81950451
2017-05-18 12:55:17 -07:00
Michael Bolin
2286e9fb14 Perform a basic histedit command and add an integration test.
Summary:
I had to add simple implementations to various things in `edendirstate`
in order to be able to run `hg histedit`. There is still a lot more to do, but
at least this gives us a starting point to iterate and a test to demonstrate
the most simple functionality.

Reviewed By: wez

Differential Revision: D5049308

fbshipit-source-id: 34727f633c003cacae44108eb3ece06590098c7b
2017-05-16 12:36:17 -07:00
Michael Bolin
145ca986a7 Specify HGRCPATH for Hg integration tests to make test environment hermetic.
Summary:
Note that we must specify quite a few extensions to get behavior that is
representative of how Hg works at Facebook.

Reviewed By: DurhamG

Differential Revision: D5057478

fbshipit-source-id: ee774a9b8dcebe82e4b19cc52f9b0b5a53e6420c
2017-05-15 11:11:00 -07:00
Yedidya Feldblum
5ce1151eed Add missing deps on @/folly:array
Summary: Add missing deps on `@/folly:array`.

Reviewed By: meyering

Differential Revision: D5058690

fbshipit-source-id: 800b4c82db40ad73d974bd67fb94774f8df1b38e
2017-05-14 16:05:49 -07:00
Michael Bolin
85a107c550 Set ui.username in ~/.hgrc in integration tests.
Summary:
Recall that we override `$HOME` in integration tests, so this will not overwrite
your personal `~/.hgrc` when you run an integration test.

An upcoming integration test for `hg histedit` that I am working on requires
this value to be set.

Reviewed By: wez

Differential Revision: D5051112

fbshipit-source-id: 2fd8541aa6504640b08337fdc22160e243beaae3
2017-05-12 13:05:50 -07:00
Michael Bolin
f766fe0a87 Update Hg integration tests to use assert_status().
Summary:
`HgExtensionTestBase.assert_status()` was added in D4814422, but it was only
applied to `update_test.py`. This change updates the docstring (it appears to
have been copy/pasted from a nearby method), and makes use of it in the other
integration tests.

Reviewed By: wez

Differential Revision: D5050775

fbshipit-source-id: bb70740b6f455a84e7a22c3286c8ddbe2462f816
2017-05-12 09:19:57 -07:00
Michael Bolin
460ec77a8b Add pudb to the integration test dependencies for ease of use.
Summary:
Previous to this change, when I would add `import pudb; pudb.set_trace()` to do
some debugging, two annoying things would happen:

- I would have to edit the `TARGETS` file to add `pudb` as a dependency and
then `buck build eden/integration/hg` again.
- When I hit a breakpoint using `pudb`, I would have to go through the welcome
screen, change the theme, etc., because my settings were not found.

Now that I figured out what the problem was, I added instructions to the
`TARGETS` file to help others fall into the pit of success.

Reviewed By: wez

Differential Revision: D5050725

fbshipit-source-id: 1896f9f52eb056b3295b2d8e896dabb5d990ba22
2017-05-12 09:19:57 -07:00
wurzel parsons-keir
4e7af57e2d open(O_CREAT): supply required third argument on .cpp/.h files
Summary:
It is an error to not provide mode argument when open is
called with O_CREAT.

Reviewed By: oebeling

Differential Revision: D5020517

fbshipit-source-id: 87665ceb16ebdff797f8bf3d33bea082191e3121
2017-05-10 07:51:04 -07:00
Eddie Elizondo
dd1cc7ca9b Codemod enums to add explicit values [2/6]
Summary: This modifies thrift files to make enum values explicit

Reviewed By: yfeldblum

Differential Revision: D5014605

fbshipit-source-id: 6822928b6a6bb8e34e89b7bbb2621c66cd670cf0
2017-05-08 13:55:13 -07:00
Yiding Jia
d817176188 Add -hgPythonPath option to eden HgImporter
Summary:
On OSX mercurial libraries are not installed in the standard pythonpath. This
option lets me pass a pythonpath to the hg importer script only, without
polluting the pythonpath for other subprocess invocations (such as python 3
based hooks, which are not happy with python2 pythonpaths).

Reviewed By: bolinfest

Differential Revision: D4992222

fbshipit-source-id: aa8e734970344215cc8783e164fd119c3ee6aed6
2017-05-04 17:21:55 -07:00
Yiding Jia
cf7935f0ab Add missing includes in eden files
Summary:
These files are defining flags, so they should import gflags.
This import being missing causes open source build to fail.

Reviewed By: bolinfest

Differential Revision: D4992246

fbshipit-source-id: 61eb35b43ae6f9ff88bd34a9ebc8db6d80ac9d08
2017-05-03 10:30:32 -07:00
Michael Bolin
edbb0ce210 Build //eden/fs/service:thrift-EdenService-pyremote as part of :all target.
Summary:
When we say we are building "all" of Eden, we generally want to ensure we have
built the pyremote service that the Hg extension needs, as well.

Reviewed By: wez

Differential Revision: D4982118

fbshipit-source-id: 7282266e82e662a48b5ced6da6b7daedab8b65ea
2017-05-02 10:50:09 -07:00
Adam Simpkins
c3f47540b0 update the Dirstate to use TreeInode directly to unlink files
Summary:
Update Dirstate::remove() to directly call TreeInode::unlink() instead of going
through the EdenDispatcher.  Internal code should be able to use TreeInode
directly without going through the FUSE Dispatcher.  This prevents us from
having to look up the TreeInode object by inode number again.

This also fixes TreeInode::unlink() and TreeInode::rmdir() to perform FUSE
cache invalidation correctly.  EdenDispatcher used to do this for unlink()
calls, but it was missing for rmdir() calls.

Reviewed By: wez

Differential Revision: D4968832

fbshipit-source-id: 51fda5de196392c640436ca6ad7d8333e6799db9
2017-05-01 18:54:42 -07:00
Adam Simpkins
a521832407 simplify the Dirstate::removeAll() code
Summary:
This replaces the shouldFileBeDeletedByHgRemove() function with a much simpler
and safer check.

It turns out this code was more complicated than it needed to be: it looked up
the inode in question and confirmed that it still existed, even though it's
calling function had already previously looked up the inode object.

I believe this deletes the last place in the code that still assumes that an
InodeBase object must be loaded if the inode has previously been materialized.
This also removes one of the last remaining places that directly holds the
TreeInode contents_ lock outside of TreeInode.cpp.

Reviewed By: bolinfest

Differential Revision: D4968834

fbshipit-source-id: a37bc0d7889eb81cca5b045cbc82732a53ef53d4
2017-05-01 18:54:41 -07:00
Adam Simpkins
51df0c0663 refactor Dirstate::addAll() to clean up some old code
Summary:
This updates the Dirstate::addAll() code to use EdenMount::diff() internally,
instead of getStatusForExistingDirectory().

This lets us delete getStatusForExistingDirectory() and several other helper
functions that it used.  The logic in getStatusForExistingDirectory() was based
on the incorrect assumption that files can only be modified from their expected
source control state if they are materialized.  This could result in incorrect
results in a variety of cases (particularly after renames, or "hg reset"
operations).  The EdenMount::diff() code does not have this problem.

That said, this new addAll() code does still have some performance issues--it
currently does a full tree diff for each input path.  We should ideally fix
this in the future to only diff the necessary subtree for each path.  However,
in the short term this trade-off seems worth being able to delete all of this
older, buggy code.  diff() should be cheap enough in most cases that this won't
be a major problem unless a large number of paths are given as input.

Reviewed By: bolinfest

Differential Revision: D4968835

fbshipit-source-id: 1834aa98a26dcaa0e1c06c7ac25c57944fa1b5f7
2017-05-01 18:54:41 -07:00
Adam Simpkins
eb1a2b671c minor clean up to GitIgnoreStack handling
Summary:
Make sure we use pointers to const GitIgnoreStack objects when possible.

Also change the code to store the root GitIgnoreStack object for a diff()
operation in the DiffContext object, instead of having EdenMount::diff()
allocate it separately on the heap.  This will make it easier to consolidate a
bit more logic in the DiffContext class in the future.  In particular, I
suspect we will want a version of diff() that only works on one portion of the
tree.  Putting more of the functionality in DiffContext will make it slightly
easier to share code between the full-mount diff and the subtree diff
functions.  This also happens to save a memory allocation for now.

Reviewed By: wez

Differential Revision: D4968833

fbshipit-source-id: 1dc33b3d44cdf00e93b22d810c3a736d27c13638
2017-04-28 19:21:34 -07:00
Adam Simpkins
a9b2c41328 update the hg extension to support multiple parents
Summary:
Update the eden thrift APIs to support multiple thrift parents, and update the
hg extension to use the new thrift APIs.

Reviewed By: bolinfest

Differential Revision: D4949139

fbshipit-source-id: 98a7bd17ccad7be6a429df34ecfaf3fe7ae0b39a
2017-04-27 17:37:03 -07:00
Adam Simpkins
f5e924af94 support storing two parent commits
Summary:
This updates the ClientConfig and EdenMount code to support storing two parent
commits.

This changes the on-disk SNAPSHOT file contents add an 8-byte header that
includes a file identifier and a file format version number, followed by up to
two commit hashes.  The code currently can read either the old or new format
from the SNAPSHOT file.  We should be able to drop the code for reading the old
format fairly soon if we want, though.

This diff only updates the ClientConfig and EdenMount code, and does not yet
update the thrift APIs or the eden mercurial extension yet.  I will update the
rest of the code in a subsequent diff.

Reviewed By: bolinfest, wez

Differential Revision: D4943917

fbshipit-source-id: cf456e67b845aa0cf8b45c822985cb932df107b4
2017-04-27 11:50:13 -07:00
Yedidya Feldblum
d5837dca4b Casing consistency for exception_wrapper::throw_exception
Summary: [Folly] Casing consistency for `exception_wrapper::throw_exception`.

Reviewed By: Orvid

Differential Revision: D4944818

fbshipit-source-id: 72056fb24ab6362e9a0319f73b5bbf8c92d658ca
2017-04-27 01:21:04 -07:00
Adam Simpkins
d090035fa4 add unit tests for FileInode::setattr()
Summary: Add some unit tests that check the behavior of setattr() and getattr().

Reviewed By: bolinfest, wez

Differential Revision: D4941215

fbshipit-source-id: 6691f51aea742d0159a16112ca291546a8adc928
2017-04-26 21:51:36 -07:00
Adam Simpkins
e9af688f90 fix missing space in EXPECT_THROW_* error messages
Summary:
The error messages for various failure cases in EXPECT_THROW_RE() and
EXPECT_THROW_ERRNO() were missing a space after the statement being executed.

Reviewed By: bolinfest

Differential Revision: D4941175

fbshipit-source-id: e10b4bff7db027acc5cc7ad5c12af248d55c7cd8
2017-04-24 18:20:50 -07:00
Adam Simpkins
87cbfe142b update the in-memory snapshot correctly after a commit
Summary:
This fixes "hg commit" so that it correctly updates the in-memory snapshot.
This has been broken ever since I added the in-memory snapshot when
implementing checkout().  The existing scmMarkCommitted() method updated only
the Dirstate object and the on-disk SNAPSHOT file.

This diff fixes checkout() and resetCommit() to clear the Dirstate user
directives correctly, and then replaces calls to scmMarkCommitted() with
resetCommit().

Reviewed By: bolinfest

Differential Revision: D4935943

fbshipit-source-id: 5ffcfd5db99f30c730ede202c5e013afa682bac9
2017-04-24 18:06:59 -07:00
Adam Simpkins
5da361f55b improve building and importing of the eden hg extension
Summary:
This updates how we build and package the eden hg extension, and how we find it
during integration tests.

- Update the extension to always look relative to its current location to find
  the other modules it depends on.  This ensures that the integration tests
  always find modules from the local repository, and do not use the modules
  installed on the system.

- Add a buck rule to unpack the python archive at build time.  This is needed
  for integration tests to use the local version of the module.

- Ensure that we install a correct `hgext3rd/__init__.py` module in the eden
  extension directory.  This is required to correctly set up `hgext3rd` as a
  namespace package.  This also unfortunately needs to be a `.py` file, and not
  just a .pyc file.  (The pkgutil.expand_path() code looks specifically for
  directories containing `__init__.py` files, and does not check for
  `__init__.pyc`.)

- Update the extension to only try importing the native thrift modules if we
  are running python 2.7.6 or greater.  Python 2.7.6 is the first that supports
  unicode arguments to `struct.pack()`, which thrift requires.  Python 2.7.5 can
  import the thrift modules, but throws errors when trying to run them.

Reviewed By: bolinfest

Differential Revision: D4935279

fbshipit-source-id: 9af81736124c55476a5eb5beba9474a4371a639b
2017-04-24 11:14:34 -07:00
Saif Hasan
d792d1607c Do not set default value for ifName
Summary:
Setting default value to empty causes trouble on server if client is old as
server will think that value is set to empty and it tries to parse empty value.

This field is not being used anywhere except in `openr` for now and openr is
fully compatible with this change. Not setting default value will give us as
`__isset.ifName` to `false` instead of being empty string, which is desired
behaviour.

(Note: this ignores all push blocking failures!)

Reviewed By: anantdeepak

Differential Revision: D4934119

fbshipit-source-id: 4dd2e9307c659f1b6ccaf583964efa8df6041d24
2017-04-21 22:49:35 -07:00
Adam Simpkins
841c9006e3 honor trailing slashes on gitignore patterns
Summary:
Update the gitignore code so that patterns ending in a trailing slash correctly
match only directories.  Fortunately we have file type information available
during TreeInode::computeDiff(), so getting the correct file type information
does not add any extra overhead.  The older ignore checking code in
Dirstate.cpp can also do a reasonable job of getting file type information.
That code should also be removed at some point in the future, and use the
TreeInode logic for computing ignore status.

Reviewed By: bolinfest

Differential Revision: D4901326

fbshipit-source-id: 1222c8142876c91e1b80ec937ec84c0c28737224
2017-04-20 21:21:15 -07:00
Wez Furlong
c51abba97a avoid an issue reported by ASAN
Summary:
The temporary Hash object doesn't live long enough for the copy into
the string, so make an explicit temporary to extend its lifetime.

Reviewed By: simpkins

Differential Revision: D4900457

fbshipit-source-id: 948d919b929285c30ee1f9f0111cba20b60d4dc6
2017-04-17 15:35:09 -07:00
Wez Furlong
4923ba4d07 fixup finding the edenfs binary
Summary: We overlooked this in the recent move around of the cli code

Reviewed By: bolinfest

Differential Revision: D4894230

fbshipit-source-id: 5c3ae274a182e5cc41df47100959f8cfbcb59c2d
2017-04-14 16:48:29 -07:00
Wez Furlong
59ed6b36b5 import tree manifest data from mercurial
Summary:
When tree manifest data is available, we don't need to parse the full
manifest any more, which is great because we can simply and quickly load the
root manifest and be done with a checkout operation.  We can then quickly load
the manifest entry for a given directory path on demand, making us closer to our
ideal of O(what-you-use).

This diff plumbs in the manifest code from mercurial so that we can reuse
the decoder implementation to get the manfiest data and translate it into
something that we can put into our LocalStore.

There's a little wrinkle when it comes to files; mercurial doesn't support
a means for getting the file contents based on just its hash, we have to
provide the filename and revision hash for that.  We have existing code
to create proxy entries in the store to map from a proxy hash to a tuple
with the appropriate data needed to resolve the file entry.

We need to extend its use to the trees that we generate because we need
to be able to propagate that path down to a child tree when we generate
the tree entry for a file for the first time.

If a tree manifest is not available for a given revision, we fall back
to the existing implementation that parses the full flat manifest.

Note: the flat manifest import generates entries with different hashes
compared to the tree manifest hash version.  While we could make the
serialization match up, there's little risk of this causing problems
for us in practice, so punting on that for now.

Reviewed By: simpkins

Differential Revision: D4873069

fbshipit-source-id: 865001996745700586f571ed67371aed1668a6a7
2017-04-14 13:05:34 -07:00
Adam Simpkins
67a756de93 avoid multiple builds of the eden server library
Summary:
This tweaks the main.cpp and EdenServer.cpp code so that we can avoid having
separate internal and open source builds of the eden/fs/service:server library.

Only one small function is different between the two builds.  This updates the
code so that this function is only used from main.cpp, instead of being used
inside EdenServer.cpp.

Reviewed By: wez

Differential Revision: D4889721

fbshipit-source-id: 97abda92c36752516fb8a8e73b4cf50580db8d79
2017-04-14 11:39:02 -07:00
Adam Simpkins
a6ae3edab9 move eden/utils and eden/fuse into eden/fs
Summary:
This change makes it so that all of the C++ code related to the edenfs daemon
is now contained in the eden/fs subdirectory.

Reviewed By: bolinfest, wez

Differential Revision: D4889053

fbshipit-source-id: d0bd4774cc0bdb5d1d6b6f47d716ecae52391f37
2017-04-14 11:39:02 -07:00
Adam Simpkins
ce0ce6fa4e move eden/fs/cli to eden/cli
Summary:
Move the code for the command-line tool up one directory, out of eden/fs.
This better separates the code so that eden/fs contains code for the edenfs
daemon, while eden/cli contains code for the command line tool.

Reviewed By: bolinfest

Differential Revision: D4888633

fbshipit-source-id: 5041e292c5353d05122eefe5db3257289e31239a
2017-04-14 11:39:01 -07:00
Adam Simpkins
4bb5948640 fix an invalid memory access in the checkout code
Summary:
Fix a subtle crash during checkout when handling newly added entries that
already exist in the working directory: CheckoutAction passed the entry name to
checkoutUpdateEntry() as a PathComponentPiece.  However, this
PathComponentPiece could refer to the entry name owned by newScmEntry_, and it
also passed newScmEntry_ into checkoutUpdateEntry() as an rvalue reference.
As a result, if the string data was stored invalidated by the move the name
would no longer be valid when checkoutUpdateEntry() tried to use it.

This bug is triggered by doing an "hg update --clean", where a file added in
the destination commit already exists on disk, and has an entry name of 23
characters or less.  (The 23 character limit is fbstring's upper bound on
small string optimizations, where it will store the string data inline in the
object, causing it to be invalidated on move.)

This also fixes a crash in a VLOG() statement when the verbose log level for
TreeInode.cpp was set to 4 or greater.

Reviewed By: bolinfest

Differential Revision: D4882544

fbshipit-source-id: 917ede6eeae2224aaa0724b8b30324f3c3a5c924
2017-04-13 17:34:38 -07:00
Alexey Spiridonov
8d14740d20 Replace Subprocess::pipe* syntax sugar with Subprocess::Options().pipe*
Summary:
This is a bit too magical -- it's not clear that the thing produces an Options object. If you do know that you can chain further option setters off this thing, it's nice, but otherwise, the first impression is "what just happened?".

So, let's have one good way for doing things.

Reviewed By: yfeldblum

Differential Revision: D4863947

fbshipit-source-id: 3dfe83cfc077d47f604f47dcb21149fbaa2d2243
2017-04-12 14:50:22 -07:00
Jasmeet Bagga
55812e225c Use normalized names for interface port stats
Summary:
Logical ids are so 2014. We have been thinking
about emitting stats using normalized names for some time.
Approach wise, I picked the following
- If port does not have a name - default to using port ID
- In agent if a port name get set or updated. Re init BCMPort stats. Basically
this means that the moment config gets applied, we would start emitting
normalized interface stats.

Two additional pieces of work here are
i) Update interface based alerts to also look at these new normalized
interface name stats - t17052196
ii) Update cubism to look at these new names - t17052255

I won't land till at least i) is fixed

Differential Revision: D4815561

fbshipit-source-id: c088b5a8981ea40429fedc8570652c376a374be3
2017-04-11 07:08:48 -07:00
Adam Simpkins
8fcaefe6b2 implement hg reset
Summary:
Update the hg extension to implement dirstate.rebuild().  This is necessary for
the `hg reset` command.  This also now implements dirstate.setparents() for
cases when there is only one parent.

Reviewed By: wez

Differential Revision: D4823780

fbshipit-source-id: 802de006e03860995095dc3af17acb2eb05f4e8b
2017-04-06 17:50:43 -07:00
Adam Simpkins
114361df88 update the checkOutRevision() API to accept a BinaryHash
Summary:
Update the checkOutRevision() thrift API to accept the commit ID as a
BinaryHash rather than as a hexadecimal ASCII string, to make it more
consistent with our other thrift APIs.

Reviewed By: wez

Differential Revision: D4823779

fbshipit-source-id: 6226f926533ef86d60f8b1d659bc5d912e2855e6
2017-04-06 17:50:43 -07:00
Wez Furlong
acb6539f87 add .eden/client symlink
Summary:
The intent is to provide a way to locate the SNAPSHOT file
for tools that want to have a very fast way to figure out the commit
id without making any RPCs or subprocess invocations.

Reviewed By: simpkins

Differential Revision: D4824176

fbshipit-source-id: 5adca225d9984146852dad1e83de0d903848c1e5
2017-04-06 13:20:02 -07:00
Adam Simpkins
b4527fe5bb simplify InodePtr classes
Summary:
This simplifies the InodePtrImpl class by removing support for pointer-to-const
Inode objects.  We don't currently use pointer-to-const Inode objects, and I
don't really anticipate that we will ever need this.

The primary motivating factor behind this diff is a recent change in clang that
breaks the existing code: clang PR31606 prevents children classes from
inheriting template constructor instantiations from their parent which take a
reference to the parent class type as the only argument.

While this could have been fixed by explicitly defining the necessary
constructors in the child class (or simply by overriding newPtrLocked() and
newPtrFromExisting() to return the subclass type), dropping support for
pointer-to-const allows us to simplify the code and resolve this issue.

Reviewed By: wez

Differential Revision: D4825526

fbshipit-source-id: 999de352788b13818b7f23788bb34686e193cd5d
2017-04-06 13:20:01 -07:00
Wez Furlong
d32fc630f2 switch hg manifest import to two passes
Summary:
previously, the importer would read the entire manifest
and emit data to the store as it resolved complete directory entries.
The entire manifest data would be buffered and sent out to the store.

In the scenario where one subtree has been modified and a commit has
been made, only the parents of the subdirectory need to be hashed
and stored, but we would compute and try to store everything anyway.

While this diff can't avoid having to compute hashes for everything (we need
tree manifest data for that), by breaking the import into two passes we can
potentially avoid interrogating the LocalStore about every tree in the entire
manifest during an import; we only need to store the trees that are missing and
can simply cut out sub trees that are already present.

This saves us IO at the expense of buffering the manifest tree in memory
for the duration of the first pass; it is an acceptable trade off.

Reviewed By: simpkins

Differential Revision: D4832166

fbshipit-source-id: 0a40cb851c65393b407a8161db05c4b1795fb11a
2017-04-06 10:52:06 -07:00