vcs-cli-rajarshi 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rajarshi Datta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: vcs-cli-rajarshi
3
+ Version: 1.0.0
4
+ Summary: A minimal Git-like version control system
5
+ Author: Rajarshi Datta
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # VCS
17
+
18
+ VCS is a small, educational, Git-like version control system written in Python.
19
+ It supports local snapshots, branches, safe checkout, and three-way merges while
20
+ keeping its on-disk format easy to inspect.
21
+
22
+ > VCS is an educational project, not a drop-in replacement for Git. The package
23
+ > is currently classified as alpha software.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install vcs-cli-rajarshi
29
+ ```
30
+
31
+ The distribution is named `vcs-cli-rajarshi`, and it installs the `vcs`
32
+ terminal command.
33
+
34
+ For local development:
35
+
36
+ ```bash
37
+ python -m pip install -e .
38
+ ```
39
+
40
+ ## Basic workflow
41
+
42
+ ```bash
43
+ mkdir my-project
44
+ cd my-project
45
+ vcs init
46
+
47
+ vcs add app.py
48
+ vcs commit -m "Initial commit" -a "Your Name"
49
+ vcs status
50
+ vcs log
51
+ ```
52
+
53
+ Branching and merging:
54
+
55
+ ```bash
56
+ vcs branch feature
57
+ vcs checkout feature
58
+ # edit and commit files
59
+ vcs checkout main
60
+ vcs merge feature
61
+ ```
62
+
63
+ Checkout and merge abort if they would overwrite staged changes, modified
64
+ tracked files, or colliding untracked files. A merge also aborts and lists the
65
+ paths when both branches changed the same file differently.
66
+
67
+ ## Ignoring files
68
+
69
+ Create a `.vcsignore` file in the repository root. It accepts common glob-style
70
+ patterns, directory patterns, comments, and `!` negation:
71
+
72
+ ```gitignore
73
+ __pycache__/
74
+ dist/
75
+ *.pyc
76
+ .env
77
+ !example.env
78
+ ```
79
+
80
+ ## Commands
81
+
82
+ - `vcs init`
83
+ - `vcs add <file> [<file> ...]`
84
+ - `vcs commit -m <message> [-a <author>]`
85
+ - `vcs status`
86
+ - `vcs log [-n <count>]`
87
+ - `vcs branch [<name>]`
88
+ - `vcs checkout <branch>`
89
+ - `vcs merge <branch>`
90
+
91
+ Run `vcs --help` or `vcs <command> --help` for command-line help.
92
+
93
+ ## Development and release
94
+
95
+ Run the tests with only the Python standard library:
96
+
97
+ ```bash
98
+ python -m unittest discover -s tests -v
99
+ ```
100
+
101
+ Build and validate a release:
102
+
103
+ ```bash
104
+ python -m pip install build twine
105
+ python -m build
106
+ python -m twine check dist/*
107
+ ```
108
+
109
+ Test the wheel in a fresh virtual environment before publishing. To publish:
110
+
111
+ ```bash
112
+ python -m twine upload dist/*
113
+ ```
114
+
115
+ ## Repository format
116
+
117
+ ```text
118
+ .vcs/
119
+ ├── objects/ # Binary-safe content-addressed objects
120
+ ├── refs/heads/ # Branch references
121
+ ├── HEAD # Current branch pointer
122
+ ├── config.json # Repository metadata
123
+ └── staging.json # Staging index
124
+ ```
125
+
126
+ VCS stores file objects byte-for-byte and hashes them with SHA-1 for educational
127
+ compatibility with the basic content-addressing idea. It does not provide Git's
128
+ network protocol, pack files, hooks, tags, rebase, or cryptographic signing.
@@ -0,0 +1,113 @@
1
+ # VCS
2
+
3
+ VCS is a small, educational, Git-like version control system written in Python.
4
+ It supports local snapshots, branches, safe checkout, and three-way merges while
5
+ keeping its on-disk format easy to inspect.
6
+
7
+ > VCS is an educational project, not a drop-in replacement for Git. The package
8
+ > is currently classified as alpha software.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install vcs-cli-rajarshi
14
+ ```
15
+
16
+ The distribution is named `vcs-cli-rajarshi`, and it installs the `vcs`
17
+ terminal command.
18
+
19
+ For local development:
20
+
21
+ ```bash
22
+ python -m pip install -e .
23
+ ```
24
+
25
+ ## Basic workflow
26
+
27
+ ```bash
28
+ mkdir my-project
29
+ cd my-project
30
+ vcs init
31
+
32
+ vcs add app.py
33
+ vcs commit -m "Initial commit" -a "Your Name"
34
+ vcs status
35
+ vcs log
36
+ ```
37
+
38
+ Branching and merging:
39
+
40
+ ```bash
41
+ vcs branch feature
42
+ vcs checkout feature
43
+ # edit and commit files
44
+ vcs checkout main
45
+ vcs merge feature
46
+ ```
47
+
48
+ Checkout and merge abort if they would overwrite staged changes, modified
49
+ tracked files, or colliding untracked files. A merge also aborts and lists the
50
+ paths when both branches changed the same file differently.
51
+
52
+ ## Ignoring files
53
+
54
+ Create a `.vcsignore` file in the repository root. It accepts common glob-style
55
+ patterns, directory patterns, comments, and `!` negation:
56
+
57
+ ```gitignore
58
+ __pycache__/
59
+ dist/
60
+ *.pyc
61
+ .env
62
+ !example.env
63
+ ```
64
+
65
+ ## Commands
66
+
67
+ - `vcs init`
68
+ - `vcs add <file> [<file> ...]`
69
+ - `vcs commit -m <message> [-a <author>]`
70
+ - `vcs status`
71
+ - `vcs log [-n <count>]`
72
+ - `vcs branch [<name>]`
73
+ - `vcs checkout <branch>`
74
+ - `vcs merge <branch>`
75
+
76
+ Run `vcs --help` or `vcs <command> --help` for command-line help.
77
+
78
+ ## Development and release
79
+
80
+ Run the tests with only the Python standard library:
81
+
82
+ ```bash
83
+ python -m unittest discover -s tests -v
84
+ ```
85
+
86
+ Build and validate a release:
87
+
88
+ ```bash
89
+ python -m pip install build twine
90
+ python -m build
91
+ python -m twine check dist/*
92
+ ```
93
+
94
+ Test the wheel in a fresh virtual environment before publishing. To publish:
95
+
96
+ ```bash
97
+ python -m twine upload dist/*
98
+ ```
99
+
100
+ ## Repository format
101
+
102
+ ```text
103
+ .vcs/
104
+ ├── objects/ # Binary-safe content-addressed objects
105
+ ├── refs/heads/ # Branch references
106
+ ├── HEAD # Current branch pointer
107
+ ├── config.json # Repository metadata
108
+ └── staging.json # Staging index
109
+ ```
110
+
111
+ VCS stores file objects byte-for-byte and hashes them with SHA-1 for educational
112
+ compatibility with the basic content-addressing idea. It does not provide Git's
113
+ network protocol, pack files, hooks, tags, rebase, or cryptographic signing.
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vcs-cli-rajarshi"
7
+ version = "1.0.0"
8
+ description = "A minimal Git-like version control system"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [{ name = "Rajarshi Datta" }]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Environment :: Console",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ ]
19
+
20
+ [project.scripts]
21
+ vcs = "vcs.cli:main"
22
+
23
+ [tool.setuptools.packages.find]
24
+ include = ["vcs*"]
25
+
26
+ [tool.pytest.ini_options]
27
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,25 @@
1
+ import contextlib
2
+ import io
3
+ import unittest
4
+
5
+ from vcs.cli import main
6
+
7
+
8
+ class CliTests(unittest.TestCase):
9
+ def test_help_exits_successfully(self):
10
+ output = io.StringIO()
11
+ with contextlib.redirect_stdout(output), self.assertRaises(SystemExit) as result:
12
+ main(["--help"])
13
+ self.assertEqual(result.exception.code, 0)
14
+ self.assertIn("A minimal version control system", output.getvalue())
15
+
16
+ def test_version_exits_successfully(self):
17
+ output = io.StringIO()
18
+ with contextlib.redirect_stdout(output), self.assertRaises(SystemExit) as result:
19
+ main(["--version"])
20
+ self.assertEqual(result.exception.code, 0)
21
+ self.assertIn("vcs 1.0.0", output.getvalue())
22
+
23
+
24
+ if __name__ == "__main__":
25
+ unittest.main()
@@ -0,0 +1,98 @@
1
+ import tempfile
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ from vcs.repository import Repository
6
+
7
+
8
+ class RepositoryTests(unittest.TestCase):
9
+ def setUp(self):
10
+ self.temporary_directory = tempfile.TemporaryDirectory()
11
+ self.root = Path(self.temporary_directory.name)
12
+ self.repo = Repository(str(self.root))
13
+ self.assertTrue(self.repo.init())
14
+
15
+ def tearDown(self):
16
+ self.temporary_directory.cleanup()
17
+
18
+ def write_bytes(self, name, content):
19
+ path = self.root / name
20
+ path.parent.mkdir(parents=True, exist_ok=True)
21
+ path.write_bytes(content)
22
+
23
+ def commit_file(self, name, content, message="change"):
24
+ self.write_bytes(name, content)
25
+ self.assertEqual(self.repo.add([name])[name], "added")
26
+ return self.repo.commit(message, "Test Author")
27
+
28
+ def test_later_commits_keep_unchanged_files_in_snapshot(self):
29
+ self.commit_file("one.txt", b"one", "first")
30
+ second_hash = self.commit_file("two.txt", b"two", "second")
31
+ tree = self.repo._get_commit(second_hash)["tree"]
32
+ self.assertEqual(set(tree), {"one.txt", "two.txt"})
33
+
34
+ def test_binary_file_round_trips_through_checkout(self):
35
+ original = bytes(range(256)) + b"\x00\xff\xfe"
36
+ self.commit_file("image.bin", original, "binary")
37
+ self.repo.branch("feature")
38
+ self.repo.checkout("feature")
39
+ changed = b"new\x00binary\xff"
40
+ self.commit_file("image.bin", changed, "change binary")
41
+ self.repo.checkout("main")
42
+ self.assertEqual((self.root / "image.bin").read_bytes(), original)
43
+ self.repo.checkout("feature")
44
+ self.assertEqual((self.root / "image.bin").read_bytes(), changed)
45
+
46
+ def test_checkout_preserves_untracked_files(self):
47
+ self.commit_file("tracked.txt", b"main", "main")
48
+ self.repo.branch("feature")
49
+ self.write_bytes("notes.tmp", b"keep me")
50
+ self.repo.checkout("feature")
51
+ self.assertEqual((self.root / "notes.tmp").read_bytes(), b"keep me")
52
+
53
+ def test_checkout_refuses_to_discard_modified_tracked_file(self):
54
+ self.commit_file("tracked.txt", b"original", "main")
55
+ self.repo.branch("feature")
56
+ self.write_bytes("tracked.txt", b"uncommitted")
57
+ with self.assertRaisesRegex(Exception, "Local changes would be overwritten"):
58
+ self.repo.checkout("feature")
59
+ self.assertEqual(self.repo._get_current_branch(), "main")
60
+ self.assertEqual((self.root / "tracked.txt").read_bytes(), b"uncommitted")
61
+
62
+ def test_vcsignore_hides_and_rejects_ignored_files(self):
63
+ self.write_bytes(".vcsignore", b"*.log\nbuild/\n")
64
+ self.write_bytes("debug.log", b"secret")
65
+ self.write_bytes("build/result.bin", b"artifact")
66
+ self.write_bytes("visible.txt", b"visible")
67
+ status = self.repo.status()
68
+ self.assertIn("visible.txt", status["untracked"])
69
+ self.assertNotIn("debug.log", status["untracked"])
70
+ self.assertNotIn("build/result.bin", status["untracked"])
71
+ self.assertIn("ignored", self.repo.add(["debug.log"])["debug.log"])
72
+
73
+ def test_merge_conflict_aborts_without_overwriting_ours(self):
74
+ self.commit_file("shared.txt", b"base", "base")
75
+ self.repo.branch("feature")
76
+ self.repo.checkout("feature")
77
+ self.commit_file("shared.txt", b"feature", "feature edit")
78
+ self.repo.checkout("main")
79
+ ours_hash = self.commit_file("shared.txt", b"main", "main edit")
80
+ with self.assertRaisesRegex(Exception, "Merge conflict in: shared.txt"):
81
+ self.repo.merge("feature")
82
+ self.assertEqual(self.repo._get_current_commit(), ours_hash)
83
+ self.assertEqual((self.root / "shared.txt").read_bytes(), b"main")
84
+
85
+ def test_three_way_merge_combines_non_conflicting_changes(self):
86
+ self.commit_file("base.txt", b"base", "base")
87
+ self.repo.branch("feature")
88
+ self.repo.checkout("feature")
89
+ self.commit_file("feature.txt", b"feature", "feature")
90
+ self.repo.checkout("main")
91
+ self.commit_file("main.txt", b"main", "main")
92
+ self.assertEqual(self.repo.merge("feature"), "Merged branch 'feature'")
93
+ self.assertEqual(set(self.repo._current_tree()), {"base.txt", "feature.txt", "main.txt"})
94
+ self.assertEqual((self.root / "feature.txt").read_bytes(), b"feature")
95
+
96
+
97
+ if __name__ == "__main__":
98
+ unittest.main()
@@ -0,0 +1,7 @@
1
+ """
2
+ Python Version Control System - MVP Implementation
3
+ A minimal Git-like version control system with core functionality.
4
+ """
5
+
6
+ __version__ = "1.0.0"
7
+ __author__ = "VCS MVP"
@@ -0,0 +1,7 @@
1
+ """Allow the CLI to be run with ``python -m vcs``."""
2
+
3
+ from .cli import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ raise SystemExit(main())