bk-kernel-howto.txt
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:11k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1.    Doing the BK Thing, Penguin-Style
  2. This set of notes is intended mainly for kernel developers, occasional
  3. or full-time, but sysadmins and power users may find parts of it useful
  4. as well.  It assumes at least a basic familiarity with CVS, both at a
  5. user level (use on the cmd line) and at a higher level (client-server model).
  6. Due to the author's background, an operation may be described in terms
  7. of CVS, or in terms of how that operation differs from CVS.
  8. This is -not- intended to be BitKeeper documentation.  Always run
  9. "bk help <command>" or in X "bk helptool <command>" for reference
  10. documentation.
  11. BitKeeper Concepts
  12. ------------------
  13. In the true nature of the Internet itself, BitKeeper is a distributed
  14. system.  When applied to revision control, this means doing away with
  15. client-server, and changing to a parent-child model... essentially
  16. peer-to-peer.  On the developer's end, this also represents a
  17. fundamental disruption in the standard workflow of changes, commits,
  18. and merges.  You will need to take a few minutes to think about
  19. how to best work under BitKeeper, and re-optimize things a bit.
  20. In some sense it is a bit radical, because it might described as
  21. tossing changes out into a maelstrom and having them magically
  22. land at the right destination... but I'm getting ahead of myself.
  23. Let's start with this progression:
  24. Each BitKeeper source tree on disk is a repository unto itself.
  25. Each repository has a parent.
  26. Each repository contains a set of a changesets ("csets").
  27. Each cset is one or more changed files, bundled together.
  28. Each tree is a repository, so all changes are checked into the local
  29. tree.  When a change is checked in, all modified files are grouped
  30. into a logical unit, the changeset.  Internally, BK links these
  31. changesets in a tree, representing various converging and diverging
  32. lines of development.  These changesets are the bread and butter of
  33. the BK system.
  34. After the concept of changesets, the next thing you need to get used
  35. to is having multiple copies of source trees lying around.  This -really-
  36. takes some getting used to, for some people.  Separate source trees
  37. are the means in BitKeeper by which you delineate parallel lines
  38. of development, both minor and major.  What would be branches in
  39. CVS become separate source trees, or "clones" in BitKeeper [heh,
  40. or Star Wars] terminology.
  41. Clones and changesets are the tools from which most of the power of
  42. BitKeeper is derived.  As mentioned earlier, each clone has a parent,
  43. the tree used as the source when the new clone was created.  In a
  44. CVS-like setup, the parent would be a remote server on the Internet,
  45. and the child is your local clone of that tree.
  46. Once you have established a common baseline between two source trees --
  47. a common parent -- then you can merge changesets between those two
  48. trees with ease.  Merging changes into a tree is called a "pull", and
  49. is analagous to 'cvs update'.  A pull downloads all the changesets in
  50. the remote tree you do not have, and merges them.  Sending changes in
  51. one tree to another tree is called a "push".  Push sends all changes
  52. in the local tree the remote does not yet have, and merges them.
  53. From these concepts come some initial command examples:
  54. 1) bk clone -q http://linux.bkbits.net/linux-2.5 linus-2.5
  55. Download a 2.5 stock kernel tree, naming it "linus-2.5" in the local dir.
  56. The "-q" disables listing every single file as it is downloaded.
  57. 2) bk clone -ql linus-2.5 alpha-2.5
  58. Create a separate source tree for the Alpha AXP architecture.
  59. The "-l" uses hard links instead of copying data, since both trees are
  60. on the local disk.  You can also replace the above with "bk lclone -q ..."
  61. You only clone a tree -once-.  After cloning the tree lives a long time
  62. on disk, being updating by pushes and pulls.
  63. 3) cd alpha-2.5 ; bk pull http://gkernel.bkbits.net/alpha-2.5
  64. Download changes in "alpha-2.5" repository which are not present
  65. in the local repository, and merge them into the source tree.
  66. 4) bk -r co -q
  67. Because every tree is a repository, files must be checked out before
  68. they will be in their standard places in the source tree.
  69. 5) bk vi fs/inode.c # example change...
  70. bk citool # checkin, using X tool
  71. bk push bk://gkernel@bkbits.net/alpha-2.5 # upload change
  72. Typical example of a BK sequence that would replace the analagous CVS
  73. situation,
  74. vi fs/inode.c
  75. cvs commit
  76. As this is just supposed to be a quick BK intro, for more in-depth
  77. tutorials, live working demos, and docs, see http://www.bitkeeper.com/
  78. BK and Kernel Development Workflow
  79. ----------------------------------
  80. Currently the latest 2.5 tree is available via "bk clone $URL"
  81. and "bk pull $URL" at http://linux.bkbits.net/linux-2.5
  82. This should change in a few weeks to a kernel.org URL.
  83. A big part of using BitKeeper is organizing the various trees you have
  84. on your local disk, and organizing the flow of changes among those
  85. trees, and remote trees.  If one were to graph the relationships between
  86. a desired BK setup, you are likely to see a few-many-few graph, like
  87. this:
  88.     linux-2.5
  89.         |
  90.        merge-to-linus-2.5
  91.  /    |      |
  92.         /     |      |
  93. vm-hacks  bugfixes  filesys   personal-hacks
  94.              |      | /
  95.              |      |         /
  96.      |      |        /
  97.          testing-and-validation
  98. Since a "bk push" sends all changes not in the target tree, and
  99. since a "bk pull" receives all changes not in the source tree, you want
  100. to make sure you are only pushing specific changes to the desired tree,
  101. not all changes from "peer parent" trees.  For example, pushing a change
  102. from the testing-and-validation tree would probably be a bad idea,
  103. because it will push all changes from vm-hacks, bugfixes, filesys, and
  104. personal-hacks trees into the target tree.
  105. One would typically work on only one "theme" at a time, either
  106. vm-hacks or bugfixes or filesys, keeping those changes isolated in
  107. their own tree during development, and only merge the isolated with
  108. other changes when going upstream (to Linus or other maintainers) or
  109. downstream (to your "union" trees, like testing-and-validation above).
  110. It should be noted that some of this separation is not just recommended
  111. practice, it's actually [for now] -enforced- by BitKeeper.  BitKeeper
  112. requires that changesets maintain a certain order, which is the reason
  113. that "bk push" sends all local changesets the remote doesn't have.  This
  114. separation may look like a lot of wasted disk space at first, but it
  115. helps when two unrelated changes may "pollute" the same area of code, or
  116. don't follow the same pace of development, or any other of the standard
  117. reasons why one creates a development branch.
  118. Small development branches (clones) will appear and disappear:
  119. -------- A --------- B --------- C --------- D -------
  120.                                            /
  121.    -----short-term devel branch-----
  122. While long-term branches will parallel a tree (or trees), with period
  123. merge points.  In this first example, we pull from a tree (pulls,
  124. "") periodically, such as what occurs when tracking changes in a
  125. vendor tree, never pushing changes back up the line:
  126. -------- A --------- B --------- C --------- D -------
  127.                                             
  128.            ----long-term devel branch-----------------
  129. And then a more common case in Linux kernel development, a long term
  130. branch with periodic merges back into the tree (pushes, "/"):
  131. -------- A --------- B --------- C --------- D -------
  132.                                           / 
  133.            ----long-term devel branch-----------------
  134. Submitting Changes to Linus
  135. ---------------------------
  136. There's a bit of an art, or style, of submitting changes to Linus.
  137. Since Linus's tree is now (you might say) fully integrated into the
  138. distributed BitKeeper system, there are several prerequisites to
  139. properly submitting a BitKeeper change.  All these prereq's are just
  140. general cleanliness of BK usage, so as people become experts at BK, feel
  141. free to optimize this process further (assuming Linus agrees, of
  142. course).
  143. 0) Make sure your tree was originally cloned from the linux-2.5 tree
  144. created by Linus.  If your tree does not have this as its ancestor, it
  145. is impossible to reliably exchange changesets.
  146. 1) Pay attention to your commit text.  The commit message that
  147. accompanies each changeset you submit will live on forever in history,
  148. and is used by Linus to accurately summarize the changes in each
  149. pre-patch.  Remember that there is no context, so
  150. "fix for new scheduler changes"
  151. would be too vague, but
  152. "fix mips64 arch for new scheduler switch_to(), TIF_xxx semantics"
  153. would be much better.
  154. You can and should use the command "bk comment -C<rev>" to update the
  155. commit text, and improve it after the fact.  This is very useful for
  156. development: poor, quick descriptions during development, which get
  157. cleaned up using "bk comment" before issuing the "bk push" to submit the
  158. changes.
  159. 2) Include an Internet-available URL for Linus to pull from, such as
  160. Pull from:  http://gkernel.bkbits.net/net-drivers-2.5
  161. 3) Include a summary and "diffstat -p1" of each changeset that will be
  162. downloaded, when Linus issues a "bk pull".  The author auto-generates
  163. these summaries using "bk push -nl <parent> 2>&1", to obtain a listing
  164. of all the pending-to-send changesets, and their commit messages.
  165. It is important to show Linus what he will be downloading when he issues
  166. a "bk pull", to reduce the time required to sift the changes once they
  167. are downloaded to Linus's local machine.
  168. IMPORTANT NOTE:  One of the features of BK is that your repository does
  169. not have to be up to date, in order for Linus to receive your changes.
  170. It is considered a courtesy to keep your repository fairly recent, to
  171. lessen any potential merge work Linus may need to do.
  172. 4) Split up your changes.  Each maintainer<->Linus situation is likely
  173. to be slightly different here, so take this just as general advice.  The
  174. author splits up changes according to "themes" when merging with Linus.
  175. Simultaneous pushes from local development go to special trees which
  176. exist solely to house changes "queued" for Linus.  Example of the trees:
  177. net-drivers-2.5 -- on-going net driver maintenance
  178. vm-2.5 -- VM-related changes
  179. fs-2.5 -- filesystem-related changes
  180. Linus then has much more freedom for pulling changes.  He could (for
  181. example) issue a "bk pull" on vm-2.5 and fs-2.5 trees, to merge their
  182. changes, but hold off net-drivers-2.5 because of a change that needs
  183. more discussion.
  184. Other maintainers may find that a single linus-pull-from tree is
  185. adequate for passing BK changesets to him.
  186. Frequently Answered Questions
  187. -----------------------------
  188. 1) How do I change the e-mail address shown in the changelog?
  189. A. When you run "bk citool" or "bk commit", set environment
  190.    variables BK_USER and BK_HOST to the desired username
  191.    and host/domain name.
  192. 2) How do I use tags / get a diff between two kernel versions?
  193. A. Pass the tags Linus uses to 'bk export'.
  194. ChangeSets are in a forward-progressing order, so it's pretty easy
  195. to get a snapshot starting and ending at any two points in time.
  196. Linus puts tags on each release and pre-release, so you could use
  197. these two examples:
  198.     bk export -tpatch -hdu -rv2.5.4,v2.5.5 | less
  199.         # creates patch-2.5.5 essentially
  200.     bk export -tpatch -du -rv2.5.5-pre1,v2.5.5 | less
  201.         # changes from pre1 to final
  202. A tag is just an alias for a specific changeset... and since changesets
  203. are ordered, a tag is thus a marker for a specific point in time (or
  204. specific state of the tree).