utils: add executable for reading from datapack files

Summary:
Useful for debugging the rust code. I used it to isolate
a bug in the delta patching logic in the rust code.

(Note: this ignores all push blocking failures!)

Reviewed By: xavierd

Differential Revision: D15380387

fbshipit-source-id: 5980d352b85ee4836bd654045eda2eae131e5847
This commit is contained in:
Stefan Filip 2019-05-17 10:20:17 -07:00 committed by Facebook Github Bot
parent bf10b4c037
commit d0aaaeffe2

View File

@ -0,0 +1,30 @@
// Copyright 2019 Facebook, Inc.
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
use std::path::PathBuf;
use structopt::StructOpt;
use revisionstore::{datapack::DataPack, datastore::DataStore, uniondatastore::UnionDataStore};
use types::{Key, Node, RepoPathBuf};
#[derive(StructOpt)]
struct Cli {
#[structopt(short = "n", parse(try_from_str = "Node::from_str"))]
node: Node,
#[structopt(short = "p")]
path: PathBuf,
}
fn main() {
let args = Cli::from_args();
let pack = DataPack::new(&args.path).unwrap();
let mut store = UnionDataStore::new();
store.add(pack);
let key = Key::new(RepoPathBuf::new(), args.node);
let result = store.get(&key).unwrap();
println!("{:?}", String::from_utf8_lossy(&result));
}