Struct hg_parser::SharedMercurialRepository
source · pub struct SharedMercurialRepository { /* private fields */ }
Expand description
Shares instance of CachedMercurialRepository
between multiple readers.
Implementations§
pub fn new(repository: MercurialRepository) -> Self
pub fn par_range_iter( &self, revision_range: RevisionRange ) -> OrderedParallelIterator<Changeset>
Methods from Deref<Target = MercurialRepository>§
sourcepub fn iter(&self) -> ChangesetIter<'_> ⓘ
pub fn iter(&self) -> ChangesetIter<'_> ⓘ
Changeset iterator other all revisions in log.
sourcepub fn header_iter(&self) -> ChangesetHeaderIter<'_> ⓘ
pub fn header_iter(&self) -> ChangesetHeaderIter<'_> ⓘ
Changeset header iterator other all revisions in log.
sourcepub fn range_iter<RR: Into<RevisionRange>>(
&self,
revisions_range: RR
) -> ChangesetIter<'_> ⓘ
pub fn range_iter<RR: Into<RevisionRange>>( &self, revisions_range: RR ) -> ChangesetIter<'_> ⓘ
Changeset iterator other range of revisions in log.
sourcepub fn range_header_iter<RR: Into<RevisionRange>>(
&self,
revisions_range: RR
) -> ChangesetHeaderIter<'_> ⓘ
pub fn range_header_iter<RR: Into<RevisionRange>>( &self, revisions_range: RR ) -> ChangesetHeaderIter<'_> ⓘ
Changeset header iterator other range of revisions in log.
List tags in repository. Tags read from .hg/cache/tags2-visible
or .hgtags
.
Examples found in repository?
examples/git-fast-import.rs (line 112)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
fn export_repo<P: AsRef<Path>>(path: P) -> Result<(), Error> {
let start = Instant::now();
let repo = MercurialRepository::open(path)?;
let stdout = std::io::stdout();
let mut writer = stdout.lock();
for changeset in &repo {
let revision = changeset.revision;
eprintln!("rev: {:?}", revision);
let header = &changeset.header;
let mut branch = None;
let mut closed = false;
for (key, value) in &header.extra {
if key == b"branch" {
branch = Some(value.as_slice());
}
if key == b"close" && value == b"1" {
closed = true;
}
}
let mut branch: Vec<_> = branch.unwrap_or(b"master").into();
for b in branch.iter_mut() {
if *b == b' ' {
*b = b'-';
}
}
let user = String::from_utf8_lossy(&header.user);
let desc = String::from_utf8_lossy(&header.comment);
let time = header.time.timestamp_secs();
let timezone = header.time.tz_offset_secs();
let tz = format!("{:+03}{:02}", -timezone / 3600, ((-timezone % 3600) / 60));
write!(writer, "reset refs/heads/")?;
writer.write_all(&branch)?;
write!(writer, "\ncommit refs/heads/")?;
writer.write_all(&branch)?;
writeln!(writer, "\nmark :{}", mark(revision))?;
writeln!(writer, "author {} {} {}", user, time, tz)?;
writeln!(writer, "committer {} {} {}", user, time, tz)?;
writeln!(writer, "data {}", desc.len() + 1)?;
writeln!(writer, "{}\n", desc)?;
match (header.p1, header.p2) {
(Some(p1), Some(p2)) => {
writeln!(writer, "from :{}", mark(p1))?;
writeln!(writer, "merge :{}", mark(p2))?;
}
(Some(p), None) | (None, Some(p)) => {
writeln!(writer, "from :{}", mark(p))?;
}
_ => (),
}
for file in changeset.files {
match (file.data, file.manifest_entry) {
(None, None) => {
write!(writer, "D ")?;
writer.write_all(&file.path)?;
writeln!(writer)?;
}
(Some(data), Some(manifest_entry)) => {
write!(
writer,
"M {} inline ",
match manifest_entry.details {
ManifestEntryDetails::File(FileType::Symlink) => "120000",
ManifestEntryDetails::File(FileType::Executable) => "100755",
ManifestEntryDetails::Tree
| ManifestEntryDetails::File(FileType::Regular) => "100644",
}
)?;
writer.write_all(&file.path)?;
let data = file_content(&data);
writeln!(writer, "\ndata {}", data.len())?;
writer.write_all(data)?;
}
_ => panic!("Wrong file data!"),
}
}
if closed {
write!(writer, "reset refs/tags/archive/")?;
writer.write_all(&branch)?;
writeln!(writer, "\nfrom :{}\n", mark(revision))?;
write!(writer, "reset refs/heads/")?;
writer.write_all(&branch)?;
writeln!(writer, "\nfrom 0000000000000000000000000000000000000000\n")?;
}
}
for (rev, tag) in repo.tags().unwrap() {
eprintln!("export tag {}", tag.name);
writeln!(writer, "reset refs/tags/{}", tag.name).unwrap();
writeln!(writer, "from :{}", mark(rev)).unwrap();
writeln!(writer).unwrap();
}
eprintln!("Done. Elapsed: {:?}", start.elapsed());
Ok(())
}
Trait Implementations§
§type Target = MercurialRepository
type Target = MercurialRepository
The resulting type after dereferencing.
source§fn deref(&self) -> &MercurialRepository
fn deref(&self) -> &MercurialRepository
Dereferences the value.
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more