# ThrillWiki Version Control System ## Overview The ThrillWiki Version Control System (VCS) provides comprehensive version tracking, branching, and merging capabilities for all content in the system. It builds upon django-simple-history while adding powerful versioning features. ## Features - Full version history tracking - Branch-based development - Version tagging - Merge operations with conflict resolution - Real-time collaborative editing - Automatic change tracking ## Model Integration ### Making Models Version-Controlled To add version control to any model, inherit from `HistoricalModel`: ```python from history_tracking.models import HistoricalModel class YourModel(HistoricalModel): # Your model fields here name = models.CharField(max_length=255) class Meta: # Your meta options ``` This automatically provides: - Full version history - Change tracking - Branch support - Merge capabilities ### Example Integration (from parks/models.py) ```python from history_tracking.models import HistoricalModel class Park(HistoricalModel): name = models.CharField(max_length=255) description = models.TextField() def save(self, *args, **kwargs): # Changes will be automatically tracked super().save(*args, **kwargs) ``` ## Usage Guide ### Basic Version Control Operations 1. Creating a Branch ```python from history_tracking.managers import BranchManager # Create a new feature branch branch_manager = BranchManager() feature_branch = branch_manager.create_branch( name="feature/new-park-details", user=request.user ) ``` 2. Recording Changes ```python from history_tracking.signals import ChangesetContextManager # Making changes in a specific branch with ChangesetContextManager(branch=feature_branch, user=request.user): park = Park.objects.get(id=1) park.description = "Updated description" park.save() # Change is automatically tracked in the branch ``` 3. Merging Changes ```python # Merge feature branch back to main success, conflicts = branch_manager.merge_branches( source=feature_branch, target=main_branch, user=request.user ) if not success: # Handle merge conflicts for conflict in conflicts: # Resolve conflicts through UI or programmatically pass ``` 4. Working with Tags ```python from history_tracking.models import VersionTag # Tag a specific version VersionTag.objects.create( name="v1.0.0", branch=main_branch, content_type=ContentType.objects.get_for_model(park), object_id=park.id, created_by=user ) ``` ## UI Integration ### HTMX Components The system provides HTMX-powered components for real-time version control: 1. Version Control Panel ```html {% include "history_tracking/version_control_panel.html" %} ``` 2. Branch Selection ```html