From 1a5ea4346a96a942d80fa6c58c6dd503a3690f99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Mar 2018 14:09:18 +0200 Subject: Add --no-fetch option for pkg-build --- bpkg/pkg-build.cxx | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 94d4a4d..4621fb9 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -1163,45 +1163,50 @@ namespace bpkg // the same canonical name. // strings args; - vector locations; { + vector locations; + transaction t (db.begin ()); while (a.more ()) { string arg (a.next ()); - size_t p (find_location (arg)); - if (p != string::npos) + if (!o.no_fetch ()) { - repository_location l (location (string (arg, p))); + size_t p (find_location (arg)); - auto pr = [&l] (const repository_location& i) -> bool + if (p != string::npos) { - return i.canonical_name () == l.canonical_name (); - }; + repository_location l (location (string (arg, p))); - auto i (find_if (locations.begin (), locations.end (), pr)); + auto pr = [&l] (const repository_location& i) -> bool + { + return i.canonical_name () == l.canonical_name (); + }; - if (i != locations.end ()) - *i = move (l); - else - locations.push_back (move (l)); + auto i (find_if (locations.begin (), locations.end (), pr)); + + if (i != locations.end ()) + *i = move (l); + else + locations.push_back (move (l)); + } } args.push_back (move (arg)); } t.commit (); - } - if (!locations.empty ()) - rep_fetch (o, - c, - db, - locations, - o.fetch_shallow (), - string () /* reason for "fetching ..." */); + if (!locations.empty ()) + rep_fetch (o, + c, + db, + locations, + o.fetch_shallow (), + string () /* reason for "fetching ..." */); + } // Expand @ arguments. // -- cgit v1.1