Skip to main content
Engineering LibreTexts

8.2: Source Control

  • Page ID
    39613
    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Versions of a method

    When you save a new version of a method, the old one is not lost. Pharo keeps all of the old versions (assuming that you are using the same image and that you saved it), and allows you to compare different versions and to go back (revert) to an old version.

    The browse > versions (v) menu item gives access to the successive modifications made to the selected method. In Figure \(\PageIndex{1}\) we can see two versions of a method.

    The versions browser.
    Figure \(\PageIndex{1}\): The versions browser showing two versions of the ObjTest>>testIVOffset method.

    The top pane displays one line for each version of the method, listing the name of the programmer who wrote it, the date and time at which it was saved, the names of the class and the method, and the protocol in which it was defined. The current (active) version is at the top of the list.

    The existence of the versions browser means that you never have to worry about preserving code that you think might no longer be needed. If you find that you do need it, you can always revert to the old version, or copy the needed code fragment out of the old version and paste it into a another method. Get into the habit of using versions; commenting out code that is no longer needed is a bad practice because it makes the current code harder to read. Pharoers rate code readability extremely highly.

    Hint

    What if you delete a method entirely, and then decide that you want it back? You can find the deletion in a change set, where you can ask to see versions by right-clicking. The change set browser is described in Section 8.2.

    Change sets and the changesorter

    Whenever you are working in Pharo, any changes that you make to methods and classes are recorded in a change set. This includes creating new classes, renaming classes, changing categories, adding methods to existing classes – just about everything of significance. However, arbitrary Do its are not included.

    At any time, many change sets exist, but only one of them – ChangeSet current – is collecting the changes that are being made to the image. You can see which change set is current and can examine all of the change sets using the change sorter, available by selecting World > Tools... > Change Sorter.

    Figure \(\PageIndex{2}\) shows the dual change sorter browser. The title bar shows which change set is current, and this change set is selected when the change sorter opens.

    The Change Sorter.
    Figure \(\PageIndex{2}\): The Change Sorter showing all the changes of one changeset and offering actions to move changes to other changesets.

    Other change sets can be selected in the top-left pane; the right-click menu allows you to make a different change set current, or to create a new change set. The next pane lists all of the classes affected by the selected change set (with their categories). Selecting one of the classes displays the names of its methods that are also in the change set (not all of the methods in the class) in the left central pane, and selecting a method name displays the method definition in the bottom pane.

    The change sorter also lets you delete classes and methods from the change set using the right-click menu on the corresponding items.

    The change sorter allows you to simultaneously view two change sets, one on the left hand side and the other on the right. This layout supports the change sorter’s main feature, which is the ability to move or copy changes from one change set to another, as shown by the right-click menu in Figure \(\PageIndex{2}\). It is also possible to copy individual methods from one side to the other.

    You may be wondering why you should care about the composition of a change set. the answer is that change sets provide a simple mechanism for exporting code from Pharo to the file system, from where it can be imported into another Pharo image. Change set export is known as Filing-out, and can be accomplished using the right-click menu on any change set, class or method in either browser. Repeated file outs create new versions of the file, but change sets are not a versioning tool like Monticello: they do not keep track of dependencies.

    Before the advent of Monticello, change sets were the main means for exchanging code between Pharoers. They have the advantage of simplicity (the file out is just a text file, although we don’t recommend that you try to edit them with a text editor), and a degree of portability.

    The main drawback of change sets, compared to Monticello packages, is that they do not support the notion of dependencies. In spite of these shortcomings, change sets still have their uses. In particular, you may find change sets on the Internet that you want to look at and perhaps use. So, having filed out a change set using the change sorter, we will now tell you how to file one in. This requires the use of another tool, the file list browser. Note that dropping a changeset on Pharo itself works brings a pop up to ask you whether you want to load or browse the code contained in a changeset.


    This page titled 8.2: Source Control is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.