贡献代码

You are viewing an old version of this article. View the current version here.

这个部分包含了贡献代码需要的指导文档和相应规则。如果你有任何疑问,你可以访问:maria-developers 或者是在Freenode 的#maria IRC 频道提问。其他如Email一类的联系方式请点击

大部分有关MariaDB的开发信息可以 点击

找寻可以参与的项目。

这里你将发现很多有关MariaDB的,开放的开发项目。

  • 我们都是用JIRA 管理MariaDB项目。通过访问 https://jira.mariadb.org 或者点击"Projects"获得MariaDB项目。 访问 悬而未决的问题,看看是否有你感兴趣的问题。其中一些可能有赞助商支持,如果你能解决,将会得到相应的报酬。
  • Join maria-developers and write to the maria-developers \at\ lists.launchpad.net list and ask for suggestions of tasks you could do. Please include your programming experience and your knowledge of the MariaDB source and how much you know about using MySQL/MariaDB with the email so that we know which tasks we can suggest to you.
  • If this is your first project, check out the Suggested Development page. It lists projects that will make a good start.
  • Join irc:irc.freenode.net/maria on Freenode IRC and ask for suggestions.

If you have your own ideas, please submit them to JIRA so other MariaDB developers can comment on them and suggest how to implement them. You can of course also use the maria-developers list for this.

Prerequisites

You need Bazaar for revision control.

bzr Login Setup

  • Get a launchpad account at https://launchpad.net/+login
  • When logged in, setup your SSH keys
    • Click your name (top right corner)
    • Click Change Details link (upper right)
    • Click SSH Keys button (middle of page)
    • Upload your public SSH key (How do I get a public key?)
  • Register yourself with launchpad from your local commandline: bzr launchpad-login [yourloginid]

Getting the Maria Code

  1. First, get a clean copy of the MariaDB code (for some, the fastest way to get up and running is to follow the instructions in the "Source Tree Tarball" section).
  1. Once you have a clean copy of the source, create a working copy for your changes:
cd $maria-repo # ex: ~/repos/maria
bzr branch trunk maria-fix-bugNNNNNN
cd maria-fix-bugNNNNNN

Tip: Use descriptive names such as maria-fix-bugNNNNNN (where NNNNNN is the bug # of course).

  1. You should now be ready to Compile MariaDB. It's a good idea to compile at this stage to confirm the source tree you are going to be hacking on works . . . before you make any changes.

The following pages will help you get up and running with the MariaDB source code:

Setting up tests

The Maria test suite is contained in the ./mysql-test/ subdirectory of the source tree. The mysql-test directory has two subdirectories of utmost concern to you, the bug fixer: the t/ directory and the r/ directory (for "tests" and "results" respectively). Be sure to check and see if your bug already has a test too.

All the tests are found in the t/ directory. Open up the file that corresponds to the functionality you are changing (or add a new file) and add the commands that will reproduce the bug or validate the new functionality.

For example, the test below creates a new test table "t1"; shows us the result of that CREATE TABLE statement; and lastly, we cleanup the test by dropping the test table:

#
# Bug #XXXXXX: INET_ATON() returns signed, not unsigned
#
create table t1 select INET_ATON('255.255.0.1') as `a`;
show create table t1;
drop table t1;

By adding your test first, it will remind you to re-record the test output file later (and inform future efforts about your expected output, of course). Now it's time to make your changes.

Examine existing tests to get a better idea of how you should write your test.

We are always on the lookout for better tests, so if you create new test or improve an existing test, please upload it to the "private" folder on our FTP server and then ping us on IRC or send a note to the Maria-Developers mailing list to let us know about it.

Editing and adding to your contribution

With a working version, you can commence making changes in your new branch, committing code regularly to your local working copy; feel free to commit early and often as you will formalize your contribution later with a push and proposal.

cd $maria-repo/maria-fix-bugNNNNNN
# Make Changes
bzr commit -m "Merge comment"

Prior to publishing your completed work, you need to confirm that your branch works as expected and update the test runs.

To allow others to see your commits, you should configure bzr to send its commit emails to commits@mariadb.org email list.

Testing your branch

Make sure you have at least libtool 1.5.22 (found here).

First, check to see that all the tests pass (remember the test you set up earlier? It should fail. That's ok, you will re-record it momentarily):

cd $maria-repo/mysql-test
./mysql-test-run

Any that fail will need to be re-recorded.

cd $maria-repo/mysql-test
./mysql-test-run --record $test # where $test is the name of the test that failed 

You are now ready to merge into trunk.

Merging recent changes

It is important to merge any changes from trunk into your branch before pushing or publishing.

Update your local trunk.

cd $maria-repo 
cd trunk
bzr pull   

Updating your local branch.

cd $maria-repo
cd maria-fix-bugNNNNNN
bzr merge ../trunk
bzr commit -m "Merged from trunk"

Conflicts can be resolved in bazaar via:

bzr resolve $filename

To revert to your last commit on your branch use:

bzr revert $filename

(Note you will need to remerge with trunk before pushing)

Verify differences carefully

bzr diff

Publish your branch

When all changes are merged and your changes are all consistent you can push your branch to LaunchPad

cd $maria-repos/$your-branch # where $your-branch is the branch you want to push (ex: maria-bugNNNN)
bzr push lp:~[yourloginid]/maria/$your-branch

If you find that this takes a very long time (eg. >30 minutes), you may want to try using 'bzr init-repo --format=1.9' to initialize a new repo and merge your work into it, then push again.

Propose branch

On your Launchpad Code page https://code.launchpad.net/~{yourloginid}/maria/{branch-name} click the Propose for merging into another branch link to propose branch to the maintainers to be merged into the main trunk.

Getting your code into the main MariaDB tree.

All code in MariaDB comes from one of the following sources:

  • MySQL
  • Developed by people employed by Monty Program Ab.
  • Code shared with Monty Program Ab under the MCA.
  • Code with a known origin that is under a permissive license (BSD or public domain).

If you want the code to be part of the main MariaDB tree, you also have to give Monty Program Ab a shared copyright to your code. This is needed so that Monty Program Ab can give your code forwards to other projects (like MySQL).

You do this by either:

  1. Signing the MariaDB Contributor Agreement (MCA) and then scanning and sending it to us.
  2. Sending an email to maria-developers where you say that your patch and all fixes to it are provided to the MariaDB Foundation under the MCA.
  3. Licensing your code using the BSD license.

We need shared copyright for the following reasons:

  1. to defend the copyright or GPL if someone breaks it (this is the same reason the Free Software Foundation also requires copyright assignment for its code)
  2. to be able to donate code to MySQL (for example to fix security bugs or new features)
  3. to allow people who have a non-free license to the MySQL code to also use MariaDB (the MCA/BSD allows us to give those companies the rights to all changes between MySQL and MariaDB so they can use MariaDB instead of MYSQL)

More information about the MCA can be found on the MCA FAQ page.

Fix Branch (if needed)

If fixes are needed on your branch you will need to: make the changes, re-merge any new changes to trunk, commit and re-push; you do not need to re-propose. After the push, LaunchPad will pick up the changes automagically.

Please be aware that changes can take a few minutes for LaunchPad to merge your new changes into your proposal.

Resubmit Proposal

At the moment, this is a tricky process, and none of the "Request another review" links work.

To resubmit a merge proposal, follow these steps: On the main page of the merge proposal, the top line will be something like "Status: Needs Review". Just to the right of this is a small button; click on this to change the status. Select "Resubmit" from the drop down menu and click "Change Status". The next page should prompt you to resubmit the merge proposal and inform you that the new proposal will supersede the old one; click "Resubmit" to finish.

A couple of easy ways to get attention to your proposed merge are:

  • Join the #maria IRC channel on freenode ask people to review/discuss your merge.
  • Subscribe to and send an email to the maria-developers group on Launchpad.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.