A simple version control system
Project description
vcs - A Lightweight Git-like Version Control System
A simple, educational version control system implemented in Python that demonstrates the core concepts behind Git. Perfect for learning how version control systems work internally.
๐ Table of Contents
- Overview
- Features
- Installation
- Commands
- Usage Examples
- Project Structure
- How It Works
- Contributing
- License
๐ฏ Overview
vcs is a minimal version control system that implements the fundamental concepts of Git in a simplified manner. It provides content tracking through blob and tree objects, commit history with parent-child relationships, staging area for preparing commits, and basic authentication for access control.
๐งฐ Features
- Repository initialization (
vcs init) - User authentication (
vcs auth) - File staging (
vcs add) - Commit creation (
vcs commit) - History viewing (
vcs log) - Commit inspection (
vcs show) - Version checkout (
vcs checkout) - Compressed storage using zlib for efficient space usage
- Content-based addressing with SHA-1 hashing
๐ฆ Installation
From PyPI
pip install vcs-core
Local Installation
# Clone the repository
git clone https://github.com/ZEUS33776/vcs.git
cd vcs
# Install the package
pip install .
Verify Installation
vcs --help
๐ Commands
vcs init
Initialize a new VCS repository in the current directory.
vcs init
How it works:
- Creates a
.vcs/directory with necessary subdirectories (objects,commits, etc.) - Sets up essential files like
HEADandindexto start tracking - Establishes the foundation for version control in your project
vcs auth <username> <email>
Set user credentials that will be stored in the config file.
vcs auth john_doe john@example.com
How it works:
- Stores the username and email in
.vcs/configfor subsequent operations - Required for commit operations to identify the author
vcs add <file>
Stage a file for the next commit.
vcs add filename.txt
How it works:
- Stages changes by hashing the file's contents into a blob object
- Updates the
indexto track the file and its hash (prepares for commit) - Think of this as telling VCS: "I want this file to be part of the next commit"
vcs commit "<message>"
Create a new commit with staged changes.
vcs commit "Initial commit"
How it works:
- Creates a new commit object with:
- A tree object representing the snapshot of all files staged (from the index)
- Metadata like the commit message, author, timestamp
- Stores the commit object compressed in
.vcs/objects - Updates
HEADto point to this new commit hash - Saves the snapshot, so you can revert or checkout later
vcs log
Display the commit history.
vcs log
How it works:
- Shows the history of commits starting from
HEAD - Displays chronological list with hash, author, timestamp, and message
- Useful to track changes over time and review commit messages
vcs show <commit_hash>
Show detailed information about a specific commit.
vcs show a1b2c3d4
# or
vcs show HEAD
How it works:
- Retrieves the commit object from storage
- Displays commit metadata and associated file changes
- Helps you understand what changed in a specific commit
vcs checkout <commit_hash>
Switch the working directory to a specific commit.
vcs checkout a1b2c3d4
How it works:
- Switches your working directory to reflect the snapshot of the specified commit
- Deletes files that don't exist in the commit and restores files from the commit tree
- Updates
HEADto point to the commit - Allows you to view or work with your project at any point in history
๐ก Usage Examples
Basic Workflow
# Initialize repository
vcs init
# Set user credentials
vcs auth alice alice@example.com
# Create and add a file
echo "Hello World" > hello.txt
vcs add hello.txt
# Commit the changes
vcs commit "Add hello.txt"
# Make changes and commit again
echo "Updated content" >> hello.txt
vcs add hello.txt
vcs commit "Update hello.txt"
# View history
vcs log
# Check out previous version
vcs checkout <first_commit_hash>
Working with Multiple Files
# Add multiple files
echo "File 1" > file1.txt
echo "File 2" > file2.txt
vcs add file1.txt
vcs add file2.txt
vcs commit "Add two files"
# Show latest commit details
vcs show HEAD
๐ Project Structure
project/
โโโ .vcs/ # VCS repository data
โ โโโ objects/ # Compressed blob and tree objects
โ โโโ commits/ # Commit objects
โ โโโ index # Staging area
โ โโโ HEAD # Current commit reference
โ โโโ config # Authentication and settings
โโโ vcs/ # Source code
โโโ __init__.py
โโโ main.py # CLI entry point
โโโ commands/ # Command implementations
โโโ init.py
โโโ auth.py
โโโ add.py
โโโ commit.py
โโโ log.py
โโโ show.py
โโโ checkout.py
๐ How It Works
Object Storage
- Blobs: Store file contents, compressed with zlib
- Trees: Store directory structures and file metadata
- Commits: Store commit metadata and tree references
Authentication
- Username and email stored in
.vcs/config - Required for commit operations
- Set once using
vcs auth <username> <email>
Data Flow
- Add: File content โ Blob object โ Index entry
- Commit: Index entries โ Tree object โ Commit object โ Update HEAD
- Checkout: Commit hash โ Tree object โ Restore files
File Organization
.vcs/
โโโ objects/ # Content-addressable storage
โโโ commits/ # Commit metadata
โโโ index # Staging area (JSON)
โโโ HEAD # Current commit pointer
โโโ config # User credentials
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Code Style
- Follow PEP 8
- Use meaningful variable names
- Add docstrings for functions
- Include error handling
๐ License
MIT License
Author: Arjun Deshmukh
Thank you for using VCS!
Project details
Release history Release notifications | RSS feed
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 vcs_core-0.1.0.tar.gz.
File metadata
- Download URL: vcs_core-0.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63fb8993630b0e51719df7f04d1f740eacd37b874854f8a762366fb6d1409071
|
|
| MD5 |
e9c955c8664e48f2fcb8657281b7d8b5
|
|
| BLAKE2b-256 |
6e55519c5ac31383946745738a80d702bdeb8c5d25dceec80848632bdb99a6d4
|
File details
Details for the file vcs_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vcs_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32309bc6d5fefce9624c23b9c35368482f518b4c604eb36d46cdf5996e75a573
|
|
| MD5 |
bf2c430e4cc173bbb951722fef968225
|
|
| BLAKE2b-256 |
e88b2fcbbf1d657496c96d5a11b26a5bfb08727e1167f3b719600fe860ea8b8b
|