Skip to content

Commit

Permalink
Move metadata statics to store.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Nov 10, 2023
1 parent 05da48f commit f577599
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
11 changes: 5 additions & 6 deletions src/libcinnabar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ use crate::git::{CommitId, GitObjectId, TreeId};
use crate::hg::HgObjectId;
use crate::libgit::{
child_process, combine_notes_ignore, die, free_notes, init_notes, notes_tree, object_id,
strbuf, FileMode, RawTree, FILES_META_OID, GIT2HG_OID, HG2GIT_OID,
strbuf, FileMode, RawTree,
};
use crate::oid::{Abbrev, ObjectId};
use crate::store::{store_git_commit, MetadataFlags, METADATA_FLAGS};
use crate::store::{
store_git_commit, MetadataFlags, FILES_META, FILES_META_OID, GIT2HG, GIT2HG_OID, HG2GIT,
HG2GIT_OID, METADATA_FLAGS,
};

#[allow(non_camel_case_types)]
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -140,10 +143,6 @@ impl cinnabar_notes_tree {
}
}

pub static mut GIT2HG: git_notes_tree = git_notes_tree::new();
pub static mut HG2GIT: hg_notes_tree = hg_notes_tree::new();
pub static mut FILES_META: hg_notes_tree = hg_notes_tree::new();

extern "C" {
fn cinnabar_get_note(
notes: *mut cinnabar_notes_tree,
Expand Down
7 changes: 0 additions & 7 deletions src/libgit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ impl From<object_id> for GitObjectId {
}
}

pub static mut METADATA_OID: CommitId = CommitId::NULL;
pub static mut CHANGESETS_OID: CommitId = CommitId::NULL;
pub static mut MANIFESTS_OID: CommitId = CommitId::NULL;
pub static mut GIT2HG_OID: CommitId = CommitId::NULL;
pub static mut HG2GIT_OID: CommitId = CommitId::NULL;
pub static mut FILES_META_OID: CommitId = CommitId::NULL;

#[allow(non_camel_case_types)]
#[repr(C)]
pub struct strbuf {
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ use hg_connect::{get_bundle, get_clonebundle_url, get_connection, get_store_bund
use indexmap::IndexSet;
use itertools::EitherOrBoth::{Both, Left, Right};
use itertools::{EitherOrBoth, Itertools};
use libcinnabar::{git_notes_tree, FILES_META, GIT2HG, HG2GIT};
use libcinnabar::git_notes_tree;
use libgit::{
commit, config_get_value, die, diff_tree_with_copies, for_each_ref_in, for_each_remote,
get_oid_committish, get_unique_abbrev, lookup_commit, lookup_replace_commit, object_id,
reachable_subset, remote, repository, resolve_ref, rev_list, rev_list_with_boundaries, strbuf,
the_repository, DiffTreeItem, MaybeBoundary, RawBlob, RawCommit, RawTree, RefTransaction,
METADATA_OID,
};
use logging::{LoggingReader, LoggingWriter};
use oid::{Abbrev, ObjectId};
Expand All @@ -125,7 +124,8 @@ use store::{
raw_commit_for_changeset, reset_changeset_heads, reset_manifest_heads, store_git_blob,
store_manifest, ChangesetHeads, GeneratedGitChangesetMetadata, RawGitChangesetMetadata,
RawHgChangeset, RawHgFile, RawHgManifest, SetWhat, BROKEN_REF, CHANGESET_HEADS, CHECKED_REF,
METADATA_REF, NOTES_REF, REFS_PREFIX, REPLACE_REFS_PREFIX,
FILES_META, GIT2HG, HG2GIT, METADATA_OID, METADATA_REF, NOTES_REF, REFS_PREFIX,
REPLACE_REFS_PREFIX,
};
use tree_util::{diff_by_path, RecurseTree};
use url::Url;
Expand Down Expand Up @@ -951,9 +951,9 @@ fn do_reclone(rebase: bool) -> Result<(), String> {
}
}

let old_changesets_oid = unsafe { libgit::CHANGESETS_OID };
let old_changesets_oid = unsafe { store::CHANGESETS_OID };
let mut old_git2hg = {
let git2hg_oid = unsafe { libgit::GIT2HG_OID };
let git2hg_oid = unsafe { store::GIT2HG_OID };
if git2hg_oid.is_null() {
None
} else {
Expand Down
25 changes: 14 additions & 11 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ use crate::hg_bundle::{
};
use crate::hg_connect_http::HttpRequest;
use crate::hg_data::{hash_data, GitAuthorship, HgAuthorship, HgCommitter};
use crate::libcinnabar::{
git_notes_tree, hg_notes_tree, strslice, strslice_mut, FILES_META, GIT2HG, HG2GIT,
};
use crate::libcinnabar::{git_notes_tree, hg_notes_tree, strslice, strslice_mut};
use crate::libgit::{
die, for_each_ref_in, get_oid_blob, object_id, strbuf, Commit, RawBlob, RawCommit, RawTree,
RefTransaction, CHANGESETS_OID, FILES_META_OID, GIT2HG_OID, HG2GIT_OID, MANIFESTS_OID,
METADATA_OID,
RefTransaction,
};
use crate::oid::ObjectId;
use crate::progress::{progress_enabled, Progress};
Expand All @@ -66,6 +63,17 @@ pub const CHECKED_REF: &str = "refs/cinnabar/checked";
pub const BROKEN_REF: &str = "refs/cinnabar/broken";
pub const NOTES_REF: &str = "refs/notes/cinnabar";

pub static mut METADATA_OID: CommitId = CommitId::NULL;
pub static mut CHANGESETS_OID: CommitId = CommitId::NULL;
pub static mut MANIFESTS_OID: CommitId = CommitId::NULL;
pub static mut GIT2HG_OID: CommitId = CommitId::NULL;
pub static mut HG2GIT_OID: CommitId = CommitId::NULL;
pub static mut FILES_META_OID: CommitId = CommitId::NULL;

pub static mut GIT2HG: git_notes_tree = git_notes_tree::new();
pub static mut HG2GIT: hg_notes_tree = hg_notes_tree::new();
pub static mut FILES_META: hg_notes_tree = hg_notes_tree::new();

bitflags! {
#[derive(Debug, Copy, Clone)]
pub struct MetadataFlags: i32 {
Expand Down Expand Up @@ -1562,12 +1570,7 @@ pub fn do_check_files() -> bool {
if busted {
let mut transaction = RefTransaction::new().unwrap();
transaction
.update(
BROKEN_REF,
unsafe { crate::libgit::METADATA_OID },
None,
"post-pull check",
)
.update(BROKEN_REF, unsafe { METADATA_OID }, None, "post-pull check")
.unwrap();
transaction.commit().unwrap();
error!(
Expand Down

0 comments on commit f577599

Please sign in to comment.