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

</pre>
<p><a href="https://github.com/macports/macports-base/commit/54e2ad502764c19322adb2d5baea0175708cca4d">https://github.com/macports/macports-base/commit/54e2ad502764c19322adb2d5baea0175708cca4d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 54e2ad502764c19322adb2d5baea0175708cca4d
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Mon Aug 28 03:42:09 2017 +0530

<span style='display:block; white-space:pre;color:#404040;'>    Add function to extract the id of a snapshot
</span>---
 src/cregistry/snapshot.c      |  1 +
 src/registry2.0/snapshotobj.c | 27 ++++++++++++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/snapshot.c b/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;color:#808080;'>index b3d967e..79877a8 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -519,6 +519,7 @@ int reg_snapshot_ports_get(reg_snapshot* snapshot, port*** ports, reg_error* err
</span>         }
     }
     reg_sqlite_error(reg->db, errPtr, query);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    return -1;
</span> }
 
 /**
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/snapshotobj.c b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 5b94b52..eb06d8f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -40,12 +40,35 @@
</span> #include "util.h"
 
 const char* snapshot_props[] = {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    "id",
</span>     "note",
     "ports",
     "created_at",
     NULL
 };
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* ${snapshot} id */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static int snapshot_obj_id(Tcl_Interp* interp, reg_snapshot* snapshot, int objc,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        Tcl_Obj* CONST objv[]) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    int index;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (objc > 3) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        Tcl_WrongNumArgs(interp, 2, objv, "?value?");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        return TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (objc == 2) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        /* ${snapshot} id; return the current value */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        char value[sizeof(snapshot->id)+1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        sprintf(value, "%lld", snapshot->id);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        if (Tcl_GetIndexFromObj(interp, objv[1], snapshot_props, "prop", 0, &index)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                == TCL_OK) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            Tcl_Obj* result = Tcl_NewStringObj(value, -1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            Tcl_SetObjResult(interp, result);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+            return TCL_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    return TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> /* ${snapshot} prop */
 static int snapshot_obj_prop(Tcl_Interp* interp, reg_snapshot* snapshot, int objc,
         Tcl_Obj* CONST objv[]) {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -73,7 +96,6 @@ static int snapshot_obj_prop(Tcl_Interp* interp, reg_snapshot* snapshot, int obj
</span>             }
             return registry_failed(interp, &error);
         }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        return TCL_ERROR;
</span>     }
     return TCL_ERROR;
 }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -127,8 +149,6 @@ static int snapshot_obj_ports(Tcl_Interp* interp, reg_snapshot* snapshot, int ob
</span>                 }
             }
             return registry_failed(interp, &error);
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-            return TCL_ERROR;
</span>         }
     }
     return TCL_ERROR;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -142,6 +162,7 @@ typedef struct {
</span> 
 static snapshot_obj_cmd_type snapshot_cmds[] = {
     /* keys */
<span style='display:block; white-space:pre;background:#e0ffe0;'>+    { "id", snapshot_obj_id },
</span>     { "note", snapshot_obj_prop },
     { "created_at", snapshot_obj_prop },
     /* ports */
</pre><pre style='margin:0'>

</pre>