Colours in diff and change: separating concerns and dependencies
[?]
Jan 13, 2021, 6:27 PM
ZRUPLBBTT4S6S7A3LOAHG4ONYEGPA5CFO4L2XBCNFKK45MWX3BDACDependencies
- [2]
OJZWJUF2MUCH faster `pijul add -r` - [3]
SLJ3OHD4unrecord: show list of changes if none were given as arguments - [4]
GLRGFBCWChecking the version of less we have - [5]
SE4RJYBZNo pager on Windows (really not) - [6]
YDKNUL6BAdd `diff --short` that lists changes without showing them - [7]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [8]
CCFJ7VO3Renaming "Record" to "Hunk" in the changes - [9]
CIEUBH46Fixing an index-out-of-bounds error when serialising bad changes - [10]
I52XSRUHMassive cleanup, and simplification - [11]
CCLLB7OIUpgrading to Sanakirja 0.15 + version bump - [12]
Q4SVMHAERemoving --channel from the changes command - [13]
VIHXB7SGcommands: set up pager for diff, change, and credit - [14]
VO5OQW4WRemoving anyhow in libpijul - [15]
73NW2X2MReturning a parse error instead of panicking when parsing a text change - [16]
2K7JLB4ZNo pager on Windows - [17]
5YDI33C4Fixing pager on OSX - [18]
5DVRL6MFHard-unrecord - [*]
Q45QHPO4Feedback on network stuff
Change contents
- replacement in pijul/src/commands/mod.rs at line 100
fn pager() {fn pager() -> bool { - replacement in pijul/src/commands/mod.rs at line 113
pager::Pager::with_pager("less -RF").setup()pager::Pager::with_pager("less -RF").setup();return true; - replacement in pijul/src/commands/mod.rs at line 116
pager::Pager::new().setup()pager::Pager::new().setup(); - edit in pijul/src/commands/mod.rs at line 120
false - replacement in pijul/src/commands/mod.rs at line 124
fn pager() {}fn pager() -> bool {false} - replacement in pijul/src/commands/diff.rs at line 90
super::pager();let pager_is_colored = super::pager(); - replacement in pijul/src/commands/diff.rs at line 161
&mut std::io::stdout(),Colored {w: termcolor::StandardStream::stdout(termcolor::ColorChoice::Auto),colors: atty::is(atty::Stream::Stdout) || pager_is_colored,}, - edit in pijul/src/commands/diff.rs at line 185
}pub struct Colored<W> {pub w: W,pub colors: bool,}impl<W: std::io::Write> std::io::Write for Colored<W> {fn write(&mut self, s: &[u8]) -> Result<usize, std::io::Error> {self.w.write(s)}fn flush(&mut self) -> Result<(), std::io::Error> {self.w.flush()}}use termcolor::*;impl<W: termcolor::WriteColor> libpijul::change::WriteChangeLine for Colored<W> {fn write_change_line(&mut self, pref: &str, contents: &str) -> Result<(), std::io::Error> {if self.colors {let col = if pref == "+" {Color::Green} else {Color::Red};self.w.set_color(ColorSpec::new().set_fg(Some(col)))?;write!(self.w, "{} {}", pref, contents)?;self.w.reset()} else {write!(self.w, "{} {}", pref, contents)}}fn write_change_line_binary(&mut self,pref: &str,contents: &[u8],) -> Result<(), std::io::Error> {if self.colors {let col = if pref == "+" {Color::Green} else {Color::Red};self.w.set_color(ColorSpec::new().set_fg(Some(col)))?;write!(self.w,"{}b{}",pref,data_encoding::BASE64.encode(contents))?;self.w.reset()} else {write!(self.w,"{}b{}",pref,data_encoding::BASE64.encode(contents))}} - replacement in pijul/src/commands/change.rs at line 44[5.419]→[5.190911:190976](∅→∅),[5.190911]→[5.190911:190976](∅→∅),[5.190976]→[5.238:262](∅→∅),[5.244]→[5.190976:191046](∅→∅),[5.262]→[5.190976:191046](∅→∅),[5.190976]→[5.190976:191046](∅→∅)
let o = std::io::stdout();let mut o = o.lock();super::pager();change.write(&changes, Some(hash), file_name, true, &mut o)?;let pager_is_colored = super::pager();change.write(&changes,Some(hash),file_name,true,super::diff::Colored {w: termcolor::StandardStream::stdout(termcolor::ColorChoice::Auto),colors: atty::is(atty::Stream::Stdout) || pager_is_colored,},)?; - edit in pijul/Cargo.toml at line 78[20.2859][2.355]
termcolor = "1.1"atty = "0.2" - edit in libpijul/src/change.rs at line 10
pub use text_changes::WriteChangeLine; - replacement in libpijul/src/change/text_changes.rs at line 86
pub fn write<W: Write, C: ChangeStore, F: FnMut(&Local, Position<Option<Hash>>) -> String>(pub fn write<W: WriteChangeLine, C: ChangeStore, F: FnMut(&Local, Position<Option<Hash>>) -> String>( - replacement in libpijul/src/change/text_changes.rs at line 306
W: std::io::Write,W: WriteChangeLine, - replacement in libpijul/src/change/text_changes.rs at line 315
mut w: W,mut w: &mut W, - replacement in libpijul/src/change/text_changes.rs at line 367
print_change_contents(&mut w, changes, contents, change_contents)?;print_change_contents(w, changes, contents, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 384
print_change_contents(&mut w, changes, contents, change_contents)?;print_change_contents(w, changes, contents, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 426
print_contents(&mut w, "+", c)?;print_contents(w, "+", c)?; - replacement in libpijul/src/change/text_changes.rs at line 438
print_change_contents(&mut w, changes, change, change_contents)?;print_change_contents(w, changes, change, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 451
print_change_contents(&mut w, changes, change, change_contents)?;print_change_contents(&mut w, changes, replacement, change_contents)?;print_change_contents(w, changes, change, change_contents)?;print_change_contents(w, changes, replacement, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 480
print_change_contents(&mut w, changes, change, change_contents)?;print_change_contents(w, changes, change, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 492
print_change_contents(&mut w, changes, change, change_contents)?;print_change_contents(w, changes, change, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 504
print_change_contents(&mut w, changes, change, change_contents)?;print_change_contents(w, changes, change, change_contents)?; - replacement in libpijul/src/change/text_changes.rs at line 1186
pub fn print_contents<W: std::io::Write>(pub trait WriteChangeLine: std::io::Write {fn write_change_line(&mut self, pref: &str, contents: &str) -> Result<(), std::io::Error> {write!(self, "{} {}", pref, contents)}fn write_change_line_binary(&mut self, pref: &str, contents: &[u8]) -> Result<(), std::io::Error> {write!(self, "{}b{}", pref, data_encoding::BASE64.encode(contents))}}impl WriteChangeLine for &mut Vec<u8> {}pub fn print_contents<W: WriteChangeLine>( - replacement in libpijul/src/change/text_changes.rs at line 1206
write!(w, "{} {}", pref, a)?;w.write_change_line(pref, a)? - replacement in libpijul/src/change/text_changes.rs at line 1209
writeln!(w, "{} {}", pref, contents)?;w.write_change_line(pref, contents)? - replacement in libpijul/src/change/text_changes.rs at line 1217
pub fn print_change_contents<W: std::io::Write, C: ChangeStore>(pub fn print_change_contents<W: WriteChangeLine, C: ChangeStore>(