Add debugging output
This commit is contained in:
parent
4e2bcf7d58
commit
9c29bf19da
1 changed files with 12 additions and 0 deletions
|
@ -144,6 +144,8 @@ impl InternalLinker for Entry {
|
|||
fn add_internal_link(&mut self, link: &mut Entry) -> Result<()> {
|
||||
let new_link = link.get_location().clone();
|
||||
|
||||
debug!("Adding internal link from {:?} to {:?}", self.get_location(), new_link);
|
||||
|
||||
add_foreign_link(link, self.get_location().clone())
|
||||
.and_then(|_| {
|
||||
self.get_internal_links()
|
||||
|
@ -158,13 +160,17 @@ impl InternalLinker for Entry {
|
|||
let own_loc = link.get_location().clone();
|
||||
let other_loc = link.get_location().clone();
|
||||
|
||||
debug!("Removing internal link from {:?} to {:?}", own_loc, other_loc);
|
||||
|
||||
link.get_internal_links()
|
||||
.and_then(|links| {
|
||||
debug!("Rewriting own links for {:?}, without {:?}", other_loc, own_loc);
|
||||
rewrite_links(self.get_header_mut(), links.filter(|l| *l != own_loc))
|
||||
})
|
||||
.and_then(|_| {
|
||||
self.get_internal_links()
|
||||
.and_then(|links| {
|
||||
debug!("Rewriting own links for {:?}, without {:?}", own_loc, other_loc);
|
||||
rewrite_links(link.get_header_mut(), links.filter(|l| *l != other_loc))
|
||||
})
|
||||
})
|
||||
|
@ -184,6 +190,7 @@ fn rewrite_links<I: Iterator<Item = Link>>(header: &mut EntryHeader, links: I) -
|
|||
})
|
||||
}));
|
||||
|
||||
debug!("Setting new link array: {:?}", links);
|
||||
let process = header.set("imag.links", Value::Array(links));
|
||||
process_rw_result(process).map(|_| ())
|
||||
}
|
||||
|
@ -191,6 +198,7 @@ fn rewrite_links<I: Iterator<Item = Link>>(header: &mut EntryHeader, links: I) -
|
|||
/// When Linking A -> B, the specification wants us to link back B -> A.
|
||||
/// This is a helper function which does this.
|
||||
fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> {
|
||||
debug!("Linking back from {:?} to {:?}", target.get_location(), from);
|
||||
target.get_internal_links()
|
||||
.and_then(|links| {
|
||||
let links = try!(links
|
||||
|
@ -205,6 +213,7 @@ fn add_foreign_link(target: &mut Entry, from: StoreId) -> Result<()> {
|
|||
})
|
||||
})
|
||||
}));
|
||||
debug!("Setting links in {:?}: {:?}", target.get_location(), links);
|
||||
process_rw_result(target.get_header_mut().set("imag.links", Value::Array(links)))
|
||||
.map(|_| ())
|
||||
})
|
||||
|
@ -293,6 +302,9 @@ mod test {
|
|||
let e1_links = e1.get_internal_links().unwrap().collect::<Vec<_>>();
|
||||
let e2_links = e2.get_internal_links().unwrap().collect::<Vec<_>>();
|
||||
|
||||
debug!("1 has links: {:?}", e1_links);
|
||||
debug!("2 has links: {:?}", e2_links);
|
||||
|
||||
assert_eq!(e1_links.len(), 1);
|
||||
assert_eq!(e2_links.len(), 1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue