jj_lib/
lib.rs

1// Copyright 2020 The Jujutsu Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Jujutsu version control system.
16
17#![warn(missing_docs)]
18#![deny(unused_must_use)]
19#![forbid(unsafe_code)]
20
21// Needed so that proc macros can be used inside jj_lib and by external crates
22// that depend on it.
23// See:
24// - https://github.com/rust-lang/rust/issues/54647#issuecomment-432015102
25// - https://github.com/rust-lang/rust/issues/54363
26extern crate self as jj_lib;
27
28#[macro_use]
29pub mod content_hash;
30
31pub mod absorb;
32pub mod annotate;
33pub mod backend;
34pub mod commit;
35pub mod commit_builder;
36pub mod config;
37mod config_resolver;
38pub mod conflicts;
39pub mod copies;
40pub mod dag_walk;
41pub mod default_index;
42pub mod default_submodule_store;
43pub mod diff;
44pub mod dsl_util;
45pub mod extensions_map;
46pub mod file_util;
47pub mod files;
48pub mod fileset;
49mod fileset_parser;
50pub mod fix;
51pub mod fmt_util;
52pub mod fsmonitor;
53#[cfg(feature = "git")]
54pub mod git;
55#[cfg(not(feature = "git"))]
56/// A stub module that provides a no-op implementation of some of the functions
57/// in the `git` module.
58pub mod git {
59    use crate::ref_name::RemoteName;
60    /// Determine, by its name, if a remote refers to the special local-only
61    /// "git" remote that is used in the Git backend.
62    ///
63    /// This function always returns false if the "git" feature is not enabled.
64    pub fn is_special_git_remote(_remote: &RemoteName) -> bool {
65        false
66    }
67}
68#[cfg(feature = "git")]
69pub mod git_backend;
70#[cfg(feature = "git")]
71mod git_subprocess;
72pub mod gitignore;
73pub mod gpg_signing;
74pub mod graph;
75pub mod hex_util;
76pub mod id_prefix;
77pub mod index;
78pub mod local_working_copy;
79pub mod lock;
80pub mod matchers;
81pub mod merge;
82pub mod merged_tree;
83pub mod object_id;
84pub mod op_heads_store;
85pub mod op_store;
86pub mod op_walk;
87pub mod operation;
88#[expect(missing_docs)]
89pub mod protos;
90pub mod ref_name;
91pub mod refs;
92pub mod repo;
93pub mod repo_path;
94pub mod revset;
95mod revset_parser;
96pub mod rewrite;
97#[cfg(feature = "testing")]
98pub mod secret_backend;
99pub mod settings;
100pub mod signing;
101// TODO: This file is mostly used for testing, whenever we no longer require it
102// in the lib it should be moved to the examples (e.g
103// "examples/simple-backend/").
104pub mod simple_backend;
105pub mod simple_op_heads_store;
106pub mod simple_op_store;
107pub mod ssh_signing;
108pub mod stacked_table;
109pub mod store;
110pub mod str_util;
111pub mod submodule_store;
112#[cfg(feature = "testing")]
113pub mod test_signing_backend;
114pub mod time_util;
115pub mod trailer;
116pub mod transaction;
117pub mod tree;
118pub mod tree_builder;
119pub mod union_find;
120pub mod view;
121pub mod working_copy;
122pub mod workspace;
123
124#[cfg(test)]
125mod tests {
126    use tempfile::TempDir;
127
128    /// Unlike `testutils::new_temp_dir()`, this function doesn't set up
129    /// hermetic Git environment.
130    pub fn new_temp_dir() -> TempDir {
131        tempfile::Builder::new()
132            .prefix("jj-test-")
133            .tempdir()
134            .unwrap()
135    }
136}