From b09c7985bfedf3d097f51889ff74c9bef34f21e3 Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Fri, 11 Mar 2011 16:50:27 -0600
Subject: [PATCH] Issue #1089852: Add a weigth field to {versioncontrol operations} tables so we can order commits.

---
 includes/VersioncontrolOperation.php |    7 +++++++
 versioncontrol.install               |   22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/includes/VersioncontrolOperation.php b/includes/VersioncontrolOperation.php
index e559c50..880d650 100644
--- a/includes/VersioncontrolOperation.php
+++ b/includes/VersioncontrolOperation.php
@@ -115,6 +115,13 @@ abstract class VersioncontrolOperation extends VersioncontrolEntity {
    */
   public $itemRevisions = array();
 
+  /**
+   * A weight to be used on operation listing.
+   *
+   * @var int
+   */
+  public $weight = 0;
+
   protected $defaultCrudOptions = array(
     'update' => array('nested' => TRUE, 'map users' => FALSE),
     'insert' => array('nested' => TRUE, 'map users' => FALSE),
diff --git a/versioncontrol.install b/versioncontrol.install
index 9921982..79a7c52 100644
--- a/versioncontrol.install
+++ b/versioncontrol.install
@@ -89,6 +89,12 @@ function versioncontrol_schema() {
         'type' => 'text',
         'not null' => FALSE,
       ),
+      'weight' => array(
+        'description' =>
+          'A field to help ordering operations.',
+        'type' => 'int',
+        'not null' => FALSE,
+      ),
     ),
     'indexes' => array(
       'type' => array('type'),
@@ -1210,3 +1216,19 @@ function versioncontrol_update_6316() {
   db_add_index($ret, 'versioncontrol_item_revisions','vc_op_id', array('vc_op_id'));
   return $ret;
 }
+
+/**
+ * Add a {versioncontrol_operations}.weight field.
+ */
+function versioncontrol_update_6317() {
+  $ret = array();
+  $spec = array(
+    'description' =>
+    'A field to help ordering operations.',
+    'type' => 'int',
+    'not null' => FALSE,
+    'default' => 0,
+  );
+  db_add_field($ret, 'versioncontrol_operations', 'weight', $spec);
+  //TODO Update the table to have better default than 0
+}
-- 
1.7.2.3

