| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Version Control API - An interface to version control systems
|
| 6 |
* whose functionality is provided by pluggable back-end modules.
|
| 7 |
*
|
| 8 |
* Copyright 2006 by Karthik ("Zen", http://drupal.org/user/21209)
|
| 9 |
* Copyright 2006, 2007 by Derek Wright ("dww", http://drupal.org/user/46549)
|
| 10 |
* Copyright 2007, 2008, 2009 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)
|
| 11 |
*/
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Implementation of hook_schema().
|
| 15 |
*/
|
| 16 |
function versioncontrol_schema() {
|
| 17 |
$schema['versioncontrol_operations'] = array(
|
| 18 |
'description' => 'The combined table for commit, branch and tag operations.',
|
| 19 |
'fields' => array(
|
| 20 |
'vc_op_id' => array(
|
| 21 |
'description' => 'Unique identifier for each operation in this table. Does not necessarily correspond to chronological order in any way.',
|
| 22 |
'type' => 'serial',
|
| 23 |
'unsigned' => TRUE,
|
| 24 |
'not null' => TRUE,
|
| 25 |
),
|
| 26 |
'type' => array(
|
| 27 |
'description' =>
|
| 28 |
'Operation type as specified by the backend: either of VERSIONCONTROL_OPERATION_COMMIT, VERSIONCONTROL_OPERATION_BRANCH or VERSIONCONTROL_OPERATION_TAG. (For version control systems like Subversion that need to emulate branches and tags, this will still be VERSIONCONTROL_OPERATION_COMMIT - the "intended" meaning is stored as associated label action.)',
|
| 29 |
'type' => 'int',
|
| 30 |
'size' => 'tiny',
|
| 31 |
'unsigned' => TRUE,
|
| 32 |
'not null' => TRUE,
|
| 33 |
'default' => 0,
|
| 34 |
),
|
| 35 |
'repo_id' => array(
|
| 36 |
'description' => 'Foreign key (referring to {versioncontrol_repositories}.repo_id) for the repository that was affected by the operation.',
|
| 37 |
'type' => 'int',
|
| 38 |
'unsigned' => TRUE,
|
| 39 |
'not null' => TRUE,
|
| 40 |
'default' => 0,
|
| 41 |
),
|
| 42 |
'date' => array(
|
| 43 |
'description' => 'Date/time when the operation was executed, as Unix timestamp.',
|
| 44 |
'type' => 'int',
|
| 45 |
'size' => 'big',
|
| 46 |
'not null' => TRUE,
|
| 47 |
'default' => 0,
|
| 48 |
),
|
| 49 |
'uid' => array(
|
| 50 |
'description' =>
|
| 51 |
'The {users}.uid for the Drupal user corresponding to the VCS-specific username in {versioncontrol_operations}.username, if such an association can be found. 0 otherwise. (The account associations are retrieved from the {versioncontrol_accounts} table.',
|
| 52 |
'type' => 'int',
|
| 53 |
'unsigned' => TRUE,
|
| 54 |
'not null' => TRUE,
|
| 55 |
'default' => 0,
|
| 56 |
),
|
| 57 |
'author' => array(
|
| 58 |
'description' => 'VCS specific username of the user who is the original author of this operation. For centralized version control systems this and committer are the same.',
|
| 59 |
'type' => 'varchar',
|
| 60 |
'length' => 64,
|
| 61 |
'not null' => TRUE,
|
| 62 |
'default' => '',
|
| 63 |
),
|
| 64 |
'committer' => array(
|
| 65 |
'description' => 'VCS specific username of the user who executed this operation. For distributed version control systems, this should be the author, not the committer. For centralized version control systems this and author are the same.',
|
| 66 |
'type' => 'varchar',
|
| 67 |
'length' => 64,
|
| 68 |
'not null' => TRUE,
|
| 69 |
'default' => '',
|
| 70 |
),
|
| 71 |
'revision' => array(
|
| 72 |
'description' =>
|
| 73 |
'VCS specific global revision identifier, like "1234" for Subversion or some SHA-1 hash for various distributed version control systems. Empty string if the VCS does not support atomic commits / global revisions.',
|
| 74 |
'type' => 'varchar',
|
| 75 |
'length' => 255,
|
| 76 |
'not null' => TRUE,
|
| 77 |
'default' => '',
|
| 78 |
),
|
| 79 |
'message' => array(
|
| 80 |
'description' =>
|
| 81 |
'Log message. Might be empty for branch and tag operations, depending on the version control system\'s capabilities. Should really not be empty for commit messages, except for the super-evil case when the commit author is sloppy enough not to enter one *and* the VCS allows that to happen.',
|
| 82 |
'type' => 'text',
|
| 83 |
'not null' => FALSE,
|
| 84 |
),
|
| 85 |
),
|
| 86 |
'indexes' => array(
|
| 87 |
'type' => array('type'),
|
| 88 |
'repo_id' => array('repo_id'),
|
| 89 |
'date' => array('date'),
|
| 90 |
'uid' => array('uid'),
|
| 91 |
'author' => array('author'),
|
| 92 |
'committer' => array('committer'),
|
| 93 |
'revision' => array('revision'),
|
| 94 |
),
|
| 95 |
'primary key' => array('vc_op_id'),
|
| 96 |
);
|
| 97 |
|
| 98 |
$schema['versioncontrol_operation_labels'] = array(
|
| 99 |
'description' =>
|
| 100 |
'This table contains information about which branches and/or tags (= labels, referred to by the label_id) have been affected by an operation (vc_op_id), and how they\'ve been affected (action). Let\'s refer to that combination as "label action".
|
| 101 |
|
| 102 |
Commit operations might not have any label associated, which happens e.g. for SVN commits outside of /trunk, /tags and /branches (or if labels are neither natively supported nor emulated).
|
| 103 |
|
| 104 |
Possible label actions are:
|
| 105 |
- Commit: commit operation, label is a branch, action == VERSIONCONTROL_ACTION_MODIFIED
|
| 106 |
- Native branch/tag creation: branch or tag operation, label has the
|
| 107 |
same type as the operation, action == VERSIONCONTROL_ACTION_ADDED
|
| 108 |
- Native branch/tag deletion: branch or tag operation, label has the
|
| 109 |
same type as the operation, action == VERSIONCONTROL_ACTION_DELETED
|
| 110 |
- Emulated branch/tag creation or deletion (think of SVN branches and
|
| 111 |
tags): commit operation, any label type, action is the same as for
|
| 112 |
native creations/deletions.',
|
| 113 |
'fields' => array(
|
| 114 |
'vc_op_id' => array(
|
| 115 |
'description' => 'Foreign key (referring to {versioncontrol_operations}.vc_op_id) for the operation that affected the given label(s).',
|
| 116 |
'type' => 'int',
|
| 117 |
'unsigned' => TRUE,
|
| 118 |
'not null' => TRUE,
|
| 119 |
'default' => 0,
|
| 120 |
),
|
| 121 |
'label_id' => array(
|
| 122 |
'description' => 'Foreign key (referring to {versioncontrol_labels}.label_id) for the affected label.',
|
| 123 |
'type' => 'int',
|
| 124 |
'unsigned' => TRUE,
|
| 125 |
'not null' => TRUE,
|
| 126 |
'default' => 0,
|
| 127 |
),
|
| 128 |
'action' => array(
|
| 129 |
'description' =>
|
| 130 |
'Specifies how the label was affected, see the {versioncontrol_operation_labels} table description for details on the semantics. Possible values are VERSIONCONTROL_ACTION_MODIFIED, VERSIONCONTROL_ACTION_ADDED and VERSIONCONTROL_ACTION_DELETED.',
|
| 131 |
'type' => 'int',
|
| 132 |
'size' => 'tiny',
|
| 133 |
'unsigned' => TRUE,
|
| 134 |
'not null' => TRUE,
|
| 135 |
'default' => 0,
|
| 136 |
),
|
| 137 |
),
|
| 138 |
'primary key' => array('vc_op_id', 'label_id'),
|
| 139 |
);
|
| 140 |
|
| 141 |
$schema['versioncontrol_labels'] = array(
|
| 142 |
'description' =>
|
| 143 |
'This table stores information about branches and tags (= labels) that exist in a repository. While there might be multiple operations involving the same branch/tag (see also {versioncontrol_operation_labels}, e.g. "create DRUPAL-6--1-0 tag for the files in project 1", "create DRUPAL-6--1-0 tag for the files in project 2", "delete DRUPAL-6--1-0 tag for the files in project 2 again"), there is only one row in this table that represents this label ("DRUPAL-6--1-0" in the above example).',
|
| 144 |
'fields' => array(
|
| 145 |
'label_id' => array(
|
| 146 |
'description' => 'Unique identifier for a branch or tag in this label, equivalent to the (also unique) repo_id/name/type combination in the same row.',
|
| 147 |
'type' => 'serial',
|
| 148 |
'unsigned' => TRUE,
|
| 149 |
'not null' => TRUE,
|
| 150 |
),
|
| 151 |
'repo_id' => array(
|
| 152 |
'description' => 'Foreign key (referring to {versioncontrol_repositories}.repo_id) for the repository that this label is located in.',
|
| 153 |
'type' => 'int',
|
| 154 |
'unsigned' => TRUE,
|
| 155 |
'not null' => TRUE,
|
| 156 |
'default' => 0,
|
| 157 |
),
|
| 158 |
'name' => array(
|
| 159 |
'description' => 'Name of the label, e.g. "HEAD", "master", "DRUPAL-6--1" or "6.x-1.0".',
|
| 160 |
'type' => 'varchar',
|
| 161 |
'length' => 255,
|
| 162 |
'not null' => TRUE,
|
| 163 |
'default' => '',
|
| 164 |
),
|
| 165 |
'type' => array(
|
| 166 |
'description' =>
|
| 167 |
'Whether this label is a branch or a tag. Consequently, this can be either VERSIONCONTROL_LABEL_BRANCH or VERSIONCONTROL_LABEL_TAG.',
|
| 168 |
'type' => 'int',
|
| 169 |
'size' => 'tiny',
|
| 170 |
'unsigned' => TRUE,
|
| 171 |
'not null' => TRUE,
|
| 172 |
'default' => 0,
|
| 173 |
),
|
| 174 |
),
|
| 175 |
'unique keys' => array(
|
| 176 |
'repo_id_name_type' => array('repo_id', 'name', 'type'),
|
| 177 |
),
|
| 178 |
'primary key' => array('label_id'),
|
| 179 |
);
|
| 180 |
|
| 181 |
$schema['versioncontrol_operation_items'] = array(
|
| 182 |
'description' =>
|
| 183 |
'This table relates an operation to the items (or more correctly, to the item revisions) that it affected. For example, an SVN commit with revision "1234" might modify an item that is now /trunk/file.txt at revision "1234", and move a directory from somewhere else that is now /trunk/dir at revision "1234". Those items are recorded here along with the vc_op_id that describes the general operation properties.
|
| 184 |
|
| 185 |
Branch/tag operations that affect the whole repository (like in Git or Mercurial) do not have items associated, whereas branch/tag operations that affect only a limited set of items (like in CVS or Subversion) link to the branched/tagged items with this table.',
|
| 186 |
'fields' => array(
|
| 187 |
'vc_op_id' => array(
|
| 188 |
'description' => 'Foreign key (referring to {versioncontrol_operations}.vc_op_id) for the operation that affected the given item(s).',
|
| 189 |
'type' => 'int',
|
| 190 |
'unsigned' => TRUE,
|
| 191 |
'not null' => TRUE,
|
| 192 |
'default' => 0,
|
| 193 |
),
|
| 194 |
'item_revision_id' => array(
|
| 195 |
'description' => 'Foreign key (referring to {versioncontrol_item_revisions}.item_revision_id) for the affected item revision.',
|
| 196 |
'type' => 'int',
|
| 197 |
'unsigned' => TRUE,
|
| 198 |
'not null' => TRUE,
|
| 199 |
'default' => 0,
|
| 200 |
),
|
| 201 |
'type' => array(
|
| 202 |
'description' =>
|
| 203 |
'Real member or cached item. This is an implementation detail of a performance optimization (for queries with a "paths" constraint), and private to the API module. Other modules must not touch this. VERSIONCONTROL_OPERATION_MEMBER_ITEM is the standard value and makes up for most entries in here, whereas VERSIONCONTROL_OPERATION_CACHED_AFFECTED_ITEM is the optimization (denoting an item that is not part of a VersioncontrolOperation::getItems() result but will still cause that operation to be found if it matches the "paths" constraint).',
|
| 204 |
'type' => 'int',
|
| 205 |
'size' => 'tiny',
|
| 206 |
'unsigned' => TRUE,
|
| 207 |
'not null' => TRUE,
|
| 208 |
'default' => 0,
|
| 209 |
),
|
| 210 |
),
|
| 211 |
'indexes' => array(
|
| 212 |
'type' => array('type'),
|
| 213 |
),
|
| 214 |
'primary key' => array('vc_op_id', 'item_revision_id'),
|
| 215 |
);
|
| 216 |
|
| 217 |
$schema['versioncontrol_source_items'] = array(
|
| 218 |
'description' =>
|
| 219 |
'This table stores item history, i.e. it relates an item to one or more direct predecessors (= source items). Likewise, a source item can also have multiple successors, for example if it\'s copied to one location and later (or at the same time) moved to another location.',
|
| 220 |
'fields' => array(
|
| 221 |
'item_revision_id' => array(
|
| 222 |
'description' =>
|
| 223 |
'Foreign key for the successor item, referring to {versioncontrol_item_revisions}.item_revision_id. This one is more recent in revision history than the source item.',
|
| 224 |
'type' => 'int',
|
| 225 |
'unsigned' => TRUE,
|
| 226 |
'not null' => TRUE,
|
| 227 |
'default' => 0,
|
| 228 |
),
|
| 229 |
'source_item_revision_id' => array(
|
| 230 |
'description' =>
|
| 231 |
'Foreign key for the source item - also referring to {versioncontrol_item_revisions}.item_revision_id, but to a different one than the above {versioncontrol_source_items}.item_revision_id. Contains 0 if the action is VERSIONCONTROL_ACTION_ADDED.',
|
| 232 |
'type' => 'int',
|
| 233 |
'unsigned' => TRUE,
|
| 234 |
'not null' => TRUE,
|
| 235 |
'default' => 0,
|
| 236 |
),
|
| 237 |
'action' => array(
|
| 238 |
'description' =>
|
| 239 |
'Action that was performed while transforming the source item into the successor item. Can be one of the VERSIONCONTROL_ACTION_* values listed at the top of versioncontrol.module.
|
| 240 |
|
| 241 |
The VERSIONCONTROL_ACTION_DELETED and VERSIONCONTROL_ACTION_REPLACED actions are considered to be the end in the history of an item, no further successors than the current one should be retrieved. (For VERSIONCONTROL_ACTION_DELETED, item_revision_id links to a deleted item. For VERSIONCONTROL_ACTION_REPLACED, item_revision_id links to a different item at the same path that replaced the item specified by source_item_revision_id.
|
| 242 |
|
| 243 |
Likewise, the VERSIONCONTROL_ACTION_ADDED action is considered the beginning, with source_item_revision_id being 0 in that case.',
|
| 244 |
'type' => 'int',
|
| 245 |
'size' => 'tiny',
|
| 246 |
'unsigned' => TRUE,
|
| 247 |
'not null' => TRUE,
|
| 248 |
'default' => 0,
|
| 249 |
),
|
| 250 |
'line_changes_recorded' => array(
|
| 251 |
'description' =>
|
| 252 |
'Specifies whether line-change information is available (1 as value) or not (0 as value). Naturally, this should only apply to file items, not to directory items. VERSIONCONTROL_ACTION_DELETED and VERSIONCONTROL_ACTION_REPLACED actions are also not supposed to contain line-change information.',
|
| 253 |
'type' => 'int',
|
| 254 |
'size' => 'tiny',
|
| 255 |
'unsigned' => TRUE,
|
| 256 |
'not null' => TRUE,
|
| 257 |
'default' => 0,
|
| 258 |
),
|
| 259 |
'line_changes_added' => array(
|
| 260 |
'description' =>
|
| 261 |
'If the line_changes_recorded column is 1 then this column contains the amount of lines that was added to the file compared to its source revision. (Equivalent to the "plus" lines in a unified diff.)',
|
| 262 |
'type' => 'int',
|
| 263 |
'unsigned' => TRUE,
|
| 264 |
'not null' => TRUE,
|
| 265 |
'default' => 0,
|
| 266 |
),
|
| 267 |
'line_changes_removed' => array(
|
| 268 |
'description' =>
|
| 269 |
'If the line_changes_recorded column is 1 then this column contains the amount of lines that was removed from the file compared to its source revision. (Equivalent to the "minus" lines in a unified diff.)',
|
| 270 |
'type' => 'int',
|
| 271 |
'unsigned' => TRUE,
|
| 272 |
'not null' => TRUE,
|
| 273 |
'default' => 0,
|
| 274 |
),
|
| 275 |
),
|
| 276 |
'primary key' => array('item_revision_id', 'source_item_revision_id'),
|
| 277 |
);
|
| 278 |
|
| 279 |
$schema['versioncontrol_item_revisions'] = array(
|
| 280 |
'description' =>
|
| 281 |
'This table contains all known different versions of a file or directory item. For version control systems using global revisions, only the revisions should be recorded in here when the item was actually changed, i.e. part of a commit operation. (Not every revision needs to have all associated items recorded in here, that would be insane.) Non-versioned items, such as directories in CVS or Git, should not be recorded in this table.',
|
| 282 |
'fields' => array(
|
| 283 |
'item_revision_id' => array(
|
| 284 |
'description' =>
|
| 285 |
'Unique identifier for this item revision. The same item in a different revision gets a different item_revision_id. Equivalent to the (also unique) repo_id/path/revision combination in the same row.',
|
| 286 |
'type' => 'serial',
|
| 287 |
'unsigned' => TRUE,
|
| 288 |
'not null' => TRUE,
|
| 289 |
),
|
| 290 |
'repo_id' => array(
|
| 291 |
'description' => 'Foreign key (referring to {versioncontrol_repositories}.repo_id) for the repository that this item is located in.',
|
| 292 |
'type' => 'int',
|
| 293 |
'unsigned' => TRUE,
|
| 294 |
'not null' => TRUE,
|
| 295 |
'default' => 0,
|
| 296 |
),
|
| 297 |
'path' => array(
|
| 298 |
'description' =>
|
| 299 |
'Path of the item, relative to the repository root. Always starts with a slash, and never ends with one (not even if the item is a directory). Examples: "/" (root directory), "/contributions", "/sandbox/jpetso/evil-plans.txt". The slash is only used for separating the parts of the path, so it is safe to use explode("/", $path).',
|
| 300 |
'type' => 'varchar',
|
| 301 |
'length' => 255,
|
| 302 |
'not null' => TRUE,
|
| 303 |
'default' => '',
|
| 304 |
),
|
| 305 |
'revision' => array(
|
| 306 |
'description' =>
|
| 307 |
'(File-level) revision of the item, such as "1.12.4.3" for CVS. If the version control system supports global revisions, this should contain the same revision as the "revision" property of the associated commit operation. Contrary to {versioncontrol_operations}.revision which may be empty, this column must always contain a revision because every changed item has a revision assigned. (If it lacks a revision, it should not be recorded as operation item in the first place.)',
|
| 308 |
'type' => 'varchar',
|
| 309 |
'length' => 255,
|
| 310 |
'not null' => TRUE,
|
| 311 |
'default' => '',
|
| 312 |
),
|
| 313 |
'type' => array(
|
| 314 |
'description' =>
|
| 315 |
'Specifies whether the item is a file or directory, and whether it exists or is deleted. Deleted items might exist for real, such as in CVS repositories (the "Attic") or they might just be recorded as part of a commit operation where the item was deleted, even though the version control system does not know about this revision. In Version Control API, deleted items only exist for display purposes, backends are expected not to retrieve information about them other than item history. Possible values for the item type are VERSIONCONTROL_ITEM_FILE, VERSIONCONTROL_ITEM_FILE_DELETED, VERSIONCONTROL_ITEM_DIRECTORY and VERSIONCONTROL_ITEM_DIRECTORY_DELETED. Usually though, API users should only use the functions VersioncontrolItem::isFile(), VersioncontrolItem::isDirectory() and VersioncontrolItem::isDeleted() for testing these constants.',
|
| 316 |
'type' => 'int',
|
| 317 |
'size' => 'tiny',
|
| 318 |
'unsigned' => TRUE,
|
| 319 |
'not null' => TRUE,
|
| 320 |
'default' => 0,
|
| 321 |
),
|
| 322 |
),
|
| 323 |
// Key too long, cannot create an index for this unique key.
|
| 324 |
//'unique keys' => array(
|
| 325 |
// 'repo_id_path_revision' => array('repo_id', 'path', 'revision'),
|
| 326 |
//),
|
| 327 |
// So instead, we roll two separate indexes.
|
| 328 |
'indexes' => array(
|
| 329 |
'repo_id_path' => array('repo_id', 'path'),
|
| 330 |
'revision' => array('revision'),
|
| 331 |
),
|
| 332 |
'primary key' => array('item_revision_id'),
|
| 333 |
);
|
| 334 |
|
| 335 |
$schema['versioncontrol_repositories'] = array(
|
| 336 |
'description' => 'This table contains the set of repositories known to the Version Control API.',
|
| 337 |
'fields' => array(
|
| 338 |
'repo_id' => array(
|
| 339 |
'description' => 'Primary key, the unique identifier for the repository.',
|
| 340 |
'type' => 'serial',
|
| 341 |
'unsigned' => TRUE,
|
| 342 |
'not null' => TRUE,
|
| 343 |
),
|
| 344 |
'name' => array(
|
| 345 |
'description' => 'User visible name of the repository, to be run through check_plain().',
|
| 346 |
'type' => 'varchar',
|
| 347 |
'length' => 255,
|
| 348 |
'not null' => TRUE,
|
| 349 |
'default' => '',
|
| 350 |
),
|
| 351 |
'vcs' => array(
|
| 352 |
'description' => 'Unique string identifier of the backend, e.g. "cvs", "svn" or "git".',
|
| 353 |
'type' => 'varchar',
|
| 354 |
'length' => 8,
|
| 355 |
'not null' => TRUE,
|
| 356 |
'default' => '',
|
| 357 |
),
|
| 358 |
'root' => array(
|
| 359 |
'description' => 'Root URL/path of the repository, to be interpreted by the VCS backend when it interfaces with the repository.',
|
| 360 |
'type' => 'varchar',
|
| 361 |
'length' => 255,
|
| 362 |
'not null' => TRUE,
|
| 363 |
'default' => '',
|
| 364 |
),
|
| 365 |
'authorization_method' => array(
|
| 366 |
'description' => 'Unique string identifier of the authorization method. (For more information on authorization methods, see hook_versioncontrol.php for functions marked with "@ingroup Authorization".)',
|
| 367 |
'type' => 'varchar',
|
| 368 |
'length' => 64,
|
| 369 |
'not null' => TRUE,
|
| 370 |
'default' => '',
|
| 371 |
),
|
| 372 |
'data' => array(
|
| 373 |
'description' => t('A serialized array of additional per-repository settings, mostly populated by third-party modules.'),
|
| 374 |
'type' => 'text',
|
| 375 |
'size' => 'medium',
|
| 376 |
'not null' => TRUE,
|
| 377 |
'serialize' => TRUE,
|
| 378 |
),
|
| 379 |
),
|
| 380 |
'unique keys' => array(
|
| 381 |
'name' => array('name'),
|
| 382 |
),
|
| 383 |
'primary key' => array('repo_id'),
|
| 384 |
);
|
| 385 |
|
| 386 |
$schema['versioncontrol_accounts'] = array(
|
| 387 |
'description' =>
|
| 388 |
'Association table of VCS account usernames (in a specific repository) to Drupal user ids. A Drupal user can be associated to multiple VCS accounts. Ideally, multiple VCS accounts per repository should be possible too, but clumsy array data structures and assumptions in the admin interface (elsewhere, too? don\'t know) currently make it necessary to restrict the number of VCS accounts to a maximum of 1 per repository and Drupal user.',
|
| 389 |
'fields' => array(
|
| 390 |
'uid' => array(
|
| 391 |
'description' => 'The {users}.uid of the Drupal user associated with the VCS-specific username in {versioncontrol_accounts}.username.',
|
| 392 |
'type' => 'int',
|
| 393 |
'unsigned' => TRUE,
|
| 394 |
'not null' => TRUE,
|
| 395 |
'default' => 0,
|
| 396 |
),
|
| 397 |
'repo_id' => array(
|
| 398 |
'description' => 'Foreign key (referring to {versioncontrol_repositories}.repo_id) for the repository that contains the VCS account.',
|
| 399 |
'type' => 'int',
|
| 400 |
'unsigned' => TRUE,
|
| 401 |
'not null' => TRUE,
|
| 402 |
'default' => 0,
|
| 403 |
),
|
| 404 |
'username' => array(
|
| 405 |
'description' => 'VCS-specific username of the VCS account associated with the Drupal user in {versioncontrol_accounts}.uid.',
|
| 406 |
'type' => 'varchar',
|
| 407 |
'length' => 64,
|
| 408 |
'not null' => TRUE,
|
| 409 |
'default' => '',
|
| 410 |
),
|
| 411 |
),
|
| 412 |
'unique keys' => array(
|
| 413 |
'repo_id_username' => array('repo_id', 'username'),
|
| 414 |
),
|
| 415 |
'primary key' => array('uid', 'repo_id'),
|
| 416 |
);
|
| 417 |
|
| 418 |
return $schema;
|
| 419 |
}
|
| 420 |
|
| 421 |
/**
|
| 422 |
* Implementation of hook_install().
|
| 423 |
*/
|
| 424 |
function versioncontrol_install() {
|
| 425 |
// Create tables.
|
| 426 |
drupal_install_schema('versioncontrol');
|
| 427 |
}
|
| 428 |
|
| 429 |
/**
|
| 430 |
* Implementation of hook_uninstall().
|
| 431 |
*/
|
| 432 |
function versioncontrol_uninstall() {
|
| 433 |
$variables = array(
|
| 434 |
'versioncontrol_email_address',
|
| 435 |
'versioncontrol_registration_message_unauthorized',
|
| 436 |
'versioncontrol_registration_message_authorized',
|
| 437 |
'versioncontrol_admin_account_pager',
|
| 438 |
);
|
| 439 |
foreach ($variables as $variable) {
|
| 440 |
variable_del($variable);
|
| 441 |
}
|
| 442 |
|
| 443 |
// Remove tables.
|
| 444 |
drupal_uninstall_schema('versioncontrol');
|
| 445 |
}
|
| 446 |
|
| 447 |
|
| 448 |
// Update functions. To be named versioncontrol_update_xyzz(), where x is the
|
| 449 |
// major version of Drupal core, y is the major version of Version Control API
|
| 450 |
// for this version of Drupal core, and zz is a consecutive number.
|
| 451 |
|
| 452 |
// versioncontrol_update_9() was the last update on Drupal 5.x (-2.x).
|
| 453 |
|
| 454 |
/**
|
| 455 |
* Original update from 5.x-2.x to 6.x-2.x:
|
| 456 |
* Change 5.x pure integer types to 6.x serial types.
|
| 457 |
*/
|
| 458 |
function versioncontrol_update_6100() {
|
| 459 |
$ret = array();
|
| 460 |
|
| 461 |
// Auto-increment fields don't like 0 values.
|
| 462 |
// So let's remove the "empty" item and implement it in some other way.
|
| 463 |
$ret = update_sql('DELETE FROM {versioncontrol_item_revisions}
|
| 464 |
WHERE item_revision_id = 0');
|
| 465 |
|
| 466 |
db_drop_primary_key($ret, 'versioncontrol_operations');
|
| 467 |
db_change_field($ret, 'versioncontrol_operations', 'vc_op_id', 'vc_op_id',
|
| 468 |
array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 469 |
array('primary key' => array('vc_op_id'))
|
| 470 |
);
|
| 471 |
db_drop_primary_key($ret, 'versioncontrol_labels');
|
| 472 |
db_change_field($ret, 'versioncontrol_labels', 'label_id', 'label_id',
|
| 473 |
array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 474 |
array('primary key' => array('label_id'))
|
| 475 |
);
|
| 476 |
db_drop_primary_key($ret, 'versioncontrol_item_revisions');
|
| 477 |
db_change_field($ret, 'versioncontrol_item_revisions', 'item_revision_id', 'item_revision_id',
|
| 478 |
array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 479 |
array('primary key' => array('item_revision_id'))
|
| 480 |
);
|
| 481 |
db_drop_primary_key($ret, 'versioncontrol_repositories');
|
| 482 |
db_change_field($ret, 'versioncontrol_repositories', 'repo_id', 'repo_id',
|
| 483 |
array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 484 |
array('primary key' => array('repo_id'))
|
| 485 |
);
|
| 486 |
|
| 487 |
return $ret;
|
| 488 |
}
|
| 489 |
|
| 490 |
/**
|
| 491 |
* Update from 6.x-1.0-rc1 to rc2:
|
| 492 |
* String deltas for the "active developers" block.
|
| 493 |
*/
|
| 494 |
function versioncontrol_update_6101() {
|
| 495 |
$ret = array();
|
| 496 |
$ret[] = update_sql("
|
| 497 |
UPDATE {blocks} SET delta = 'site_active_developers'
|
| 498 |
WHERE delta = '0' AND module = 'versioncontrol'");
|
| 499 |
return $ret;
|
| 500 |
}
|
| 501 |
|
| 502 |
/**
|
| 503 |
* Update from 6.x-1.0-rc2 to 6.x-1.0-rc3:
|
| 504 |
* Add a "data" column for modules to put their per-repository settings,
|
| 505 |
* and migrate the registration texts as well as the previously global option
|
| 506 |
* "allow unauthorized commit access" to the data column for all repositories.
|
| 507 |
*
|
| 508 |
* Per-repository settings of the Commit Restrictions module is also migrated
|
| 509 |
* in this function - for convenience, as otherwise we would need some extra
|
| 510 |
* logic to prevent its updates as long as the data column doesn't yet exist.
|
| 511 |
*/
|
| 512 |
function versioncontrol_update_6102() {
|
| 513 |
$ret = array();
|
| 514 |
$spec = array(
|
| 515 |
'description' => t('A serialized array of additional per-repository settings, mostly populated by third-party modules.'),
|
| 516 |
'type' => 'text',
|
| 517 |
'size' => 'medium',
|
| 518 |
'not null' => TRUE,
|
| 519 |
'serialize' => TRUE,
|
| 520 |
);
|
| 521 |
db_add_field($ret, 'versioncontrol_repositories', 'data', $spec);
|
| 522 |
|
| 523 |
$global_access = (bool) variable_get('versioncontrol_allow_unauthorized_access', 0);
|
| 524 |
$data_template = array(
|
| 525 |
'versioncontrol' => array('allow_unauthorized_access' => $global_access),
|
| 526 |
);
|
| 527 |
|
| 528 |
// Get all repository ids. Some of the data arrays might get changed still,
|
| 529 |
// so we don't write them all at once.
|
| 530 |
$result = db_query('
|
| 531 |
SELECT r.repo_id, m.registration_message
|
| 532 |
FROM {versioncontrol_repositories} r
|
| 533 |
LEFT JOIN {versioncontrol_repository_metadata} m
|
| 534 |
ON r.repo_id = m.repo_id'
|
| 535 |
);
|
| 536 |
while ($repository = db_fetch_object($result)) {
|
| 537 |
$repository_data[$repository->repo_id] = $data_template;
|
| 538 |
$repository_data[$repository->repo_id]['versioncontrol']['registration_message'] =
|
| 539 |
$repository->registration_message;
|
| 540 |
}
|
| 541 |
|
| 542 |
// Migrate Commit Restrictions module settings into the $data array,
|
| 543 |
// and delete the module's table after all data has been migrated.
|
| 544 |
if (db_table_exists('commit_restrictions')) {
|
| 545 |
$result = db_query('
|
| 546 |
SELECT repo_id, allowed_paths, forbidden_paths, deny_undefined_paths,
|
| 547 |
valid_branch_tag_paths, valid_branches, valid_tags
|
| 548 |
FROM {commit_restrictions}'
|
| 549 |
);
|
| 550 |
|
| 551 |
while ($restrictions = db_fetch_array($result)) {
|
| 552 |
$repo_id = $restrictions['repo_id'];
|
| 553 |
|
| 554 |
$restrictions = array_filter(array(
|
| 555 |
'allowed_paths' => array_filter(explode(' ', $restrictions['allowed_paths'])),
|
| 556 |
'forbidden_paths' => array_filter(explode(' ', $restrictions['forbidden_paths'])),
|
| 557 |
'valid_branch_tag_paths' => array_filter(explode(' ', $restrictions['valid_branch_tag_paths'])),
|
| 558 |
'valid_branches' => array_filter(explode(' ', $restrictions['valid_branches'])),
|
| 559 |
'valid_tags' => array_filter(explode(' ', $restrictions['valid_tags'])),
|
| 560 |
));
|
| 561 |
if (!empty($restrictions['deny_undefined_paths'])) {
|
| 562 |
$restrictions['deny_undefined_paths'] = (bool) $restrictions['deny_undefined_paths'];
|
| 563 |
}
|
| 564 |
if (!empty($restrictions)) {
|
| 565 |
$repository_data[$repo_id]['commit_restrictions'] = $restrictions;
|
| 566 |
}
|
| 567 |
}
|
| 568 |
db_drop_table($ret, 'commit_restrictions');
|
| 569 |
}
|
| 570 |
|
| 571 |
// Write the $data array to the respective repositories.
|
| 572 |
foreach ($repository_data as $repo_id => $data) {
|
| 573 |
$ret[] = update_sql("UPDATE {versioncontrol_repositories}
|
| 574 |
SET data = '". db_escape_string(serialize($data)) ."'
|
| 575 |
WHERE repo_id = ". $repo_id);
|
| 576 |
}
|
| 577 |
|
| 578 |
db_drop_table($ret, 'versioncontrol_repository_metadata');
|
| 579 |
variable_del('versioncontrol_allow_unauthorized_access');
|
| 580 |
|
| 581 |
$ret[] = array(
|
| 582 |
'success' => TRUE,
|
| 583 |
'query' => 'Deleted the global "versioncontrol_allow_unauthorized_access" variable, and migrated it to be a per-repository setting.',
|
| 584 |
);
|
| 585 |
|
| 586 |
return $ret;
|
| 587 |
}
|
| 588 |
|
| 589 |
/**
|
| 590 |
* Update 6300 (from 6.x-2.0 to 6.x-3.0):
|
| 591 |
* Adding author and commiter instead of only username
|
| 592 |
* Move urls to data array.
|
| 593 |
* Drop url_backend field from repo table
|
| 594 |
*/
|
| 595 |
function versioncontrol_update_6300() {
|
| 596 |
$ret = array();
|
| 597 |
|
| 598 |
// author and committer
|
| 599 |
$author_spec = array(
|
| 600 |
'description' => 'VCS specific username of the user who is the original author of this operation. For centralized version control systems this and committer are the same.',
|
| 601 |
'type' => 'varchar',
|
| 602 |
'length' => 64,
|
| 603 |
'not null' => TRUE,
|
| 604 |
'default' => '',
|
| 605 |
);
|
| 606 |
$committer_spec = array(
|
| 607 |
'description' => 'VCS specific username of the user who executed this operation. For distributed version control systems, this should be the author, not the committer. For centralized version control systems this and author are the same.',
|
| 608 |
'type' => 'varchar',
|
| 609 |
'length' => 64,
|
| 610 |
'not null' => TRUE,
|
| 611 |
'default' => '',
|
| 612 |
);
|
| 613 |
db_change_field($ret, 'versioncontrol_operations', 'username', 'author', $author_spec);
|
| 614 |
db_add_field($ret, 'versioncontrol_operations', 'committer', $committer_spec);
|
| 615 |
|
| 616 |
// urls to data array
|
| 617 |
$repos = VersioncontrolRepositoryCache::getInstance()->getAllRepositories();
|
| 618 |
$result = db_query('SELECT * FROM {versioncontrol_repository_urls}');
|
| 619 |
while ($urls = db_fetch_array($result)) {
|
| 620 |
$repo_id = $urls['repo_id'];
|
| 621 |
unset($urls['repo_id']);
|
| 622 |
$repos[$repo_id]->data['versioncontrol']['url_handler'] = new VersioncontrolRepositoryUrlHandler($repos[$repo_id], $urls);
|
| 623 |
$repos[$repo_id]->update();
|
| 624 |
}
|
| 625 |
db_drop_table($ret, 'versioncontrol_repository_urls');
|
| 626 |
|
| 627 |
// no more url backend
|
| 628 |
db_drop_field($ret, 'versioncontrol_repositories', 'url_backend');
|
| 629 |
|
| 630 |
return $ret;
|
| 631 |
}
|