Skip to content

[v1.40.0] Remove code deprecated in v1.30.0 #2924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fc1711a
Remove deprecated override system
Geod24 Jun 3, 2024
63fe80d
Remove deprecated PackageManager.getLatestPackage
Geod24 Jun 5, 2024
2074d61
Remove Dependency : Repository related deprecations
Geod24 Jun 5, 2024
65ba191
Remove deprecated SelectedVersions Json constructor
Geod24 Jun 5, 2024
c85a46a
Remove deprecated PackageManager.loadSCMPackage(string, Dependency)
Geod24 Jun 5, 2024
8cf5ffe
Remove deprecated Project.dependencyToJson
Geod24 Jun 5, 2024
e2fdbda
Remove deprecated Dub.remove(pack, bool)
Geod24 Jun 5, 2024
0cd0675
Remove deprecation project : PlacementLocation alias
Geod24 Jun 5, 2024
189d4f5
Remove deprecated selections JSON deserialization functions
Geod24 Jun 5, 2024
8898c1c
Remove deprecated DependencyResolver constructor
Geod24 Jun 5, 2024
2a81349
Error our on invalid settings / selections file
Geod24 Jun 5, 2024
2a0b04c
Remove deprecated enum LocalPackageType
Geod24 Jun 5, 2024
e0e7209
Remove deprecated Dependency.matchesAny
Geod24 Jun 5, 2024
6b8726d
Remove deprecated dub.remove overload
Geod24 Jun 5, 2024
d9c2355
Remove deprecated Dependency.versionSpec
Geod24 Jun 5, 2024
fd7830d
Remove deprecated Dub.fetch with Dependency
Geod24 Jun 5, 2024
d64cc26
Remove deprecated Dub.getPackageSuppliers
Geod24 Jun 5, 2024
0db33e3
Remove deprecated PackageManaget.getPackage version string overloads
Geod24 Jun 5, 2024
855cd2d
Remove deprecated Dependency.path and repository setters
Geod24 Jun 5, 2024
a645511
Error out on invalid dub.json file
Geod24 Jun 5, 2024
b82ec23
Remove deprecated PackageManager.getFirstPackage
Geod24 Jun 5, 2024
0248cbb
Remove deprecated PackageManager.getPackage(string, NativePath)
Geod24 Jun 5, 2024
0ca27a9
Remove PackageManager.completeSearchPath
Geod24 Jun 5, 2024
9cd7640
Remove deprecated PackageManager.getPackage overload
Geod24 Jun 5, 2024
3558335
Remove deprecated PackageManager.storeFetchedPackage
Geod24 Jun 5, 2024
6d4fb1a
Dub: Remove the ability to change the rootpath
Geod24 Jun 5, 2024
6e5e4c9
Remove deprecated BuildOptions / BuildRequirements aliases
Geod24 Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/removed_overrides.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The override system has been removed

The override system was deprecated in v1.30.0 as it was neither
widely used nor generally useful given Dub's available feature set.
With this release, it is now completely removed.

This means that the commands `add-override`, `remove-override`,
`list-override`, and the interaction with `local-overrides.json`
have been removed, along with all the associated APIs.
122 changes: 1 addition & 121 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
@@ -67,9 +67,6 @@ CommandGroup[] getCommands() @safe pure nothrow
new RemoveLocalCommand,
new ListCommand,
new SearchCommand,
new AddOverrideCommand,
new RemoveOverrideCommand,
new ListOverridesCommand,
new CleanCachesCommand,
new ConvertCommand,
)
@@ -272,7 +269,7 @@ unittest {
assert(handler.commandNames == ["init", "run", "build", "test", "lint", "generate",
"describe", "clean", "dustmite", "fetch", "add", "remove",
"upgrade", "add-path", "remove-path", "add-local", "remove-local", "list", "search",
"add-override", "remove-override", "list-overrides", "clean-caches", "convert"]);
"clean-caches", "convert"]);
}

/// It sets the cwd as root_path by default
@@ -2561,123 +2558,6 @@ class SearchCommand : Command {
}
}


/******************************************************************************/
/* OVERRIDES */
/******************************************************************************/

class AddOverrideCommand : Command {
private {
bool m_system = false;
}

static immutable string DeprecationMessage =
"This command is deprecated. Use path based dependency, custom cache path, " ~
"or edit `dub.selections.json` to achieve the same results.";


this() @safe pure nothrow
{
this.name = "add-override";
this.argumentsPattern = "<package> <version-spec> <target-path/target-version>";
this.description = "Adds a new package override.";

this.hidden = true;
this.helpText = [ DeprecationMessage ];
}

override void prepare(scope CommandArgs args)
{
args.getopt("system", &m_system, [
"Register system-wide instead of user-wide"
]);
}

override int execute(Dub dub, string[] free_args, string[] app_args)
{
logWarn(DeprecationMessage);
enforceUsage(app_args.length == 0, "Unexpected application arguments.");
enforceUsage(free_args.length == 3, "Expected three arguments, not "~free_args.length.to!string);
auto scope_ = m_system ? PlacementLocation.system : PlacementLocation.user;
auto pack = free_args[0];
auto source = VersionRange.fromString(free_args[1]);
if (existsFile(NativePath(free_args[2]))) {
auto target = NativePath(free_args[2]);
if (!target.absolute) target = getWorkingDirectory() ~ target;
dub.packageManager.addOverride_(scope_, pack, source, target);
logInfo("Added override %s %s => %s", pack, source, target);
} else {
auto target = Version(free_args[2]);
dub.packageManager.addOverride_(scope_, pack, source, target);
logInfo("Added override %s %s => %s", pack, source, target);
}
return 0;
}
}

class RemoveOverrideCommand : Command {
private {
bool m_system = false;
}

this() @safe pure nothrow
{
this.name = "remove-override";
this.argumentsPattern = "<package> <version-spec>";
this.description = "Removes an existing package override.";

this.hidden = true;
this.helpText = [ AddOverrideCommand.DeprecationMessage ];
}

override void prepare(scope CommandArgs args)
{
args.getopt("system", &m_system, [
"Register system-wide instead of user-wide"
]);
}

override int execute(Dub dub, string[] free_args, string[] app_args)
{
logWarn(AddOverrideCommand.DeprecationMessage);
enforceUsage(app_args.length == 0, "Unexpected application arguments.");
enforceUsage(free_args.length == 2, "Expected two arguments, not "~free_args.length.to!string);
auto scope_ = m_system ? PlacementLocation.system : PlacementLocation.user;
auto source = VersionRange.fromString(free_args[1]);
dub.packageManager.removeOverride_(scope_, free_args[0], source);
return 0;
}
}

class ListOverridesCommand : Command {
this() @safe pure nothrow
{
this.name = "list-overrides";
this.argumentsPattern = "";
this.description = "Prints a list of all local package overrides";

this.hidden = true;
this.helpText = [ AddOverrideCommand.DeprecationMessage ];
}
override void prepare(scope CommandArgs args) {}
override int execute(Dub dub, string[] free_args, string[] app_args)
{
logWarn(AddOverrideCommand.DeprecationMessage);

void printList(in PackageOverride_[] overrides, string caption)
{
if (overrides.length == 0) return;
logInfoNoTag("# %s", caption);
foreach (ovr; overrides)
ovr.target.match!(
t => logInfoNoTag("%s %s => %s", ovr.package_.color(Mode.bold), ovr.source, t));
}
printList(dub.packageManager.getOverrides_(PlacementLocation.user), "User wide overrides");
printList(dub.packageManager.getOverrides_(PlacementLocation.system), "System wide overrides");
return 0;
}
}

/******************************************************************************/
/* Cache cleanup */
/******************************************************************************/
6 changes: 0 additions & 6 deletions source/dub/compilers/buildsettings.d
Original file line number Diff line number Diff line change
@@ -528,9 +528,3 @@ enum Flags!BuildOption inheritedBuildOptions =
| BuildOption.ignoreDeprecations | BuildOption.deprecationWarnings
| BuildOption.deprecationErrors | BuildOption.property | BuildOption.profileGC
| BuildOption.pic;

deprecated("Use `Flags!BuildOption` instead")
public alias BuildOptions = Flags!BuildOption;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value of deprecating/removing something like this? IMO, it makes code easier to read and also keeps a door open for backwards compatible adjustments of the exact type (exactly like what was happening in the mentioned original commit).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My usual approach is to avoid those kind of trivial aliases as they harm composability. In this instance there's not a strong case to deprecate / remove it in hindsight, but this has been deprecated for over 2 years without a comment so I assume either no one use it, or it isn't a problem. I assumed most people were using the field directly from the recipe, not so much the type itself.


deprecated("Use `Flags!BuildRequirement` instead")
public alias BuildRequirements = Flags!BuildRequirement;
67 changes: 3 additions & 64 deletions source/dub/dependency.d
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ struct Dependency {

/** Constructs a new dependency specification from a string
See the `versionSpec` property for a description of the accepted
See the `VersionRange` type for a description of the accepted
contents of that string.
*/
this(string spec) @safe
@@ -188,21 +188,7 @@ struct Dependency {
this.m_value = rng;
}

deprecated("Instantiate the `Repository` struct with the string directly")
this(Repository repository, string spec) @safe
{
assert(repository.m_ref is null);
repository.m_ref = spec;
this(repository);
}

/// If set, overrides any version based dependency selection.
deprecated("Construct a new `Dependency` object instead")
@property void path(NativePath value) @trusted
{
this.m_value = value;
}
/// ditto
/// The path this `Dependency` matches, or `NativePath.init`
@property NativePath path() const @safe
{
return this.m_value.match!(
@@ -211,13 +197,7 @@ struct Dependency {
);
}

/// If set, overrides any version based dependency selection.
deprecated("Construct a new `Dependency` object instead")
@property void repository(Repository value) @trusted
{
this.m_value = value;
}
/// ditto
/// The repository this `Dependency` matches, or `Repository.init`
@property Repository repository() const @safe
{
return this.m_value.match!(
@@ -271,23 +251,6 @@ struct Dependency {
return range.m_versA;
}

/// Sets/gets the matching version range as a specification string.
deprecated("Create a new `Dependency` instead and provide a `VersionRange`")
@property void versionSpec(string ves) @trusted
{
this.m_value = VersionRange.fromString(ves);
}

/// ditto
deprecated("Use `Dependency.visit` and match `VersionRange`instead")
@property string versionSpec() const @safe {
return this.m_value.match!(
(const NativePath p) => ANY_IDENT,
(const Repository r) => r.m_ref,
(const VersionRange p) => p.toString(),
);
}

/** Returns a modified dependency that gets mapped to a given path.
This function will return an unmodified `Dependency` if it is not path
@@ -485,19 +448,6 @@ struct Dependency {
);
}

/** Determines if this dependency specification matches arbitrary versions.
This is true in particular for the `any` constant.
*/
deprecated("Use `VersionRange.matchesAny` directly")
bool matchesAny() const scope @safe {
return this.m_value.match!(
(NativePath v) => true,
(Repository v) => true,
(VersionRange v) => v.matchesAny(),
);
}

/** Tests if the specification matches a specific version.
*/
bool matches(string vers, VersionMatchMode mode = VersionMatchMode.standard) const @safe
@@ -767,17 +717,6 @@ struct Repository
assert(m_ref.length);
}

/// Ditto
deprecated("Use the constructor accepting a second parameter named `ref_`")
this(string remote)
{
enforce(remote.startsWith("git+"), "Unsupported repository type (supports: git+URL)");

m_remote = remote["git+".length .. $];
m_kind = Kind.git;
assert(m_remote.length);
}

string toString() const nothrow pure @safe
{
if (empty) return null;
12 changes: 0 additions & 12 deletions source/dub/dependencyresolver.d
Original file line number Diff line number Diff line change
@@ -43,18 +43,6 @@ class DependencyResolver(CONFIGS, CONFIG) {
this.loop_limit = limit;
}

/// Compatibility overload
deprecated("Use the overload that accepts a `ulong limit` argument")
public this () scope @safe
{
// Leave the possibility to opt-out from the loop limit
import std.process : environment;
if (environment.get("DUB_NO_RESOLVE_LIMIT") !is null)
this(ulong.max);
else
this(1_000_000);
}

/** Encapsulates a list of outgoing edges in the dependency graph.
A value of this type represents a single dependency with multiple
63 changes: 2 additions & 61 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
@@ -206,12 +206,6 @@ class Dub {
m_packageManager = new PackageManager(pkg_root);
}

deprecated("Use the overload that takes `(NativePath pkg_root, NativePath root)`")
this(NativePath pkg_root)
{
this(pkg_root, pkg_root);
}

/**
* Get the `PackageManager` instance to use for this `Dub` instance
*
@@ -255,12 +249,9 @@ class Dub {

static void readSettingsFile (NativePath path_, ref Settings current)
{
// TODO: Remove `StrictMode.Warn` after v1.40 release
// The default is to error, but as the previous parser wasn't
// complaining, we should first warn the user.
const path = path_.toNativeString();
if (path.exists) {
auto newConf = parseConfigFileSimple!Settings(path, StrictMode.Warn);
auto newConf = parseConfigFileSimple!Settings(path);
if (!newConf.isNull())
current = current.merge(newConf.get());
}
@@ -326,21 +317,12 @@ class Dub {
/** Get the list of package suppliers.
Params:
additional_package_suppliers = A list of package suppliers to try
base = A list of package suppliers to try
before the suppliers found in the configurations files and the
`defaultPackageSuppliers`.
skip = Can be used to skip using the configured package suppliers,
as well as the default suppliers.
*/
deprecated("This is an implementation detail. " ~
"Use `packageSuppliers` to get the computed list of package " ~
"suppliers once a `Dub` instance has been constructed.")
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] base, SkipPackageSuppliers skip)
{
return this.makePackageSuppliers(base, skip, environment.get("DUB_REGISTRY", null));
}

/// Ditto
protected PackageSupplier[] makePackageSuppliers(PackageSupplier[] base,
SkipPackageSuppliers skip, string registry_var)
{
@@ -423,29 +405,12 @@ class Dub {
}
}

/// ditto
deprecated("This is an implementation detail. " ~
"Use `packageSuppliers` to get the computed list of package " ~
"suppliers once a `Dub` instance has been constructed.")
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] additional_package_suppliers)
{
return getPackageSuppliers(additional_package_suppliers, m_config.skipRegistry);
}

@property bool dryRun() const { return m_dryRun; }
@property void dryRun(bool v) { m_dryRun = v; }

/** Returns the root path (usually the current working directory).
*/
@property NativePath rootPath() const { return m_rootPath; }
/// ditto
deprecated("Changing the root path is deprecated as it has non-obvious pitfalls " ~
"(e.g. settings aren't reloaded). Instantiate a new `Dub` instead")
@property void rootPath(NativePath root_path)
{
m_rootPath = root_path;
if (!m_rootPath.absolute) m_rootPath = getWorkingDirectory() ~ m_rootPath;
}

/// Returns the name listed in the dub.json of the current
/// application.
@@ -897,16 +862,6 @@ class Dub {
rmdirRecurse(cache.toNativeString());
}

deprecated("Use the overload that accepts either a `Version` or a `VersionRange` as second argument")
Package fetch(string packageId, const Dependency dep, PlacementLocation location, FetchOptions options, string reason = "")
{
const vrange = dep.visit!(
(VersionRange range) => range,
function VersionRange (any) { throw new Exception("Cannot call `dub.fetch` with a " ~ typeof(any).stringof ~ " dependency"); }
);
return this.fetch(packageId, vrange, location, options, reason);
}

deprecated("Use `fetch(PackageName, Version, [FetchOptions, PlacementLocation, string])`")
Package fetch(string name, in Version vers, PlacementLocation location, FetchOptions options, string reason = "")
{
@@ -1058,13 +1013,6 @@ class Dub {
if (!m_dryRun) m_packageManager.remove(pack);
}

/// Compatibility overload. Use the version without a `force_remove` argument instead.
deprecated("Use `remove(pack)` directly instead, the boolean has no effect")
void remove(in Package pack, bool force_remove)
{
remove(pack);
}

/// @see remove(string, string, RemoveLocation)
enum RemoveVersionWildcard = "*";

@@ -1170,13 +1118,6 @@ class Dub {
this.remove(PackageName(name), version_, location);
}

/// Compatibility overload. Use the version without a `force_remove` argument instead.
deprecated("Use the overload without force_remove instead")
void remove(string package_id, string version_, PlacementLocation location, bool force_remove)
{
remove(package_id, version_, location);
}

/** Adds a directory to the list of locally known packages.
Forwards to `PackageManager.addLocalPackage`.
364 changes: 8 additions & 356 deletions source/dub/packagemanager.d

Large diffs are not rendered by default.

63 changes: 0 additions & 63 deletions source/dub/project.d
Original file line number Diff line number Diff line change
@@ -1437,9 +1437,6 @@ enum ListBuildSettingsFormat {
commandLineNul, /// NUL character separated list entries (unescaped, data lists separated by two NUL characters)
}

deprecated("Use `dub.packagemanager : PlacementLocation` instead")
public alias PlacementLocation = dub.packagemanager.PlacementLocation;

void processVars(ref BuildSettings dst, in Project project, in Package pack,
BuildSettings settings, in GeneratorSettings gsettings, bool include_target_settings = false)
{
@@ -1874,29 +1871,6 @@ public class SelectedVersions {
this.m_bare = false;
}

/** Constructs a new version selection from JSON data.
The structure of the JSON document must match the contents of the
"dub.selections.json" file.
*/
deprecated("Pass a `dub.recipe.selection : Selected` directly")
this(Json data)
{
deserialize(data);
m_dirty = false;
}

/** Constructs a new version selections from an existing JSON file.
*/
deprecated("JSON deserialization is deprecated")
this(NativePath path)
{
auto json = jsonFromFile(path);
deserialize(json);
m_dirty = false;
m_bare = false;
}

/// Returns a list of names for all packages that have a version selection.
@property string[] selectedPackages() const { return m_selections.versions.keys; }

@@ -1977,12 +1951,6 @@ public class SelectedVersions {
m_dirty = true;
}

deprecated("Move `spec` inside of the `repository` parameter and call `selectVersion`")
void selectVersionWithRepository(string package_id, Repository repository, string spec)
{
this.selectVersion(package_id, Repository(repository.remote(), spec));
}

/// Removes the selection for a particular package.
deprecated("Use the overload that accepts a `PackageName`")
void deselectVersion(string package_id)
@@ -2046,41 +2014,10 @@ public class SelectedVersions {
m_bare = false;
}

deprecated("Use `dub.dependency : Dependency.toJson(true)`")
static Json dependencyToJson(Dependency d)
{
return d.toJson(true);
}

deprecated("JSON deserialization is deprecated")
static Dependency dependencyFromJson(Json j)
{
if (j.type == Json.Type.string)
return Dependency(Version(j.get!string));
else if (j.type == Json.Type.object && "path" in j)
return Dependency(NativePath(j["path"].get!string));
else if (j.type == Json.Type.object && "repository" in j)
return Dependency(Repository(j["repository"].get!string,
enforce("version" in j, "Expected \"version\" field in repository version object").get!string));
else throw new Exception(format("Unexpected type for dependency: %s", j));
}

deprecated("JSON serialization is deprecated")
Json serialize() const {
return PackageManager.selectionsToJSON(this.m_selections);
}

deprecated("JSON deserialization is deprecated")
private void deserialize(Json json)
{
const fileVersion = json["fileVersion"].get!int;
enforce(fileVersion == FileVersion, "Mismatched dub.selections.json version: " ~ to!string(fileVersion) ~ " vs. " ~ to!string(FileVersion));
clear();
m_selections.fileVersion = fileVersion;
scope(failure) clear();
foreach (string p, dep; json["versions"])
m_selections.versions[p] = dependencyFromJson(dep);
}
}

/// The template code from which the test runner is generated
41 changes: 2 additions & 39 deletions source/dub/recipe/io.d
Original file line number Diff line number Diff line change
@@ -83,8 +83,6 @@ PackageRecipe parsePackageRecipe(string contents, string filename,
{
import std.algorithm : endsWith;
import dub.compilers.buildsettings : TargetType;
import dub.internal.vibecompat.data.json;
import dub.recipe.json : parseJson;
import dub.recipe.sdl : parseSDL;

PackageRecipe ret;
@@ -93,43 +91,8 @@ PackageRecipe parsePackageRecipe(string contents, string filename,

if (filename.endsWith(".json"))
{
try {
ret = parseConfigString!PackageRecipe(contents, filename, mode);
fixDependenciesNames(ret.name, ret);
} catch (ConfigException exc) {
logWarn("Your `dub.json` file use non-conventional features that are deprecated");
logWarn("Please adjust your `dub.json` file as those warnings will turn into errors in dub v1.40.0");
logWarn("Error was: %s", exc);
// Fallback to JSON parser
ret = PackageRecipe.init;
parseJson(ret, parseJsonString(contents, filename), parent);
} catch (Exception exc) {
logWarn("Your `dub.json` file use non-conventional features that are deprecated");
logWarn("This is most likely due to duplicated keys.");
logWarn("Please adjust your `dub.json` file as those warnings will turn into errors in dub v1.40.0");
logWarn("Error was: %s", exc);
// Fallback to JSON parser
ret = PackageRecipe.init;
parseJson(ret, parseJsonString(contents, filename), parent);
}
// `debug = ConfigFillerDebug` also enables verbose parser output
debug (ConfigFillerDebug)
{
import std.stdio;

PackageRecipe jsonret;
parseJson(jsonret, parseJsonString(contents, filename), parent_name);
if (ret != jsonret)
{
writeln("Content of JSON and YAML parsing differ for file: ", filename);
writeln("-------------------------------------------------------------------");
writeln("JSON (excepted): ", jsonret);
writeln("-------------------------------------------------------------------");
writeln("YAML (actual ): ", ret);
writeln("========================================");
ret = jsonret;
}
}
ret = parseConfigString!PackageRecipe(contents, filename, mode);
fixDependenciesNames(ret.name, ret);
}
else if (filename.endsWith(".sdl")) parseSDL(ret, contents, parent, filename);
else assert(false, "readPackageRecipe called with filename with unknown extension: "~filename);