branch-policy.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. =============
  2. Branch policy
  3. =============
  4. In general, the trunk must be kept stable. People should be able to run
  5. production sites against the trunk at any time. Additionally, commits to trunk
  6. ought to be as atomic as possible -- smaller changes are better. Thus, large
  7. feature changes -- that is, changes too large to be encapsulated in a single
  8. patch, or changes that need multiple eyes on them -- must happen on dedicated
  9. branches.
  10. This means that if you want to work on a large feature -- anything that would
  11. take more than a single patch, or requires large-scale refactoring -- you need
  12. to do it on a feature branch. Our development process recognizes two options
  13. for feature branches:
  14. 1. Feature branches using a distributed revision control system like
  15. Git_, Mercurial_, Bazaar_, etc.
  16. If you're familiar with one of these tools, this is probably your best
  17. option since it doesn't require any support or buy-in from the Django
  18. core developers.
  19. However, do keep in mind that Django will continue to use Subversion
  20. for the foreseeable future, and this will naturally limit the
  21. recognition of your branch. Further, if your branch becomes eligible
  22. for merging to trunk you'll need to find a core developer familiar
  23. with your DVCS of choice who'll actually perform the merge.
  24. If you do decided to start a distributed branch of Django and choose to
  25. make it public, please add the branch to the `Django branches`_ wiki
  26. page.
  27. 2. Feature branches using SVN have a higher bar. If you want a branch
  28. in SVN itself, you'll need a "mentor" among the :doc:`core committers
  29. </internals/committers>`. This person is responsible for actually
  30. creating the branch, monitoring your process (see below), and
  31. ultimately merging the branch into trunk.
  32. If you want a feature branch in SVN, you'll need to ask in
  33. `django-developers`_ for a mentor.
  34. .. _git: http://git-scm.com/
  35. .. _mercurial: http://mercurial.selenic.com/
  36. .. _bazaar: http://bazaar.canonical.com/
  37. .. _django branches: http://code.djangoproject.com/wiki/DjangoBranches
  38. Branch rules
  39. ------------
  40. We've got a few rules for branches born out of experience with what makes a
  41. successful Django branch.
  42. DVCS branches are obviously not under central control, so we have no way of
  43. enforcing these rules. However, if you're using a DVCS, following these rules
  44. will give you the best chance of having a successful branch (read: merged back
  45. to trunk).
  46. Developers with branches in SVN, however, **must** follow these rules. The
  47. branch mentor will keep on eye on the branch and **will delete it** if these
  48. rules are broken.
  49. * Only branch entire copies of the Django tree, even if work is only
  50. happening on part of that tree. This makes it painless to switch to a
  51. branch.
  52. * Merge changes from trunk no less than once a week, and preferably every
  53. couple-three days.
  54. In our experience, doing regular trunk merges is often the difference
  55. between a successful branch and one that fizzles and dies.
  56. If you're working on an SVN branch, you should be using `svnmerge.py`_
  57. to track merges from trunk.
  58. * Keep tests passing and documentation up-to-date. As with patches,
  59. we'll only merge a branch that comes with tests and documentation.
  60. .. _svnmerge.py: http://www.orcaware.com/svn/wiki/Svnmerge.py
  61. Once the branch is stable and ready to be merged into the trunk, alert
  62. `django-developers`_.
  63. After a branch has been merged, it should be considered "dead"; write access
  64. to it will be disabled, and old branches will be periodically "trimmed."
  65. To keep our SVN wrangling to a minimum, we won't be merging from a given
  66. branch into the trunk more than once.
  67. Using branches
  68. --------------
  69. To use a branch, you'll need to do two things:
  70. * Get the branch's code through Subversion.
  71. * Point your Python ``site-packages`` directory at the branch's version of
  72. the ``django`` package rather than the version you already have
  73. installed.
  74. Getting the code from Subversion
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. To get the latest version of a branch's code, check it out using Subversion:
  77. .. code-block:: bash
  78. svn co http://code.djangoproject.com/svn/django/branches/<branch>/
  79. ...where ``<branch>`` is the branch's name. See the `list of branch names`_.
  80. Alternatively, you can automatically convert an existing directory of the
  81. Django source code as long as you've checked it out via Subversion. To do the
  82. conversion, execute this command from within your ``django`` directory:
  83. .. code-block:: bash
  84. svn switch http://code.djangoproject.com/svn/django/branches/<branch>/
  85. The advantage of using ``svn switch`` instead of ``svn co`` is that the
  86. ``switch`` command retains any changes you might have made to your local copy
  87. of the code. It attempts to merge those changes into the "switched" code. The
  88. disadvantage is that it may cause conflicts with your local changes if the
  89. "switched" code has altered the same lines of code.
  90. (Note that if you use ``svn switch``, you don't need to point Python at the
  91. new version, as explained in the next section.)
  92. .. _list of branch names: http://code.djangoproject.com/browser/django/branches
  93. .. _pointing-python-at-the-new-django-version:
  94. Pointing Python at the new Django version
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. Once you've retrieved the branch's code, you'll need to change your Python
  97. ``site-packages`` directory so that it points to the branch version of the
  98. ``django`` directory. (The ``site-packages`` directory is somewhere such as
  99. ``/usr/lib/python2.7/site-packages`` or
  100. ``/usr/local/lib/python2.7/site-packages`` or ``C:\Python\site-packages``.)
  101. The simplest way to do this is by renaming the old ``django`` directory to
  102. ``django.OLD`` and moving the trunk version of the code into the directory
  103. and calling it ``django``.
  104. Alternatively, you can use a symlink called ``django`` that points to the
  105. location of the branch's ``django`` package. If you want to switch back, just
  106. change the symlink to point to the old code.
  107. A third option is to use a path file (``<something>.pth``). This is a feature of
  108. the :mod:`site` module. First, make sure there are no files, directories or
  109. symlinks named ``django`` in your ``site-packages`` directory. Then create a
  110. text file named ``django.pth`` and save it to your ``site-packages`` directory.
  111. That file should contain a path to your copy of Django on a single line and
  112. optional comments. Here is an example that points to multiple branches. Just
  113. uncomment the line for the branch you want to use ('trunk' in this example) and
  114. make sure all other lines are commented::
  115. # Trunk is a svn checkout of:
  116. # http://code.djangoproject.com/svn/django/trunk/
  117. #
  118. /path/to/trunk
  119. # <branch> is a svn checkout of:
  120. # http://code.djangoproject.com/svn/django/branches/<branch>/
  121. #
  122. #/path/to/<branch>
  123. # On windows a path may look like this:
  124. # C:/path/to/<branch>
  125. .. _django-developers: http://groups.google.com/group/django-developers