[yast-commit] r63501 - in /branches/tmp/jsuchome/snapper: package/yast2-snapper.changes src/Snapper.ycp src/dialogs.ycp

Author: jsuchome Date: Thu Mar 3 15:05:18 2011 New Revision: 63501 URL: http://svn.opensuse.org/viewcvs/yast?rev=63501&view=rev Log: - check selected file mode and ownership Modified: branches/tmp/jsuchome/snapper/package/yast2-snapper.changes branches/tmp/jsuchome/snapper/src/Snapper.ycp branches/tmp/jsuchome/snapper/src/dialogs.ycp Modified: branches/tmp/jsuchome/snapper/package/yast2-snapper.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/package/y... ============================================================================== --- branches/tmp/jsuchome/snapper/package/yast2-snapper.changes (original) +++ branches/tmp/jsuchome/snapper/package/yast2-snapper.changes Thu Mar 3 15:05:18 2011 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Thu Mar 3 15:03:55 CET 2011 - jsuchome@suse.cz + +- check selected file mode and ownership + +------------------------------------------------------------------- Mon Feb 28 10:37:40 CET 2011 - jsuchome@suse.cz - added option to compare with arbitrary snapshot Modified: branches/tmp/jsuchome/snapper/src/Snapper.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/Snapp... ============================================================================== --- branches/tmp/jsuchome/snapper/src/Snapper.ycp (original) +++ branches/tmp/jsuchome/snapper/src/Snapper.ycp Thu Mar 3 15:05:18 2011 @@ -78,7 +78,7 @@ if (FileUtils::Exists (file1) && FileUtils::Exists (file2)) { - + list<string> status = [ "no_change" ]; map out = (map) SCR::Execute (.target.bash_output, sformat ("/usr/bin/diff -u %1 %2", file1, file2)); if (out["stderr"]:"" != "") @@ -86,26 +86,49 @@ y2warning ("out: %1", out); ret["diff"] = out["stderr"]:""; } - else if (out["stdout"]:nil == "") + // the file diff + else if (out["stdout"]:nil != "") { - ret["status"] = "no_change"; + status = ["diff"]; + ret["diff"] = out["stdout"]:""; } - else + + // check mode and ownerships + out = (map) SCR::Execute (.target.bash_output, + sformat ("ls -l %1 %2 | cut -f 1,3,4 -d ' '", file1, file2)); + list<string> parts = splitstring (out["stdout"]:""," \n"); + + if (parts[0]:"" != parts[3]:"") { - ret["diff"] = out["stdout"]:""; + status = add (status, "mode"); + ret["mode1"] = parts[0]:""; + ret["mode2"] = parts[3]:""; + } + if (parts[1]:"" != parts[4]:"") + { + status = add (status, "user"); + ret["user1"] = parts[1]:""; + ret["user2"] = parts[4]:""; + } + if (parts[2]:"" != parts[5]:"") + { + status = add (status, "group"); + ret["group1"] = parts[2]:""; + ret["group2"] = parts[5]:""; } + ret["status"] = status; } else if (FileUtils::Exists (file1)) { - ret["status"] = "removed"; + ret["status"] = ["removed"]; } else if (FileUtils::Exists (file2)) { - ret["status"] = "created"; + ret["status"] = ["created"]; } else { - ret["status"] = "none"; + ret["status"] = ["none"]; } return ret; } Modified: branches/tmp/jsuchome/snapper/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jsuchome/snapper/src/dialo... ============================================================================== --- branches/tmp/jsuchome/snapper/src/dialogs.ycp (original) +++ branches/tmp/jsuchome/snapper/src/dialogs.ycp Thu Mar 3 15:05:18 2011 @@ -168,6 +168,7 @@ map display_info = UI::GetDisplayInfo (); boolean textmode = display_info["TextMode"]:false; + string previous_file= ""; string current_file = ""; // map of already read files @@ -290,40 +291,69 @@ Popup::ShowFeedback ("", _("Calculating file modifications...")); map modification = Snapper::GetFileModification (file, from, to); Popup::ClearFeedback (); + list<string> status = modification["status"]:[]; + if (contains (status, "created")) + { + // label + content = add (content, `Left (`Label ("New file was created."))); + } + else if (contains (status, "removed")) + { + // label + content = add (content, `Left (`Label ("File was removed."))); + } + else if (contains (status, "no_change")) + { + // label + content = add (content, `Left (`Label ("File content was not changed."))); + } + else if (contains (status, "none")) + { + // label + content = add (content, `Left (`Label ("File does not exist in either snapshot."))); + } + else if (contains (status, "diff")) + { + // label + content = add (content, `Left (`Label ("File content was modified."))); + } + if (contains (status, "mode")) + { + content = add (content, `Left (`Label ( + // text label, %1, %2 are file modes (like '-rw-r--r--') + sformat (_("File mode was changed from '%1' to '%2'."), + modification["mode1"]:"", modification["mode2"]:"") + ))); + } + if (contains (status, "user")) + { + content = add (content, `Left (`Label ( + // text label, %1, %2 are user names + sformat (_("File user ownership was changed from '%1' to '%2'."), + modification["user1"]:"", modification["user2"]:"") + ))); + } + if (contains (status, "group")) + { + // label + content = add (content, `Left (`Label ( + // text label, %1, %2 are group names + sformat (_("File group ownership was changed from '%1' to '%2'."), + modification["group1"]:"", modification["group2"]:"") + ))); + } + if (haskey (modification, "diff")) { string diff = modification["diff"]:""; diff = mergestring (splitstring (diff, "\n"), "<br>"); - content = `RichText (`id (`diff), diff); + content = add (content, `RichText (`id (`diff), diff)); } else { - if (modification["status"]:"" == "created") - { - // label - content = add (content, `Left (`Heading ("New file was created"))); - } - else if (modification["status"]:"" == "removed") - { - // label - content = add (content, `Left (`Heading ("File was removed"))); - } - else if (modification["status"]:"" == "no_change") - { - // label - content = add (content, `Left (`Heading ("File was not changed"))); - } - else if (modification["status"]:"" == "none") - { - // label - content = add (content, `Left (`Heading ("File does not exist in either snapshot"))); - } - else - { - y2warning ("not known: %1", modification); - } content = add (content, `VStretch ()); } + UI::ReplaceWidget (`id (`diff_content), `HBox (`HSpacing (0.5), `VBox ( content, `VSquash (`HBox ( @@ -356,6 +386,7 @@ ), `HBox ( `HSpacing (2), + // FIXME without label, there's no shortcut! `Left (`ComboBox (`id (`selection_snapshots), `opt (`notify), "", combo_items)) ) ) @@ -491,6 +522,7 @@ map event = UI::WaitForEvent (); ret = (symbol) event["ID"]:nil; + previous_file = current_file; current_file = (string) UI::QueryWidget (`id(`tree),`CurrentItem); if (current_file == nil) current_file = ""; @@ -546,10 +578,13 @@ // other tree events else if (ret == `tree) { - set_entry_term (); - UI::NormalCursor (); - if (textmode) - UI::SetFocus (`id(`tree)); + // seems like tree widget emits 2 SelectionChanged events + if (current_file != previous_file) + { + set_entry_term (); + if (textmode) + UI::SetFocus (`id(`tree)); + } } else if (ret == `diff_snapshot) { -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jsuchome@svn2.opensuse.org