Index: uuid.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.admin.inc,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 uuid.admin.inc
--- uuid.admin.inc	28 Jul 2010 18:10:55 -0000	1.1.2.7
+++ uuid.admin.inc	8 Sep 2010 10:54:18 -0000
@@ -65,6 +65,22 @@
     }
   }
 
+  $form['comment'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Comment settings'),
+  );
+  $form['comment']['uuid_automatic_for_comments'] = array(
+    '#type' => 'radios',
+    '#title' => t('Automatic UUID generation for comments'),
+    '#default_value' => variable_get('uuid_automatic_for_comments', FALSE),
+    '#options' => array(
+      TRUE => t('Enabled'),
+      FALSE => t('Disabled'),
+    ),
+    '#description' => t('Should UUIDs be created automatically for comments?'),
+  );
+
+
   $form['settings'] = array(
     '#type' => 'fieldset',
     '#title' => t('Synchronization'),
@@ -91,6 +107,14 @@
     }
   }
 
+  // Comments.
+  if (variable_get('uuid_automatic_for_comments', FALSE)) {
+    $result = db_query("SELECT cid FROM {comments} WHERE cid NOT IN (SELECT cid FROM {uuid_comments})");
+    while($item = db_fetch_object($result)) {
+      db_query("INSERT INTO {uuid_comments} (uid, uuid) VALUES(%d, '%s')", $item->cid, uuid_uuid());
+    }
+  }
+
   $types = variable_get('uuid_automatic_for_nodes', array());
 
   // Remove disabled node types.
Index: uuid.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.install,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 uuid.install
--- uuid.install	2 Apr 2010 02:20:38 -0000	1.1.2.8
+++ uuid.install	8 Sep 2010 10:54:18 -0000
@@ -107,3 +107,14 @@
 
   return $ret;
 }
+
+/**
+ * Create uuid_comment table.
+ */
+function uuid_update_6003() {
+  $ret = array();
+
+  db_create_table($ret, 'uuid_comments', uuid_table_schema('comments', 'cid'));
+
+  return $ret;
+}
Index: uuid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid/uuid.module,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 uuid.module
--- uuid.module	7 Sep 2010 23:33:50 -0000	1.1.2.12
+++ uuid.module	8 Sep 2010 10:54:19 -0000
@@ -203,6 +203,39 @@
 }
 
 /**
+ * Implementation of hook_comment().
+ */
+function uuid_comment(&$a1, $op) {
+  switch ($op) {
+    // Make sure that a new entry gets made in the comments_uuid table when new content
+    // is added.
+    case 'insert':
+      if (!empty($a1['uuid']) && uuid_is_valid($a1['uuid'])) {
+        db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], $a1['uuid']);
+      }
+      else if (variable_get('uuid_automatic_for_comments', FALSE)) {
+        db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], uuid_uuid());
+      }
+      break;
+      
+    case 'update':
+      if (isset($a1['uuid']) && uuid_is_valid($a1['uuid'])) {
+        $exists = db_result(db_query('SELECT 1 FROM {uuid_comments} WHERE cid = %d', $a1['cid']));
+
+        if (!$exists && variable_get('uuid_automatic_for_comments', FALSE)) {
+          db_query("INSERT INTO {uuid_comments} (cid, uuid) VALUES (%d, '%s')", $a1['cid'], uuid_uuid());
+        }
+      }
+      break;
+
+    // Clean up comments_uuid table when content is deleted.
+    case 'delete':
+      db_query("DELETE FROM {uuid_comments} WHERE cid = %d", $a1->cid);
+      break;
+  }
+}
+
+/**
  * Determines if a UUID is valid.
  */
 function uuid_is_valid($uuid) {
