Commit Graph

152 Commits

Author SHA1 Message Date
cmasone-attic
f2ca3d6e8e Add noms merge (#2768)
Add optional merging functionality to noms commit.
noms merge <database> <left-dataset-name> <right-dataset-name> <output-dataset-name>

The command above will look in the given Database for the two named
Datasets and, if possible, merge their HeadValue()s and commit the
result back to <output-dataset-name>.

Fixes #2535
2016-10-27 15:27:36 -07:00
Erik Arvidsson
0eb940e50a First cut at noms migrate (#2594)
This iterates over all the values of the old version and creates new
values of the new version.

Closes #2428
Fixes #2272
2016-10-21 15:16:29 -07:00
Dan Willhite
d94fb97788 Move diff package to top-level go directory (#2739)
Towards #609.
2016-10-20 10:19:57 -07:00
Dan Willhite
e1e143a27a Extract print functionality from Diff function. (#2722)
The Diff function now returns Difference objects that can be
used in different contexts (e.g. print_diff)

Towards #609
2016-10-19 16:44:37 -07:00
Erik Arvidsson
e164f8aeec Flow header after copyright (#2734)
This puts the flow header after the copyright header.

It also:
 * fixes the existing files to have valid headers
 * Makes sure the script can handle doctype
2016-10-19 11:36:48 -07:00
cmasone-attic
c9c1bb9ff5 Add concurrency to use of ValidatingBatchingSink (#2684)
There are two places where ValidatingBatchingSink could be more
concurrent: Prepare(), where it's reading in hints, and Enqueue().

Making Prepare() handle many hints concurrently is easy because the
hints don't depend on one another, so that method now just spins up
a number of goroutines and runs them all at once.

Enqueue() is more complex, because while Chunk decoding and validation
of its hash can proceed concurrently, validating that a given Chunk is
'ref-complete' requires that the chunks in the writeValue payload all
be processed in order. So, this patch uses orderedparallel to run the
new Decode() method on chunks in parallel, but then return to serial
operation before calling the modified Enqueue() method.

Fixes #1935
2016-10-10 15:33:35 -07:00
Eric Halpern
d9715dba0e Support db aliases and default db for noms cli
This patch implements evolving support for configuring aliases and defaults for the noms cli (started with #2131)

For an introduction, please take a look at the sample code here: https://github.com/attic-labs/noms/blob/master/samples/cli/nomsconfig/README.md

Improvements include: 

 - All go samples now work with .nomsconfig
 - Absolute paths in ldb specs are now properly handled 
 - Add -v|--verbose flag to commands to debug expansion
 - Make default just another alias and change [default] section to [db.default]
 - Introduce the `.` shorthand to refer to a previously mentioned dataset/object
2016-09-27 22:21:32 -07:00
cmasone-attic
c250406a0e LocalDatabase vends separate validating BatchStore (#2624)
This patch modifies LocalDatabase so that it no longer swaps out
its embedded ValueStore during Pull(). The reason it was doing this
is that Pull() injects chunks directly into a Database, without
doing any work on its own to ensure correctness. For LocalDatabase,
WriteValue() performs de-facto validation as it goes, so it does not
need this additional validation in the general case. To address the
former wtithout impacting the latter, we were making LocalDatabase
swap out its ValueStore() during Pull(), replacing it with one that
performs validation.

This led to inconsistencies, seen in issue #2598. Collections read
from the DB _before_ this swap could have weird behavior if they
were modified and written after this swap.

The new code just lazily creates a BatchStore for use during Pull().

Fixes #2598
2016-09-27 14:24:57 -07:00
Aaron Boodman
e52775f838 Refactor exit mockery into go/util/exit (#2622) 2016-09-27 13:51:27 -07:00
cmasone-attic
2e462b11a5 Make Database a mutable API that vends immutable Datasets (#2617)
Noms SDK users frequently shoot themselves in the foot because they're
holding onto an "old" Database object. That is, they have a Database
tucked away in some internal state, they call Commit() on it, and
don't replace the object in their internal state with the new Database
returned from Commit.

This PR changes the Database and Dataset Go API to be in line with the
proposal in Issue #2589. JS follows in a separate patch.
2016-09-26 12:18:14 -07:00
Eric Halpern
e3e9b29d2c Noms configuration for default and aliases (#2597)
* Implement noms cli configuration support

- Introduce .nomsconfig
- Supports a default db to use when no explicit db is given
- Supports defining db aliases to use as short hand for db urls
- See samples/cli/nomsconfig for more info

fix: #2131
2016-09-21 19:43:51 -07:00
Eric Halpern
27cbfdd489 Fix noms-sync surprising quantity (#2531)
* Use sampling for a better bytes-written estimate for noms sync
* Confirmed that remaining overestimate of data written is consistent with leveldb stats and opened #2567 to track
2016-09-20 10:57:40 -07:00
Dan Willhite
1a7bfd0627 Cleanup Prefix and MaxLine writers (#2591)
These were previously intertwined into one writer that was
embedded in and only usable by the 'noms' command.
This commit separates them into to separate writers that
can be used independently or combined. I also moved them
into go/utils/writers so they can be used by other code.

The main impetus to do this was to fix Bug #2593.
2016-09-20 10:31:16 -07:00
Dan Willhite
ce763cb704 Fix test so temp db is cleaned up (#2546) 2016-09-12 15:14:48 -07:00
Adam Leventhal
df677ad0b4 noms diff should exit after the pager exits (#2526) 2016-09-09 21:46:00 -07:00
Mike Gray
1996e0a3d8 Add Noms commit command (#2474)
* Add "noms commit" command
* Updated csv-import, json-import, xml-import and url-fetch to (optionally) not commit results
* Added helpers for creating commit meta-data struct through command line or function calls
2016-09-09 12:42:27 -04:00
zcstarr
65131432c7 Fix cmdline help message color argument (#2520) 2016-09-06 14:59:01 -07:00
Mike Gray
47565f39d1 Improve code based on tool analysis feeback (#2521)
Fixes are based on Go report card output:
- `gofmt -s` eliminates some duplication in struct/slice initialization
- `golint` found some issues like: `warning: should drop = nil from declaration of var XXX; it is the zero value`
- `golint` found some issues like: `warning: receiver name XXX should be consistent with previous receiver name YYY for ZZZ`
- `golint` says not to use underscores for function/variable names
- `golint` found several issues like: `warning: if block ends with a return statement, so drop this else and outdent its block`

No functional changes are included - just source code quality improvements.
2016-09-06 16:35:25 -04:00
zcstarr
3cdebb7e77 Add run safe method that reads stderr and stdout regardless of panic (#2475)
Run method will now always return stdout,stderr, and a recoveredErr
on Exit or Panic. MustRun will Panic with recoveredErr.
2016-09-06 11:30:57 -07:00
Mike Gray
4e54c44d56 no functional changes, improving code quality (#2410)
fix misspellings; fix code that was not gofmt'd - plus take advantage of gofmt -s too; couple of unreachable golint reported fixes; reference go report card results and tests
2016-08-23 13:51:38 -04:00
Ben Kalman
8a92b75995 Add missing ==nil check to list diff (#2362)
This isn't triggering any problem in particular, I just noticed it. All
it meant was that noms log might take unnecessarily long with list diff
when there are a lot of changes.
2016-08-17 14:44:21 -07:00
Ben Kalman
a28f5ddaf9 Render diff struct field paths .foo not ["foo"] (#2379) 2016-08-16 15:28:47 -07:00
Ben Kalman
9079b83927 Use best set/map diff in noms diff (#2372)
In 7c103344 I changed noms log to use left-right diff so that it
completes faster, but it changed noms diff to use left-right as well.
Noms diff is supposed to use best diff.
2016-08-15 17:15:12 -07:00
Ben Kalman
da62bb2b97 Remove most references to ldb: prefix in the .md docs (#2360) 2016-08-12 15:51:25 -07:00
Eric Halpern
c5ccae3852 Fix noms_sync status message to indicate when new dataset is created (#2276)
* Fix noms_sync status message to indicate when new dataset is created

Originally, syncing a commit to a non-existent dataset and an already sync'ed dataset resulted in the same message: "<src> is up to date"

This fix distinguishes 2 cases:

  - Syncing to a new dataset prints "<dest> created"

  - Syncing to an identical dataset prints "<dest> already up to date"

Resolves: #2053

* Make message when noms sync creates new dataset more fun

Addresses: #2053
2016-08-11 16:17:15 -07:00
Sungguk Lim
6697c2e6fc Replace github.com/tsuru/gnuflag with github.com/juju/gnuflag (#2340)
Replace vendor folder and where it is used.
2016-08-11 10:29:57 -07:00
Dan Willhite
deb4d2ac0c Factor out noms Command and Help so they are reusable. 2016-08-08 14:08:29 -07:00
cmasone-attic
65edbaabe3 Allow Dataset HEAD to be set to non-fastforward commits (#2271)
The Dataset.Commit() code pathway still enforces fast-forward-only
behavior, but a new SetHead() method allows the HEAD of a Dataset to
be forced to any other Commit.

noms sync detects the case where the source Commit is not a descendent
of the provided sink Dataset's HEAD and uses the new API to force the
sink to the desired new Commit, printing out the now-abandoned old
HEAD.

Fixes #2240
2016-08-05 15:38:41 -07:00
Ben Kalman
fd034f8c81 Simplify Path construction in Go (#2262)
Previously there were 3 ways to construct a Path: via methods like
AddIndex, via parsing/AddPath, and simply via using append() (since Path
is a slice).

This patch deletes the former and leaves only ParsePath and append(),
with the ability to manually create the various path parts (I've made
them public). I also added documentation for the public types/fields.
2016-08-05 15:16:04 -07:00
Ben Kalman
c386725d4e Fix struct diff (#2281)
It inverted the added/removed order.
Fixes https://github.com/attic-labs/noms/issues/2278.
2016-08-04 16:11:11 -07:00
Ben Kalman
02f7e9556c Tweak "Deleted dataset..." message (#2255)
It (a) had a spurious blank line, (b) should print the dataset path not
just its ID, (c) should include the # for the hash. Now it says:
```
> noms ds -d path/to/db::my-dataset
Deleted path/to/db::my-dataset (was #lvnbmpj94r9h3nuaj1t0m4jeqp25o1ve)
>
```
2016-08-02 18:22:20 -07:00
Ben Kalman
7c10334472 Make sure that set/map diff has completed before returning from noms log (#2249)
This fixes https://github.com/attic-labs/noms/issues/2235 where set/map
diff was still running when noms log has finished, and already closed
its database. Commonly this would crash.

I've removed panic-based control flow to make error handling explicit,
and added a "DiffLeftRight" method to set/map so that noms log completes
ASAP. See the issue for details.
2016-08-02 18:14:09 -07:00
Dan Willhite
e4266a0d3b Add test 2016-08-01 15:30:25 -07:00
Dan Willhite
8d09fd770b Fix noms log output when --online is used. Fixes #2150 2016-08-01 14:19:09 -07:00
Erik Arvidsson
93e56eb4c2 Handle Blob and Ref in noms diff (#2216)
For Blobs we print:

```
-   Blob (42 kB)
+   Blob (1 B)
```

For Refs we just print the hashes:

```
-   abcdeabcdeabcdeabcde
+   defghdefghdefghdefgh
```

Fixes #2213
2016-08-01 09:34:39 -07:00
Mike Gray
93916c5139 exposing StructData, updating tour (#2214) 2016-08-01 12:09:02 -04:00
Adam Leventhal
e920c12c1c Fix cyclic type nondeterminism (#2147) (#2148) 2016-07-29 21:35:17 -07:00
Erik Arvidsson
ed0364cc19 Switch to gnuflag (#2206)
This is to support:
- shorthands
- Putting commands anywhere (after positional arguments too)
2016-07-29 18:08:23 -07:00
Ben Kalman
1db33d33f8 Use correct first arg when printing "up to date" in noms sync (#2200) 2016-07-29 11:39:31 -07:00
Erik Arvidsson
dba9e5584b Print percentages in diff summary (#2195)
For example:

```
0 insertions (0.00%), 5,405 deletions (0.28%), 45 changes (0.00%), (1,938,935 entries vs 1,933,530 entries)
```

Fixes #2194
Towards #2031
2016-07-28 18:04:33 -07:00
Ben Kalman
b2096234fd Make the output pager close the pipes it creates (#2187)
This makes less exit properly - before, it wasn't properly restoring the
terminal sometimes, and keyboard input stopped working.
Fixes https://github.com/attic-labs/noms/issues/2180.
2016-07-28 17:55:18 -07:00
Ben Kalman
6d2710a04e Simplify the channel logic in diff.go/summary.go (#2190)
Earlier I'd used 2 channels and selected over them, but as I found
elsewhere, this doesn't scale very well. It's simpler to just use a
close channel with a buffer size of 1.
2016-07-28 17:44:20 -07:00
Erik Arvidsson
26b94cf816 Minor cleanup of noms diff code (#2191) 2016-07-28 16:55:37 -07:00
Erik Arvidsson
b20bec9b23 noms diff --summarize (#2183)
Shows number of changes between two top level values.

```
noms diff -summarize $l::#t5p4im6uug7n5m72frr0dnjnkm04e4ph.value $l::#ueo0utduuqsf9vrntrhn25lnc19m848l.value
```

Prints:

```
13,636 insertions, 0 deletions, 107 changes, (1,919,894 values vs 1,933,530 values)
```

Where the numbers are updated as more data is computed from the diff.

Towards #2031
2016-07-28 15:01:27 -07:00
Ben Kalman
8330f3b7f3 Print closing brace for struct diff (#2178) 2016-07-27 17:36:14 -07:00
Ben Kalman
7998f302be Don't quote struct field names in diff (#2177) 2016-07-27 16:14:35 -07:00
Erik Arvidsson
b0e77c250c Cleanup Struct Diff (#2160)
- Too have same API as all the other diff methods
- Send changes to channel without intermediary slices and without the
need to union and sort the fields
2016-07-27 14:56:22 -07:00
Ben Kalman
57bd3d2540 Make map diff print headers for each block of additions/deletions (#2166)
Previously a header was only printed once per entire map. This led to a
confusing diff where if a map like:

```
{
  "a": {
    "b": 1
  }
}
```

changed to:

```
{
  "a": {
    "b": 2
  },
  "c": {
    "d": 3
  }
}
```

then the diff would be:

```
/["a"]
- "b": 1
+ "b": 2
+ "c": {
+   "d": 3
+ }
```

which makes it look like the "c" change is part of the ["a"]["b"] one.

After this change, the diff will be:

```
/["a"]
- "b": 1
+ "b": 2
/
+ "c": {
+   "d": 3
+ }
```

I also fixed up a bit of the diff formatting in this change.
2016-07-26 16:48:33 -07:00
Rafael Weinstein
b57377c1ed Chunk over value (non-type) serialization bytes (#2130)
Chunk over value (non-type) serialization bytes
2016-07-25 11:02:26 -07:00
Dan Willhite
c12402668a Treat diffing of structs of different types, like maps. (#2062) 2016-07-22 14:49:51 -07:00