This project is a lightweight version control system for text files, implemented entirely in C++ without using STL’s map or priority_queue.
It supports:
- File creation and editing
- Versioning with snapshots
- Rollbacks to previous versions
- History tracking of commits
- Listing recent files and biggest version trees
- Compile through shells scripts
Note: User must be able to input commands at runtime, i.e., from stdin has been followed. For that user must run the main.exe after compiling.
The system uses:
- A custom hash map (
map.cpp) - A custom heap/priority queue (
Heap.cpp) - A tree structure to represent file versions (
Tree.cpp)
-
CREATE
<filename>- Creates a new file with an initial snapshot (version 0).
-
READ
<filename>- Prints the current active version’s ID and content.
-
INSERT
<filename> <content>- Appends content to the active version.
- If the active version is a snapshot, a new version is created.
-
UPDATE
<filename> <content>- Replaces the file’s content.
- Creates a new version if the active one is a snapshot.
-
SNAPSHOT
<filename> <message>- Commits the current version with a message and timestamp.
-
ROLLBACK
<filename>[versionID]- Rolls back to the parent version (if no ID is provided).
- Or rolls back to a specific version if
versionIDis given.
-
HISTORY
<filename>- Shows all snapshots (ID, timestamp, commit message) in chronological order.
-
RECENT_FILES
[num]- Lists files in descending order of their last modification time.
-
BIGGEST_TREES
[num]- Lists files in descending order of their total version count.
-
EXIT
- Ends the program.
.
├── main.cpp # Command interpreter (CLI)
├── map.cpp # Custom hash map implementation
├── Heap.cpp # Custom heap/priority queue implementation
├── Tree.cpp # Version tree (file versioning)
-
Hash-based key-value store.
-
Supports:
count(key)operator[]insert(key, value)erase(key)items()→ returns all key-value pairs as a vector.
-
Binary heap (min/max based on comparator).
-
Supports:
push(value)pop()top()empty()size()
-
Represents a file’s version history as a tree of
TreeNode. -
TreeNodeholds:version_idcontentmessagecreated_timestampsnapshot_timestampparentandchildrenpointers.
To compile and run: open the file run.bat
To compile and run: open the file run.sh
- Invalid commands →
Unknown command - Missing filename →
Please provide a filename - File does not exist →
Error: File does not exist - Colliding names →
File already exists - No content/message →
Error: No content provided - No num parameter provided in system-wide commands→
Please specify the number of files - If num more than total files →
Terminating early ... - If rollback to parent of root →
Already at root version. Cannot rollback further.