Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 23840)
+++ wp-includes/post.php	(working copy)
@@ -1755,6 +1755,67 @@
 }
 
 /**
+ * Add versioned meta data field to a post or revision.
+ *
+ * Post meta data is called "Custom Fields" on the Administration Screen.
+ *
+ * @since 3.6.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/add_versioned_meta
+ *
+ * @param int $post_id Post or Revision ID.
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Metadata value.
+ * @param bool $unique Optional, default is false. Whether the same key should not be added.
+ * @return bool False for failure. True for success.
+ */
+function add_versioned_meta($post_id, $meta_key, $meta_value, $unique = false) {
+	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
+}
+
+/**
+ * Remove versioned metadata matching criteria from a post or revision.
+ *
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
+ *
+ * @since 3.6.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/delete_versioned_meta
+ *
+ * @param int $post_id Post or Revision ID
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Optional. Metadata value.
+ * @return bool False for failure. True for success.
+ */
+function delete_versioned_meta($post_id, $meta_key, $meta_value = '') {
+	return delete_metadata('post', $post_id, $meta_key, $meta_value);
+}
+
+/**
+ * Update versioned post meta field based on post or revision.
+ *
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and post revision ID.
+ *
+ * If the meta field for the post or revision does not exist, it will be added.
+ *
+ * @since 3.6.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/update_versioned_meta
+ *
+ * @param int $post_id Post or Revision ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @return bool False on failure, true if success.
+ */
+function update_versioned_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
+	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
+}
+
+/**
  * Retrieve post meta fields, based on post ID.
  *
  * The post meta fields are retrieved from the cache where possible,
Index: wp-includes/revision.php
===================================================================
--- wp-includes/revision.php	(revision 23840)
+++ wp-includes/revision.php	(working copy)
@@ -335,6 +335,20 @@
 	if ( is_wp_error( $post_id ) )
 		return $post_id;
 
+	// Handle versioned meta data
+	$versioned_meta = array(); // WordPress Core's versioned meta
+	$versioned_meta = apply_filters( 'versioned_meta', $versioned_meta );
+
+	foreach ( $versioned_meta as $key ) {
+		$meta = get_post_meta( $revision_id, $key );
+		delete_post_meta( $post_id, $key );
+		if ( ! empty( $meta ) ) {
+			$unique = 1 == count( $meta ) ? true : false;
+			foreach ( $meta as $value )
+				add_post_meta( $post_id, $key, $value, $unique ); 
+		}
+	}
+
 	if ( $post_id )
 		do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );
 
@@ -706,4 +720,4 @@
 	$r .= "</table>";
 
 	return array( 'html' => $r, 'linesadded' => $linesadded, 'linesdeleted' => $linesdeleted );
-	}
+}
