/[drupal]/contributions/modules/versioncontrol_hg/versioncontrol_hg.install
ViewVC logotype

Contents of /contributions/modules/versioncontrol_hg/versioncontrol_hg.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download) (as text)
Sun Feb 3 04:05:20 2008 UTC (21 months, 3 weeks ago) by ezyang
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-RC1, HEAD
Changes since 1.7: +1 -3 lines
File MIME type: text/x-php
Trim schema's extraneous elements that are not implemented.
1 <?php
2
3 // $Id: versioncontrol_hg.install,v 1.7 2008/02/03 03:24:35 ezyang Exp $
4
5 /**
6 * @file
7 * Mercurial backend for Version Control API.
8 *
9 * Copyright 2008 by Edward Z. Yang (ezyang, http://drupal.org/user/211688)
10 */
11
12 /**
13 * Implementation of hook_install().
14 */
15 function versioncontrol_hg_install() {
16 switch ($GLOBALS['db_type']) {
17 case 'mysqli':
18 case 'mysql':
19 // 'latest_rev' is the most recent repository-specific revision number
20 // that has been processed and added to the database, or NULL if
21 // no revisions have been inserted (the equivalent of -1)
22 db_query("CREATE TABLE {versioncontrol_hg_repositories} (
23 repo_id int unsigned NOT NULL default 0,
24 latest_rev int unsigned NULL,
25 PRIMARY KEY (repo_id)
26 ) /*!40100 DEFAULT CHARACTER SET utf8 */");
27
28 // In Mercurial vocab, this should be named "versioncontrol_hg_changesets",
29 // however we call it commits to piggy back off of AUTOCOMMIT
30 //
31 // 'manifest' is the node ID of the repository state after that commit,
32 // also effectively unique. NULL = '0000000000000000000000000000000000000000'.
33 // 'rev' is a repository-specific shorthand revision number, tied
34 // to manifest. NULL = -1
35 // 'parent1' and 'parent2' are the vc_op_id of the parent changesets
36 // of the commit. If there is no parent, NULL is set.
37
38 db_query("CREATE TABLE {versioncontrol_hg_commits} (
39 vc_op_id int unsigned NOT NULL default 0,
40 branch_id int unsigned NOT NULL default 0,
41 rev int unsigned NULL,
42 manifest varchar(255) NULL,
43 parent1 int signed NULL,
44 parent2 int signed NULL,
45 PRIMARY KEY (vc_op_id),
46 UNIQUE KEY (manifest),
47 UNIQUE KEY (rev)
48 ) /*!40100 DEFAULT CHARACTER SET utf8 */");
49
50 // sourceX_path corresponds to parentX in the commit log.
51 // sourceX_Y values can be NULL depending on merge status.
52 // There are no file-specific revisions that we track (Mercurial
53 // does have internal ones, but they are not easily accessible),
54 // so we defer this contains the last operation in which the item
55 // was changed.
56 db_query("CREATE TABLE {versioncontrol_hg_commit_actions} (
57 commit_action_id int unsigned NOT NULL default 0,
58 vc_op_id int unsigned NOT NULL default 0,
59 action tinyint unsigned NOT NULL default 0,
60 type tinyint NOT NULL default 0,
61 path varchar(255) NOT NULL default '',
62 source1_path varchar(255) NULL,
63 source2_path varchar(255) NULL,
64 source1_vc_op_id int unsigned NULL,
65 source2_vc_op_id int unsigned NULL,
66 PRIMARY KEY (commit_action_id),
67 UNIQUE KEY (vc_op_id, path)
68 ) /*!40100 DEFAULT CHARACTER SET utf8 */");
69
70 // Mercurial tags apply to changesets, not files
71 db_query("CREATE TABLE {versioncontrol_hg_tags} (
72 tag_id int unsigned NOT NULL default 0,
73 repo_id int unsigned NOT NULL default 0,
74 name varchar(255) NOT NULL default 'default',
75 vc_op_id int unsigned NOT NULL default 0,
76 PRIMARY KEY (tag_id),
77 UNIQUE KEY (repo_id, name)
78 ) /*!40100 DEFAULT CHARACTER SET utf8 */");
79
80 break;
81 }
82 }
83
84 /**
85 * Implementation of hook_uninstall().
86 */
87 function versioncontrol_hg_uninstall() {
88 // Make sure we can access the required functions even from the .install file.
89 include_once(drupal_get_path('module', 'versioncontrol') .'/versioncontrol.module');
90 include_once(drupal_get_path('module', 'versioncontrol_hg') .'/versioncontrol_hg.module');
91
92 if (db_table_exists('versioncontrol_repositories')) {
93 $result = db_query("SELECT repo_id FROM {versioncontrol_repositories}
94 WHERE vcs = 'hg'");
95 while ($repository = db_fetch_array($result)) {
96 versioncontrol_delete_repository($repository);
97 }
98 }
99
100 db_query('DROP TABLE {versioncontrol_hg_repositories}');
101 db_query('DROP TABLE {versioncontrol_hg_commits}');
102 db_query('DROP TABLE {versioncontrol_hg_commit_actions}');
103 db_query('DROP TABLE {versioncontrol_hg_tags}');
104 }
105

  ViewVC Help
Powered by ViewVC 1.1.2