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 bisect;
35pub mod commit;
36pub mod commit_builder;
37pub mod config;
38mod config_resolver;
39pub mod conflicts;
40pub mod copies;
41pub mod dag_walk;
42pub mod default_index;
43pub mod default_submodule_store;
44pub mod diff;
45pub mod dsl_util;
46pub(crate) mod eol;
47pub mod evolution;
48pub mod extensions_map;
49pub mod file_util;
50pub mod files;
51pub mod fileset;
52mod fileset_parser;
53pub mod fix;
54pub mod fmt_util;
55pub mod fsmonitor;
56#[cfg(feature = "git")]
57pub mod git;
58#[cfg(not(feature = "git"))]
59/// A stub module that provides a no-op implementation of some of the functions
60/// in the `git` module.
61pub mod git {
62    use crate::ref_name::RemoteName;
63    /// Determine, by its name, if a remote refers to the special local-only
64    /// "git" remote that is used in the Git backend.
65    ///
66    /// This function always returns false if the "git" feature is not enabled.
67    pub fn is_special_git_remote(_remote: &RemoteName) -> bool {
68        false
69    }
70}
71#[cfg(feature = "git")]
72pub mod git_backend;
73#[cfg(feature = "git")]
74mod git_subprocess;
75pub mod gitignore;
76pub mod gpg_signing;
77pub mod graph;
78pub mod hex_util;
79pub mod id_prefix;
80pub mod index;
81pub mod local_working_copy;
82pub mod lock;
83pub mod matchers;
84pub mod merge;
85pub mod merged_tree;
86pub mod object_id;
87pub mod op_heads_store;
88pub mod op_store;
89pub mod op_walk;
90pub mod operation;
91#[expect(missing_docs)]
92pub mod protos;
93pub mod ref_name;
94pub mod refs;
95pub mod repo;
96pub mod repo_path;
97pub mod revset;
98mod revset_parser;
99pub mod rewrite;
100#[cfg(feature = "testing")]
101pub mod secret_backend;
102pub mod settings;
103pub mod signing;
104pub mod tree_merge;
105// TODO: This file is mostly used for testing, whenever we no longer require it
106// in the lib it should be moved to the examples (e.g
107// "examples/simple-backend/").
108pub mod simple_backend;
109pub mod simple_op_heads_store;
110pub mod simple_op_store;
111pub mod ssh_signing;
112pub mod stacked_table;
113pub mod store;
114pub mod str_util;
115pub mod submodule_store;
116#[cfg(feature = "testing")]
117pub mod test_signing_backend;
118pub mod time_util;
119pub mod trailer;
120pub mod transaction;
121pub mod tree;
122pub mod tree_builder;
123pub mod union_find;
124pub mod view;
125pub mod working_copy;
126pub mod workspace;
127
128#[cfg(test)]
129mod tests {
130    use tempfile::TempDir;
131
132    /// Unlike `testutils::new_temp_dir()`, this function doesn't set up
133    /// hermetic Git environment.
134    pub fn new_temp_dir() -> TempDir {
135        tempfile::Builder::new()
136            .prefix("jj-test-")
137            .tempdir()
138            .unwrap()
139    }
140}