# HG changeset patch # User Dan Drogichen # Date 1403149386 25200 # Wed Jun 18 20:43:06 2014 -0700 # Node ID d03df310f7ae9734ee1a78128d062f334f81114b # Parent 293cf2f7da0fa9d4000faf71bf8b4872f78f0bb1 [developer] Add diffs-only mode to file diff utility - #1699 Adds an alternate display mode to the developer tools 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 293cf2f7da0f -r d03df310f7ae chirpui/common.py --- a/chirpui/common.py Wed Jun 18 14:08:02 2014 -0700 +++ b/chirpui/common.py Wed Jun 18 20:43:06 2014 -0700 @@ -379,7 +379,7 @@ # A quick hacked up tool to show a blob of text in a dialog window # using fixed-width fonts. It also highlights lines that start with # a '-' in red bold font and '+' with blue bold font. -def show_diff_blob(title, result): +def show_diff_blob(title, result, diffsonly=False): d = gtk.Dialog(title=title, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) b = gtk.TextBuffer() @@ -402,11 +402,20 @@ fontsize = 11 lines = result.split(os.linesep) + blankprinted = True for line in lines: if line.startswith("-"): tags = ("red", "bold") elif line.startswith("+"): tags = ("blue", "bold") + blankprinted = False + elif diffsonly == True: + if blankprinted: + continue + else: + line = "" + tags = () + blankprinted = True else: tags = () b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags) diff -r 293cf2f7da0f -r d03df310f7ae chirpui/mainapp.py --- a/chirpui/mainapp.py Wed Jun 18 14:08:02 2014 -0700 +++ b/chirpui/mainapp.py Wed Jun 18 20:43:06 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!")