diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-24 08:08:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-24 08:08:23 +0200 |
commit | 04ea94103db92d6d27230794e14606547aacf670 (patch) | |
tree | e6731caab1d64375e52525fd2dec8ae33cfb50d0 /bpkg/rep-create.cxx | |
parent | 69c333f31373177f6809ef4532f9c0c73a1a8148 (diff) |
Factor and reuse manifest fetching code
Diffstat (limited to 'bpkg/rep-create.cxx')
-rw-r--r-- | bpkg/rep-create.cxx | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx index 6ee0e87..8cb1827 100644 --- a/bpkg/rep-create.cxx +++ b/bpkg/rep-create.cxx @@ -12,9 +12,9 @@ #include <butl/filesystem> // dir_iterator #include <bpkg/manifest> -#include <bpkg/manifest-parser> #include <bpkg/manifest-serializer> +#include <bpkg/fetch> #include <bpkg/types> #include <bpkg/utility> #include <bpkg/diagnostics> @@ -143,33 +143,8 @@ namespace bpkg // Load the 'repositories' file to make sure it is there and // is valid. // - // @@ The same code as in rep-fetch. - // @@ Should we check for duplicates? Or should this be done at - // the manifest level? - // - path rf (d / path ("repositories")); - - if (!exists (rf)) - fail << "file " << rf << " does not exist"; - - try - { - ifstream ifs; - ifs.exceptions (ofstream::badbit | ofstream::failbit); - ifs.open (rf.string ()); - - manifest_parser mp (ifs, rf.string ()); - repository_manifests ms (mp); - level4 ([&]{trace << ms.size () - 1 << " prerequisite repository(s)";}); - } - catch (const manifest_parsing& e) - { - fail (e.name, e.line, e.column) << e.description; - } - catch (const ifstream::failure&) - { - fail << "unable to read from " << rf; - } + repository_manifests rms (fetch_repositories (d)); + level4 ([&]{trace << rms.size () - 1 << " prerequisite repository(s)";}); // While we could have serialized as we go along, the order of // packages will be pretty much random and not reproducible. By |