<pre style='margin:0'>
Umesh Singla (umeshksingla) pushed a commit to branch gsoc17-migrate
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/273676d5cc561ca07acc9e3f0b44a9c894c9fab7">https://github.com/macports/macports-base/commit/273676d5cc561ca07acc9e3f0b44a9c894c9fab7</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 273676d5cc561ca07acc9e3f0b44a9c894c9fab7
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Wed Jul 12 23:37:25 2017 +0530

<span style='display:block; white-space:pre;color:#404040;'>    Store the current state (imaged/installed) of the port in snapshot
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Again, state
</span><span style='display:block; white-space:pre;color:#404040;'>    imaged is installed but inactive, while
</span><span style='display:block; white-space:pre;color:#404040;'>    installed is installed and active
</span>---
 src/cregistry/entry.c | 16 ++++++++++------
 src/cregistry/sql.c   |  2 ++
 2 files changed, 12 insertions(+), 6 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.c b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 049cf89..092a46e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1351,24 +1351,28 @@ int snapshot_store_ports(reg_registry* reg, reg_entry* snap_entry, reg_error* er
</span> 
     char* key1 = "name";
     char* key2 = "requested";
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    char* key3 = "state";
</span> 
     if (entry_count >= 0) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        for ( i = 0; i < entry_count; i++){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        for ( i = 0; i < entry_count; i++) {
</span>             char* port_name;
             char* requested;
<span style='display:block; white-space:pre;background:#e0ffe0;'>+            char* state;
</span>             sqlite3_stmt* stmt = NULL;
             reg_entry* entry = NULL;
<span style='display:block; white-space:pre;background:#ffe0e0;'>-            if(reg_entry_propget(entries[i], key1, &port_name, &error)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                && reg_entry_propget(entries[i], key2, &requested, &error)){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            if (reg_entry_propget(entries[i], key1, &port_name, &error)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && reg_entry_propget(entries[i], key2, &requested, &error)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                && reg_entry_propget(entries[i], key3, &state, &error)) {
</span>                 
                 char* query = "INSERT INTO registry.snapshot_ports "
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                    "(snapshots_id, port_name, requested) "
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    "VALUES (?, ?, ?)";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    "(snapshots_id, port_name, requested, state) "
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    "VALUES (?, ?, ?, ?)";
</span>                 
                 if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
                         && (sqlite3_bind_int64(stmt, 1, snap_entry->id) == SQLITE_OK)
                         && (sqlite3_bind_text(stmt, 2, port_name, -1, SQLITE_STATIC) == SQLITE_OK)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                        && (sqlite3_bind_int64(stmt, 3, atoi(requested)) == SQLITE_OK)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        && (sqlite3_bind_int64(stmt, 3, atoi(requested)) == SQLITE_OK)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        && (sqlite3_bind_text(stmt, 4, state, -1, SQLITE_STATIC) == SQLITE_OK)) {
</span>                     int r;
                     do {
                         r = sqlite3_step(stmt);
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/sql.c b/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;color:#808080;'>index aad6aa4..cfd029f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/sql.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -208,6 +208,7 @@ int create_tables(sqlite3* db, reg_error* errPtr) {
</span>             ", snapshots_id INTEGER"
             ", port_name TEXT COLLATE NOCASE"
             ", requested INTEGER"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+            ", state TEXT COLLATE NOCASE"
</span>             ", FOREIGN KEY(snapshots_id) REFERENCES snapshots(id)"
             " ON DELETE CASCADE"
             ")",
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -646,6 +647,7 @@ int update_db(sqlite3* db, reg_error* errPtr) {
</span>                     ", snapshots_id INTEGER"
                     ", port_name TEXT COLLATE NOCASE"
                     ", requested INTEGER"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+                    ", state TEXT COLLATE NOCASE"
</span>                     ", FOREIGN KEY(snapshots_id) REFERENCES snapshots(id)"
                     " ON DELETE CASCADE"
                     ")",
</pre><pre style='margin:0'>

</pre>