diff options
| author | Crash Over Burn | 2026-04-14 13:05:33 +0000 |
|---|---|---|
| committer | ยท๐๐ด๐๐๐ฉ๐ค | 2026-04-14 13:05:33 +0000 |
| commit | e6c901d2e5430a3815109b38ced11a4f695f0226 (patch) | |
| tree | 07a4cf8846035d5968f7a78007f71cc1fc6dd6fc /lib/lockfile.ml | |
| parent | 26fef65e28c3f085d33a5d222aa1dbac245ec435 (diff) | |
| download | nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.gz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.bz2 nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.lz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.xz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.zst nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.zip | |
Port upstream patches: Cmdliner 2.x, lockfile auto-creation, schema upgrade, Fossil VCS
Ported from upstream darcs repository (v1.1.2):
- Cmdliner 2.x compatibility fixes (variable shadowing)
- Lockfile auto-creation when missing
- Schema upgrade command with backup/rollback
- Fossil VCS support (new VCS type)
- Clean up Cmdliner warning for unescaped $PWD
Files modified:
- lib/schema.ml (new): Schema versioning module
- lib/nixtamal.ml: Add upgrade function, Fossil meld support
- lib/error.ml: Add Fossil to prefetch_method, Upgrade error
- lib/input.ml: Add Fossil module, Kind variant
- lib/prefetch.ml: Add Fossil prefetch with SRI hash support
- lib/manifest.ml: Add Fossil codec
- lib/lockfile.ml: Add Fossil lockfile type
- lib/lock_loader.ml: Add Fossil feature flag
- lib/input_foreman.ml: Add Fossil display and prefetch check
- bin/cmd.ml: Cmdliner 2.x fixes, add Upgrade command
- bin/dune, lib/dune, test/dune: Deprecation flags
Builds successfully with all tests passing.
Diffstat (limited to 'lib/lockfile.ml')
| -rw-r--r-- | lib/lockfile.ml | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/lockfile.ml b/lib/lockfile.ml index 36dd069..0792886 100644 --- a/lib/lockfile.ml +++ b/lib/lockfile.ml @@ -291,6 +291,77 @@ module Pijul = struct |> Object.finish end +module Nilla = struct + type t = { + repository: URI.t; + mirrors: URI.t list; + datetime: string option; + latest_revision: string option; + path: string; + } + [@@deriving show, eq, qcheck] + + let [@inline]to_lock + ~(models : Input.jg_models2) + ({repository; mirrors; datetime; latest_revision; path; _}: Input.Nilla.t) + : t + = + let to_uri = Fun.compose URI.of_string (Input.Template.fill ~models) in + { + repository = to_uri repository; + mirrors = List.map to_uri mirrors; + datetime; + latest_revision; + path = Input.Template.(fill ~models path); + } + + let jsont : t Jsont.t = + let open Jsont in + Object.map ~kind: "Nilla_lock" (fun repository mirrors datetime latest_revision path -> + {repository; mirrors; datetime; latest_revision; path} + ) + |> Object.mem "rp" URI.jsont ~enc: (fun i -> i.repository) + |> Object.mem "ms" (list URI.jsont) ~enc: (fun i -> i.mirrors) + |> Object.mem "dt" (option string) ~enc: (fun i -> i.datetime) + |> Object.mem "lr" (option string) ~enc: (fun i -> i.latest_revision) + |> Object.mem "pt" string ~enc: (fun i -> i.path) + |> Object.finish +end + +module Fossil = struct + type t = { + repository: URI.t; + mirrors: URI.t list; + datetime: string option; + latest_checkin: string option; + } + [@@deriving show, eq, qcheck] + + let [@inline]to_lock + ~(models : Input.jg_models2) + ({repository; reference; date; latest_checkin; _}: Input.Fossil.t) + : t + = + let to_uri = Fun.compose URI.of_string (Input.Template.fill ~models) in + { + repository = to_uri repository; + mirrors = []; (* Fossils don't have mirrors in upstream, so empty *) + datetime = date; + latest_checkin; + } + + let jsont : t Jsont.t = + let open Jsont in + Object.map ~kind: "Fossil_lock" (fun repository mirrors datetime latest_checkin -> + {repository; mirrors; datetime; latest_checkin} + ) + |> Object.mem "rp" URI.jsont ~enc: (fun i -> i.repository) + |> Object.mem "ms" (list URI.jsont) ~enc: (fun i -> i.mirrors) + |> Object.mem "dt" (option string) ~enc: (fun i -> i.datetime) + |> Object.mem "lc" (option string) ~enc: (fun i -> i.latest_checkin) + |> Object.finish +end + module Kind = struct type t = [ | `File of File.t @@ -298,6 +369,8 @@ module Kind = struct | `Git of Git.t | `Darcs of Darcs.t | `Pijul of Pijul.t + | `Nilla of Nilla.t + | `Fossil of Fossil.t ] [@@deriving show, eq, qcheck] @@ -307,6 +380,8 @@ module Kind = struct | `Git g -> `Git (Git.to_lock ~models g) | `Darcs d -> `Darcs (Darcs.to_lock ~models d) | `Pijul p -> `Pijul (Pijul.to_lock ~models p) + | `Nilla n -> `Nilla (Nilla.to_lock ~models n) + | `Fossil f -> `Fossil (Fossil.to_lock ~models f) let jsont : t Jsont.t = let open Jsont in @@ -316,6 +391,8 @@ module Kind = struct | `Git g -> encode_tag 2 Git.jsont g | `Darcs d -> encode_tag 3 Darcs.jsont d | `Pijul p -> encode_tag 4 Pijul.jsont p + | `Nilla n -> encode_tag 5 Nilla.jsont n + | `Fossil f -> encode_tag 6 Fossil.jsont f and dec = function | [|tag; value|] -> begin @@ -335,6 +412,12 @@ module Kind = struct | 4 -> Json.decode' Pijul.jsont value |> Result.map (fun v -> `Pijul v) + | 5 -> + Json.decode' Nilla.jsont value + |> Result.map (fun v -> `Nilla v) + | 6 -> + Json.decode' Fossil.jsont value + |> Result.map (fun v -> `Fossil v) | n -> Error.msgf Meta.none "Unknown reference enum tag: %d" n ) with |
