A simple version control system written in Python
Project description
README.md
SimpleVCS
A simple version control system written in Python that provides basic VCS functionality similar to Git.
Features
- Initialize repositories
- Add files to staging area
- Commit changes with messages or timestamps
- View commit history with detailed information
- Show differences between commits
- Repository status tracking
- Cross-platform compatibility
- Both CLI and Python API support
Installation
From PyPI (when published)
pip install simple-vcs
From Source
# Clone the repository
git clone https://github.com/muhammadsufiyanbaig/simple_vcs.git
cd simple-vcs
# Install in development mode
pip install -e .
# Or install normally
pip install .
Quick Start
# Initialize a new repository
svcs init
# Create a sample file
echo "Hello World" > hello.txt
# Add file to staging area
svcs add hello.txt
# Commit the changes
svcs commit -m "Add hello.txt"
# View commit history
svcs log
Usage
Command Line Interface
Repository Management
# Initialize a new repository in current directory
svcs init
# Initialize in specific directory
svcs init --path /path/to/project
File Operations
# Add single file
svcs add filename.txt
# Add multiple files
svcs add file1.txt file2.py file3.md
# Check repository status
svcs status
Commit Operations
# Commit with message
svcs commit -m "Your commit message"
# Commit with auto-generated timestamp
svcs commit
# View commit history
svcs log
# View limited commit history
svcs log --limit 5
Viewing Differences
# Show diff between last two commits
svcs diff
# Show diff between specific commits
svcs diff --c1 1 --c2 3
# Show diff between commit 2 and latest
svcs diff --c1 2
Python API
from simple_vcs import SimpleVCS
# Create VCS instance
vcs = SimpleVCS("./my_project")
# Initialize repository
vcs.init_repo()
# Add files
vcs.add_file("example.txt")
vcs.add_file("script.py")
# Commit changes
vcs.commit("Initial commit with example files")
# Show commit history
vcs.show_log()
# Show differences between commits
vcs.show_diff(1, 2)
# Check repository status
vcs.status()
Advanced Usage
Working with Multiple Files
from simple_vcs import SimpleVCS
from simple_vcs.utils import get_all_files
vcs = SimpleVCS()
vcs.init_repo()
# Add all Python files in current directory
python_files = [f for f in get_all_files(".") if f.endswith('.py')]
for file in python_files:
vcs.add_file(file)
vcs.commit("Add all Python files")
Repository Structure
When initialized, SimpleVCS creates a .svcs directory containing:
.svcs/
├── objects/ # File content storage (hashed)
├── commits.json # Commit history and metadata
├── staging.json # Currently staged files
└── HEAD # Current commit reference
Requirements
- Python 3.7 or higher
- click>=7.0 (for CLI functionality)
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/yourusername/simple-vcs.git
cd simple-vcs
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Install development dependencies
pip install pytest pytest-cov black flake8
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=simple_vcs
# Run specific test file
pytest tests/test_core.py
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Publishing to PyPI
# Install build tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI (requires PyPI account)
twine upload dist/*
Limitations
This is a simple implementation for educational purposes. It lacks advanced features like:
- Branching and merging
- Remote repositories
- File conflict resolution
- Large file handling
- Advanced diff algorithms
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Your Name - your.email@example.com
Changelog
Version 1.0.0
- Initial release
- Basic VCS functionality (init, add, commit, log, diff, status)
- CLI and Python API support
- Cross-platform compatibility
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_vcs-1.0.0.tar.gz.
File metadata
- Download URL: simple_vcs-1.0.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
925687e394077409b714d1dcd74e41a005d30b1ac6ab238aa06171cc0ae7983a
|
|
| MD5 |
3f17f93f9488965912fcf9a044eded4f
|
|
| BLAKE2b-256 |
f12089e3dbec0abbbc0854ac0d37c4ac21df86cd1f719dba7a9ae697cf512516
|
File details
Details for the file simple_vcs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: simple_vcs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10a0d54ab7e857cceda711846be237bc8ed33e215e685cafe8fce1cf0a2b70e5
|
|
| MD5 |
f92e776e241c6282eb426eb25a51e602
|
|
| BLAKE2b-256 |
f01022103d27683a5570ffb0d5b1489c615c98711a6298589877612914e447a2
|