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