⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rcs.ms

📁 早期freebsd实现
💻 MS
📖 第 1 页 / 共 4 页
字号:
arrowbox "2.2"arrow dashed.ps +2.PE.ce 1Figure 2.  A slender revision tree..sp 0Now imagine a customer requesting a fix ofa problem in revision 1.3, although actual development has moved onto release 2.  RCS does not permit an extrarevision to be spliced in between 1.3 and 2.1, since that would not reflectthe actual development history.  Instead, create a branchat revision 1.3, and check in the fix on that branch.The first branch starting at 1.3 has number 1.3.1, andthe revisions on that branch are numbered 1.3.1.1, 1.3.1.2, etc.The double numbering is needed to allow for anotherbranch at 1.3, say 1.3.2.Revisions on the second branch would be numbered1.3.2.1, 1.3.2.2, and so on.The following steps createbranch 1.3.1 and add revision 1.3.1.1:.sp 0.I.nr VS 12p.vs 12p.TStab(%);l l l.     %co  \-r1.3  f.c% \*- check out revision 1.3     %edit  f.c% \*- change it     %ci  \-r1.3.1  f.c% \*- check it in on branch 1.3.1.TE.nr VS 18p.vs 18p.RThis sequence of commands transforms the tree of Figure 2 intothe one in Figure 3.Note that it may be necessary to incorporate the differencesbetween 1.3 and 1.3.1.1into a revision at level 2.  The operation \fIrcsmerge\fR automates thisprocess (see the Appendix)..ne 7.PS  4i.ps -2     box "1.1"     arrow     box "1.2"     arrowR13: box "1.3"     arrowR21: box "2.1"     arrowR22: box "2.2"     arrow dashed     line invis down from R21.sRB1: box "1.3.1.1"     arrow dashed right from RB1.e     arrow from R13.s to RB1.w.ps +2.PE.ce 1Figure 3.  A revision tree with one side branch.sp.IP "\fIDistributed development and customer modifications\fR".sp 0Assume a situation as in Figure 2, where revision 1.3 is in operationat several customer sites,while release 2 is in development.Customer sites should use RCS to store the distributed software.However, customer modifications should not be placed on the same branchas the distributed source; instead, they should be placed on a side branch.When the next software distribution arrives,it should be appended to the trunk ofthe customer's RCS file, and the customercan then merge the local modifications back into the new release.In the above example, acustomer's RCS file would contain the following tree, assumingthat the customer has received revision 1.3, added his local modificationsas revision 1.3.1.1, then received revision 2.4, and merged2.4 and 1.3.1.1, resulting in 2.4.1.1..ne 7.PS  4i.ps -2R13: box "1.3"     line invisR21: box invis     line invisR22: box invis     line invisR24: box "2.4"     line invisR25: box invis     line invis     arrow from R13.e to R24.w     line invis down from R21.sRB1: box "1.3.1.1"     arrow from R13.s to RB1.w     right     line invis down from R25.sRB2: box "2.4.1.1"     arrow from R24.s to RB2.w.ps +2.PE.ce 1Figure 4.  A customer's revision tree with local modifications..sp 1This approach is actually practiced in the CSNET project,where several universities and a company cooperatein developing a national computer network..IP "\fIParallel development\fR".sp 0Sometimes it is desirable to explore an alternate design ora different implementation technique in parallel with themain line development.  Such developmentshould be carried out on a side branch.The experimental changes may later be moved into the main line, or abandoned..IP "\fIConflicting updates\fR".sp 0A common occurrence is that one programmerhas checked out a revision, but cannot complete the assignmentfor some reason.  In the meantime, another personmust perform another modificationimmediately.  In that case, the second person should check-out the same revision,modify it, and check it in on a side branch, for later merging..PPEvery node in a revision tree consists of the following attributes:a revision number, a check-in date and time, the author's identification,a log entry, a state and the actual text.  All these attributesare determined at the time the revision is checked in.The state attribute indicates the status of a revision.It is set automatically to `experimental' during check-in.A revision can later be promoted to a higher status, for example`stable' or `released'.  The set of states is user-defined..NH 2Revisions are represented as deltas.PPFor conserving space, RCS stores revisions in the formof deltas, i.e., as differences between revisions.The user interface completely hides this fact..PPA delta is a sequence of edit commands that transforms one stringinto another.  The deltas employed by RCS are line-based, which meansthat the only edit commands allowed are insertion and deletion of lines.If a single character in a line is changed, theedit scripts consider the entire line changed.The program \fIdiff\fR\u2\dproduces a small, line-based delta between pairs of text files.A character-based edit script would take much longer to compute,and would not be significantly shorter..PPUsing deltas is a classical space-time tradeoff: deltas reduce thespace consumed, but increase access time.However, a version control tool should impose as little delayas possible on programmers.Excessive delays discourage the use of version controls,or induce programmers to take shortcuts that compromise system integrity.To gain reasonably fast access time for both editing and compiling,RCS arranges deltas in the following way.The most recent revision on the trunk is stored intact.All other revisions on the trunk are stored as reverse deltas.A reverse delta describes how to go backward in the development history:it produces the desired revision if applied to the successor of that revision.This implementation has the advantagethat extraction of the latest revision is a simple and fast copyoperation.Adding a new revision to the trunk is also fast: \fIci\fR simplyadds the new revision intact, replaces the previousrevision with a reverse delta, and keeps the rest of the old deltas.Thus, \fIci\fR requires the computationof only one new delta..PPBranches need special treatment.  The naive solution would be tostore complete copies for the tips of all branches.Clearly, this approach would cost too much space.  Instead,RCS uses \fIforward\fR deltas for branches.  Regenerating a revisionon a side branch proceeds as follows.  First, extract the latest revisionon the trunk; secondly, apply reverse deltas until the fork revision forthe branch is obtained; thirdly, apply forward deltas until the desiredbranch revision is reached.  Figure 5 illustrates a tree withone side branch.  Triangles pointing to the left and right representreverse and forward deltas, respectively..ne 8.PS  4i.ps -2define BD X [line invis $1 right .5;line up .3 then left .5 down .3 then right .5 down .3 then up .3] Xdefine FD X [line invis $1 right .5;line left .5 down .3 then up .6 then right .5 down .3;] XrightD11:    BD(" 1.1")	arrow right from D11.eD12:    BD(" 1.2")	arrow  right from D12.eD13:    BD(" 1.3")	arrow  right from D13.eD21:    BD(" 2.1")	arrow  right from D21.eD22:    box "2.2"	line invis down from D21.sF1:     FD("1.3.1.1 ")	arrow from D13.se to F1.w	arrow from F1.e right	rightF2:     FD("1.3.1.2 ").ps +2.PE.ce 1Figure 5.  A revision tree with reverse and forward deltas..sp 0.PPAlthough implementing fast check-out for the latest trunk revision,this arrangement has the disadvantage that generation of other revisionstakes time proportional to the number of deltas applied.  For example,regenerating the branch tip in Figure 5 requires application of fivedeltas (including the initial one).  Since usage statistics show thatthe latest trunk revision is the one that is retrieved in 95 per centof all cases (see the section on usage statistics), biasing check-out timein favor of that revision results in significant savings.However, careful implementation of the delta application process isnecessary to provide low retrieval overhead for other revisions, inparticular for branch tips..PPThere are several techniques for delta application.The naive one is to pass each delta to a general-purpose text editor.A prototype of RCS invoked the UNIX editor \fIed\fR bothfor applying deltas and for expanding the identification markers.Although easy to implement, performance was poor, owing to thehigh start-up costs and excess generality of \fIed\fR.  An intermediateversion of RCS used a special-purpose, stream-oriented editor.This technique reduced the cost of applying a delta to the cost ofchecking out the latest trunk revision.  The reason for this behavioris that each delta application involves a complete pass overthe preceding revision..PPHowever, there is a much better algorithm.  Note that the deltas areline oriented and that most of the work of a stream editor involvescopying unchanged lines from one revision to the next.  A fasteralgorithm avoids unnecessary copying of character strings by usinga \fIpiece table\fR.A piece table is a one-dimensional array, specifying how a givenrevision is `pieced together' from lines in the RCS file.Suppose piece table \fIPT\dr\u\fR represents revision \fIr\fR.Then \fIPT\dr\u[i]\fR contains the starting position of line \fIi\fRof revision \fIr\fR.Application of the next delta transforms piece table \fIPT\dr\u\fRinto \fIPT\dr+1\u\fR.  For instance, a delete command removes aseries of entries from the piece table.  An insertion command insertsnew entries, moving the entries following the insertion point further down thearray.  The inserted entries point to the text lines in the delta.Thus, no I/O is involved except for reading the delta itself.  When alldeltas have been applied to the piece table, a sequential passthrough the table looks up each line in the RCS file and copies it tothe output file, updating identification markers at the same time.Of course, the RCS file must permit random access, since the copiedlines are scattered throughout that file.  Figure 6 illustrates anRCS file with two revisions and the corresponding piece tables..ne 13.sp 6.ce 1\fIFigure 6 is not available.\fP.sp 5.ce 1Figure 6.  An RCS file and its piece tables.sp 0.PPThe piece table approach has the property that the time for applying a singledelta is roughly determined by the size of the delta, and not by thesize of the revision.  For example, if a delta is10 per cent of the size of a revision, then applying it takes only10 per cent of the time to generate the latest trunk revision.  (The streameditor would take 100 per cent.).PPThere is an important alternative for representing deltas that affectsperformance.  SCCS\u3\d,a precursor of RCS, uses \fIinterleaved\fR deltas.A file containing interleaved deltas is partitioned into blocks of lines.Each block has a header that specifies to which revision(s) the blockbelongs.  The blocks are sorted out in such a way that a singlepass over the file can pick up all the lines belonging to a givenrevision.  Thus, the regeneration time for all revisions is the same:all headers must be inspected, and the associated blocks either copiedor skipped.  As the number of revisions increases, the cost of retrievingany revision is much higher than the cost of checking out thelatest trunk revision with reverse deltas.  A detailed comparisonof SCCS's interleaved deltas and RCS's reverse deltas can be foundin Reference 4.This reference considers the version of RCS with thestream editor only.  The piece table method improves performancefurther, so that RCS is always faster than SCCS, except if 10or more deltas are applied..PPAdditional speed-up for both delta methods can be obtained by cachingthe most recently generated revision, as has been implemented in DSEE.\u5\dWith caching, access time to frequently used revisions can approach normal fileaccess time, at the cost of some additional space..NHLocking: A Controversial Issue.PPThe locking mechanism for RCS was difficult to design.The problem and its solution are first presented in their `pure' form,followed by a discussion of the complicationscaused by `real-world' considerations..PPRCS must prevent two or more persons from depositing competing changes of thesame revision.Suppose two programmers check out revision 2.4 andmodify it.  Programmer A checks in a revision before programmer B\&.Unfortunately, programmer B has not seen A'schanges, so the effect is that A's changes are covered up by B's deposit.A's changes are not lost since all revisionsare saved, but they are confined to a single revision.\(dd.FS \(ddNote that this problem is entirely different from the atomicity problem.Atomicity means thatconcurrent update operations on the same RCS file cannot be permitted,because that may result in inconsistent data.Atomic updates are essential (and implemented in RCS),but do not solve the conflict discussed here..FE.PPThis conflict is prevented in RCS by locking.Whenever someone intends to edit a revision (as opposedto reading or compiling it), the revision should be checked outand locked,using the \fI\-l\fR option on \fIco\fR.  On subsequent check-in,\fIci\fR tests the lock and then removes it.At most one programmer at a time maylock a particular revision, and only this programmer may check inthe succeeding revision.Thus, while a revision is locked, it is the exclusive responsibilityof the locker..PPAn important maxim for software tools like RCS is that they mustnot stand in the way of making progress with a project.This consideration leads to several weakenings of the locking mechanism.First of all, even if a revision is locked, it canstill be checked out.  This is necessary if other peoplewish to compile or inspect the locked revisionwhile the next one is in preparation.  The only operations theycannot do are to lock the revision or to check in the succeeding one.  Secondly,check-in operations on other branches in the RCS file are still possible; thelocking of one revision does not affect any other revision.Thirdly, revisions are occasionally locked for a long period of timebecause a programmer is absent or otherwise unable to completethe assignment.  If another programmer has to make a pressing change,there are the following three alternatives for making progress:a) find out who is holding the lock and ask that person to release it;b) check out the locked revision, modify it, check itin on a branch, and merge the changes later;c) break the lock.  Breaking a lock leaves a highly visibletrace, namely an electronic mail message that is sent automatically to theholder of the lock, recording the breaker and a commentary requested from him.Thus, breaking locks is tolerated under certain circumstances,but will not go unnoticed.Experience has shown that the automatic mail message attaches a high enoughstigma to lock breaking,such that programmers break locks only in real emergencies,or when a co-worker resigns and leaves locked revisions behind..PPIf an RCS file is private, i.e., when a programmer owns an RCS fileand does not expect anyone else to perform check-in operations,locking is an unnecessary nuisance.In this case,the `strict locking feature' discussed earlier may be disabled,provided that file protectionis set such that only the owner may write the RCS file.This has the effect that only the owner can check-in revisions,and that no lock is needed for doing so..PPAs added protection,each RCS file contains an access list that specifies the userswho may execute update operations.  If an access list is empty,only normal UNIX file protection applies.  Thus, the access list isuseful for restricting the set of people who would otherwise have updatepermission.  Just as with locking, the access listhas no effect on read-only operations such as \fIco\fR.  This approachis consistent with the UNIX philosophy of openness, which contributesto a productive software development environment..NH

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -