# HG changeset patch # User Dan Drogichen # Date 1404844716 25200 # Tue Jul 08 11:38:36 2014 -0700 # Node ID 9bef3191928caec63ffc8ae9398901c9a52a2fd8 # Parent fa902fc78810dae3a383a025c710eb575145fa1c [developer] Add diffs-only mode to file diff utility - #1699 Adds an alternate display mode to the developer tools whole-file hex dump/diff utility in which only lines which are different are printed. Ranges of one or more lines that do not differ are replaced with a single blank line. This mode is invoked by setting the first memory location in the "Diff Radios" popup to -2. The existing functionality invoked by -1 is not affected. #1699 diff -r fa902fc78810 -r 9bef3191928c chirpui/common.py --- a/chirpui/common.py Mon Jul 07 19:42:15 2014 -0400 +++ b/chirpui/common.py Tue Jul 08 11:38:36 2014 -0700 @@ -363,15 +363,22 @@ return r, cb.get_active() return r -def simple_diff(a, b): +def simple_diff(a, b, diffsonly=False): lines_a = a.split(os.linesep) lines_b = b.split(os.linesep) + blankprinted = True diff = "" for i in range(0, len(lines_a)): if lines_a[i] != lines_b[i]: diff += "-%s%s" % (lines_a[i], os.linesep) diff += "+%s%s" % (lines_b[i], os.linesep) + blankprinted = False + elif diffsonly == True: + if blankprinted: + continue + diff += os.linesep + blankprinted = True else: diff += " %s%s" % (lines_a[i], os.linesep) return diff diff -r fa902fc78810 -r 9bef3191928c chirpui/mainapp.py --- a/chirpui/mainapp.py Mon Jul 07 19:42:15 2014 -0400 +++ b/chirpui/mainapp.py Tue Jul 08 11:38:36 2014 -0700 @@ -160,7 +160,7 @@ choice_a = miscwidgets.make_choice(choices, False, choices[0]) choice_a.show() chan_a = gtk.SpinButton() - chan_a.get_adjustment().set_all(1, -1, 999, 1, 10, 0) + chan_a.get_adjustment().set_all(1, -2, 999, 1, 10, 0) chan_a.show() hbox = gtk.HBox(False, 3) hbox.pack_start(choice_a, 1, 1, 1) @@ -219,7 +219,12 @@ # Diff whole (can do this without a job, since both are clone-mode) a = util.hexprint(eset_a.rthread.radio._mmap.get_packed()) b = util.hexprint(eset_b.rthread.radio._mmap.get_packed()) - common.show_diff_blob("Differences", common.simple_diff(a, b)) + if sel_chan_a == -2: + diffsonly = True + else: + diffsonly = False + common.show_diff_blob("Differences", + common.simple_diff(a, b, diffsonly)) else: common.show_error("Cannot diff whole live-mode radios!")