Author: jsuchome
Date: Wed Apr 13 09:08:29 2011
New Revision: 63768
URL: http://svn.opensuse.org/viewcvs/yast?rev=63768&view=rev
Log:
generate file index also in the agent
Modified:
trunk/snapper/agent-snapper/src/SnapperAgent.cc
trunk/snapper/src/Snapper.ycp
trunk/snapper/src/dialogs.ycp
Modified: trunk/snapper/agent-snapper/src/SnapperAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/SnapperAgent.cc?rev=63768&r1=63767&r2=63768&view=diff
==============================================================================
--- trunk/snapper/agent-snapper/src/SnapperAgent.cc (original)
+++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Wed Apr 13 09:08:29 2011
@@ -167,39 +167,52 @@
return retlist;
}
+ unsigned int num1 = getIntValue (argmap, "from", 0);
+ unsigned int num2 = getIntValue (argmap, "to", 0);
+
/**
* Read(.snapper.diff_list) -> show difference between snapnots num1 and num2 as list.
*/
if (PC(0) == "diff_list") {
YCPList retlist;
- unsigned int num1 = getIntValue (argmap, "from", 0);
- unsigned int num2 = getIntValue (argmap, "to", 0);
const Snapshots& snapshots = sh->getSnapshots();
-
const Comparison comparison(sh, snapshots.find(num1), snapshots.find(num2));
-
const Files& files = comparison.getFiles();
+
for (Files::const_iterator it = files.begin(); it != files.end(); ++it)
{
YCPMap filemap;
filemap->add (YCPString ("name"), YCPString (it->getName()));
- // FIXME it's PreToPostStatus!
filemap->add (YCPString ("changes"), YCPString (statusToString (it->getPreToPostStatus())));
retlist->add (filemap);
}
return retlist;
}
/**
+ * Read(.snapper.diff_index) -> show difference between snapnots num1 and num2 as one-level map:
+ * (mapping each file to its changes)
+ */
+ if (PC(0) == "diff_index") {
+ YCPMap retmap;
+
+ const Snapshots& snapshots = sh->getSnapshots();
+ const Comparison comparison(sh, snapshots.find(num1), snapshots.find(num2));
+ const Files& files = comparison.getFiles();
+
+ for (Files::const_iterator it = files.begin(); it != files.end(); ++it)
+ {
+ retmap->add (YCPString (it->getName()), YCPString (statusToString (it->getPreToPostStatus())));
+ }
+ return retmap;
+ }
+ /**
* Read(.snapper.diff_tree) -> show difference between snapnots num1 and num2 as tree.
*/
else if (PC(0) == "diff_tree")
{
Tree ret1;
- unsigned int num1 = getIntValue(argmap, "from", 0);
- unsigned int num2 = getIntValue(argmap, "to", 0);
-
const Snapshots& snapshots = sh->getSnapshots();
const Comparison comparison(sh, snapshots.find(num1), snapshots.find(num2));
const Files& files = comparison.getFiles();
Modified: trunk/snapper/src/Snapper.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Snapper.ycp?rev=63768&r1=63767&r2=63768&view=diff
==============================================================================
--- trunk/snapper/src/Snapper.ycp (original)
+++ trunk/snapper/src/Snapper.ycp Wed Apr 13 09:08:29 2011
@@ -53,10 +53,18 @@
global integer selected_snapshot_index = 0;
/**
- * Return list of files modified between given snapshots
- * File is a map with name (path) and some parameters
+ * Return map of files modified between given snapshots
+ * Return structure has just one level, and maps each modified file to it's modification map
*/
-global map ReadModifiedFiles (integer from, integer to) {
+global map ReadModifiedFilesIndex (integer from, integer to) {
+ return (map) SCR::Read (.snapper.diff_index, $[ "from" : from, "to" : to]);
+}
+
+/**
+ * Return map of files modified between given snapshots
+ * Map is recursively describing the filesystem structure; helps to build Tree widget contents
+ */
+global map ReadModifiedFilesMap (integer from, integer to) {
return (map) SCR::Read (.snapper.diff_tree, $[ "from" : from, "to" : to]);
}
Modified: trunk/snapper/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/dialogs.ycp?rev=63768&r1=63767&r2=63768&view=diff
==============================================================================
--- trunk/snapper/src/dialogs.ycp (original)
+++ trunk/snapper/src/dialogs.ycp Wed Apr 13 09:08:29 2011
@@ -180,9 +180,9 @@
map snapshot = Snapper::selected_snapshot;
integer snapshot_num = snapshot["num"]:0;
+ // map of whole tree (recursive)
map tree_map = snapshot["tree_map"]:$[];
integer previous_num = snapshot["pre_num"]:snapshot_num;
-
integer pre_index = Snapper::id2index[previous_num]:0;
string description = Snapper::snapshots[pre_index,"description"]:"";
string pre_date = timestring ("%c", Snapper::snapshots[pre_index,"date"]:0, false);
@@ -198,45 +198,53 @@
}
});
- if (!haskey (snapshot, "files"))
+ integer from = snapshot_num;
+ integer to = 0; // current system
+ if (snapshot["type"]:`NONE == `POST)
{
- integer from = snapshot_num;
- integer to = 0; // current system
- if (snapshot["type"]:`NONE == `POST)
- {
- from = snapshot["pre_num"]:0;
- to = snapshot_num;
- }
- else if (snapshot["type"]:`NONE == `PRE)
- {
- to = snapshot["post_num"]:0;
- }
- // busy popup message
- Popup::ShowFeedback ("", _("Calculating changed files..."));
- snapshot["tree_map"] = Snapper::ReadModifiedFiles (from, to);
+ from = snapshot["pre_num"]:0;
+ to = snapshot_num;
+ }
+ else if (snapshot["type"]:`NONE == `PRE)
+ {
+ to = snapshot["post_num"]:0;
+ }
+
+ // busy popup message
+ Popup::ShowFeedback ("", _("Calculating changed files..."));
+
+ if (!haskey (snapshot, "tree_map"))
+ {
+ snapshot["tree_map"] = Snapper::ReadModifiedFilesMap (from, to);
Popup::ClearFeedback ();
tree_map = snapshot["tree_map"]:$[];
- // update the global snapshots list
+ }
+ // full paths of files marked as modified, mapping to changes string
+ map files_index = $[];
+ if (!haskey (snapshot, "files_index"))
+ {
+ snapshot["files_index"] = Snapper::ReadModifiedFilesIndex (from, to);
Snapper::snapshots[Snapper::selected_snapshot_index] = snapshot;
}
+ files_index = snapshot["files_index"]:$[];
+
+ // update the global snapshots list
+ Snapper::snapshots[Snapper::selected_snapshot_index] = snapshot;
string snapshot_name = tostring (snapshot_num);
// map of all items in tree (just one level)
map selected_items = $[];
- // save full paths of files marked as modified
- map files_index = $[];
-
// go through the map defining filesystem tree and create the widget items
list<term> generate_tree_items (string current_path, map current_branch) {
list<term> ret = [];
foreach (string node, map branch, current_branch, {
string new_path = current_path + "/" + node;
- if (files_index[new_path]:$[] != $[])
+ if (haskey (files_index, new_path))
{
- string changes = files_index[new_path,"changes"]:"";
+ string changes = files_index[new_path]:"";
string icon_f = "16x16/apps/gdu-smart-unknown.png";
if (substring (changes, 0, 1) == "+")
{
@@ -347,7 +355,7 @@
// create the term for selected file
void set_entry_term () {
- if (current_file != "" && files_index[current_file]:$[] != $[])
+ if (current_file != "" && haskey (files_index, current_file))
{
if (type == `SINGLE)
{
@@ -496,7 +504,7 @@
if (ret == `tree && event["EventReason"]:"" == "ValueChanged")
{
// non-tracked file (so, it should be directory)
- if (current_file != "" && files_index[current_file]:$[] == $[])
+ if (current_file != "" && ! haskey (files_index, current_file))
{
void select_items (map current_map, string prefix) {
selected_items[prefix] = ! selected_items[prefix]:false;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org