Using Modules
What is a module?
A module is a set of files with closely related functionality gathered into a separate directory. The module is intended for speeding up CVS operations by skipping the module when working with changes where the files in module are not affected.
Important notes:
- Changelogic's modules are there for one particular purpose – to make version control operations faster. You are not obliged to use them – you may define your logical modules however you please without registering them in Changelogic, just set up directory structure and build file as you like. It's only reasonable to consider using Changelogic's modules when change 'edit' and 'end_edit' are regularly taking time long enough to justify downsides of using modules (see next).
- Using modules has some downsides:
- Developer has to be aware which modules are going to be / have been edited during his change. Forgetting to mark a module editable implies that edits made in that module will not be commited by Changelogic.
- Usage of regular CVS client is somewhat limited as it is not aware of the module system provided by Changelogic. Manually executed CVS commands will not apply to modules that have not been explicitly specified on command line.
- Potential trouble when someone manages to add module's files to main repository.
- When using Changelogic's modules the code for each module is required to be stored in top-level CVS directory, but you can use different structure in working directories (for example in a subdirectory of main module).
Adding a new module to project
What you need to do is:
- Create a new change
- Start editing the change – ant edit
- Create top-level directory in CVS repository for the new module – mkdir my-module; cvs import my-module change_xxx initial (the change_XXX should be replaced with the tag of your change)
- Check out the module cvs checkout -r change_xxx my-module
- Register the module in web interface (starting change: your current change)
- Create and add files and directories in the module cvs add file1 file2 .... You must add at least one file in the module.
- Commit the files cvs commit
- From working directory of your main repository, mark the module editable ant edit_module
You may add several modules in the same change.
End development, review and integrate the change to access the modules in other changes.
Refactoring current project to use modules
Important! All open working directories will malfunction if used further, thus you either need to commit and close all open changes or merge those changes manually (a task quite complex and error-prone).
The process itself is similar to previous one, now the steps are: 1, 2, instead of step 3 you should move former subdirectories to top level in CVS repository (for example: /var/cvs/my-project/my-module1 now becomes /var/cvs/my-module1. And yes, you should do it in CVS server on file system level, it cannot be accomplished by using only CVS commands and working directory), followed by cvs rtag -b -r latest change_xxx my-module and steps 5 and 8.
Working with modules
Here's what you additionally need to do when using modules modules (compared to not using modules):
- You must choose the modules that are going to be edited when adding a new change (by default, no modules will be edited)
- You can change the selection from web interface until development is started (until you do ant edit)
- After starting development you can only add modules one by one with the dedicated build script target 'edit_module' (ant edit_module)
- If you need to refresh or check out other modules for your project to compile or application to deploy, you can use the target 'update_all' (ant update_all)
What Changelogic will do:
- When starting development, it updates the working directory of main module, checks out/updates all modules marked editable and adds change tag to these
- When you run ant update_all, Changelogic checks out/updates all other modules to the open change's base version
- When you run ant edit_module, Changelogic will tag that module with change tag. If the code has already been edited, changes will be merged (nothing will get lost)
- Important! When you end development of change, but the actually changed module is not marked editable, that code will not be committed to CVS. Changelogic will not try to commit modules, because the whole point of module is to gain speed by performing CVS command only on selected parts of the whole repository. As the commit will not take place at all, it will not fail because of being impossible against non-branch tag.
Note:
If module-specific build script targets have not yet been imported into build.xml of your project, you may use them directly from Changelogic script.
- Use ant -f devweb-build.xml edit_module instead of ant edit_module
- Use ant -f devweb-build.xml refresh_all instead of ant update_all
Projects using modules and migrating from previous Changelogic releases to 1.29
You should add targets 'edit_module' and 'update_all' to your build.xml file. You can get the sample from build.xml file provided in Changelogic's supprting files (user menu->supporting files). The stub targets you should add are these: