Skip to content

Commit efe819d

Browse files
authored
refactor!: Rename packages and classes (#408)
Easier to type, takes up less screen width, and fits the case better. - Moves: - `libvcs.parse` -> `libvcs.url` - `libvcs.projects` -> `libvcs.sync` - Renames: - `BaseProject` -> `BaseSync` - `MercurialProject` -> `HgSync` - `SubversionProject` -> `SvnSync` - `GitProject` -> `GitSync`
2 parents b18a3c0 + 07e31f9 commit efe819d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+276
-266
lines changed

CHANGES

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ $ pip install --user --upgrade --pre libvcs
1515

1616
### Breaking changes
1717

18+
- Moves (#408):
19+
20+
- `libvcs.parse` -> `libvcs.url`
21+
- `libvcs.projects` -> `libvcs.sync`
22+
23+
- Renames (#408):
24+
25+
- `BaseProject` -> `BaseSync`
26+
- `MercurialProject` -> `HgSync`
27+
- `SubversionProject` -> `SvnSync`
28+
- `GitProject` -> `GitSync`
29+
1830
- Deprecate custom functions in favor of standard library:
1931
- `which()` in favor of {func}`shutil.which`, via #397
2032
- `mkdir_p()` in favor of {func}`os.makedirs` and {meth}`pathlib.Path.mkdir` w/ `parents=True`,
@@ -60,41 +72,41 @@ $ pip install --user --upgrade --pre libvcs
6072

6173
:::
6274

63-
- {mod}`libvcs.parse.git`
75+
- {mod}`libvcs.url.git`
6476

65-
- {class}`~libvcs.parse.git.GitBaseURL` - Parse git URLs, `git(1)` compatible
77+
- {class}`~libvcs.url.git.GitBaseURL` - Parse git URLs, `git(1)` compatible
6678

67-
- {meth}`~libvcs.parse.git.GitBaseURL.is_valid`
68-
- {meth}`~libvcs.parse.git.GitBaseURL.to_url` - export `git clone`-compatible URL
79+
- {meth}`~libvcs.url.git.GitBaseURL.is_valid`
80+
- {meth}`~libvcs.url.git.GitBaseURL.to_url` - export `git clone`-compatible URL
6981

70-
- {class}`~libvcs.parse.git.GitPipURL` - Pip URLs, {meth}`~libvcs.parse.git.GitPipURL.is_valid`,
71-
{meth}`~libvcs.parse.git.GitPipURL.to_url`
82+
- {class}`~libvcs.url.git.GitPipURL` - Pip URLs, {meth}`~libvcs.url.git.GitPipURL.is_valid`,
83+
{meth}`~libvcs.url.git.GitPipURL.to_url`
7284

73-
- {class}`~libvcs.parse.git.GitURL` - Compatibility focused,
74-
{meth}`~libvcs.parse.git.GitURL.is_valid` {meth}`~libvcs.parse.git.GitURL.to_url`
85+
- {class}`~libvcs.url.git.GitURL` - Compatibility focused,
86+
{meth}`~libvcs.url.git.GitURL.is_valid` {meth}`~libvcs.url.git.GitURL.to_url`
7587

76-
- {mod}`libvcs.parse.hg`
88+
- {mod}`libvcs.url.hg`
7789

78-
- {class}`~libvcs.parse.hg.HgURL` - Parse Mercurial URLs
79-
- {meth}`~libvcs.parse.hg.HgURL.is_valid`
80-
- {meth}`~libvcs.parse.hg.HgURL.to_url` - export `hg clone`-compatible URL
90+
- {class}`~libvcs.url.hg.HgURL` - Parse Mercurial URLs
91+
- {meth}`~libvcs.url.hg.HgURL.is_valid`
92+
- {meth}`~libvcs.url.hg.HgURL.to_url` - export `hg clone`-compatible URL
8193

82-
- {mod}`libvcs.parse.svn`
94+
- {mod}`libvcs.url.svn`
8395

84-
- {class}`~libvcs.parse.svn.SvnURL` - Parse Subversion URLs
85-
- {meth}`~libvcs.parse.svn.SvnURL.is_valid`
86-
- {meth}`~libvcs.parse.svn.SvnURL.to_url` - export `svn checkout`-compatible URL
96+
- {class}`~libvcs.url.svn.SvnURL` - Parse Subversion URLs
97+
- {meth}`~libvcs.url.svn.SvnURL.is_valid`
98+
- {meth}`~libvcs.url.svn.SvnURL.to_url` - export `svn checkout`-compatible URL
8799

88-
Detection can be extended through writing {class}`~libvcs.parse.base.Matcher`s and adding them to
89-
the classes' {class}`~libvcs.parse.base.MatcherRegistry`
100+
Detection can be extended through writing {class}`~libvcs.url.base.Matcher`s and adding them to
101+
the classes' {class}`~libvcs.url.base.MatcherRegistry`
90102

91-
You can write your own VCS parser by implementing {class}`~libvcs.parse.base.URLProtocol`, but it
103+
You can write your own VCS parser by implementing {class}`~libvcs.url.base.URLProtocol`, but it
92104
would be most efficient if you studied the source of the `git(1)` parser to see how it's done.
93105

94106
### Breaking changes
95107

96-
- #391 Removed `flat` keyword argument for {class}`libvcs.projects.git.GitProject`. This was unused
97-
and the equivalent can be retrieved via `.to_dict()` on `GitRemote`
108+
- #391 Removed `flat` keyword argument for {class}`libvcs.sync.git.GitSync`. This was unused and the
109+
equivalent can be retrieved via `.to_dict()` on `GitRemote`
98110
- #379 Support for `git+git` URLs removed. Pip removed these in 21.0 due to them being insecure
99111
[^pip-git+git]
100112
- #372 Typings moved from `libvcs.types` -> {mod}`libvcs._internal.types`
@@ -111,7 +123,7 @@ $ pip install --user --upgrade --pre libvcs
111123
### Fixes
112124

113125
- Minor spelling fix in Git's `convert_pip_url()` exception
114-
- Fix mercurial cloning in {class}`libvcs.projects.hg.MercurialProject`
126+
- Fix mercurial cloning in {class}`libvcs.sync.hg.HgSync`
115127

116128
_Backport from 0.13.1_
117129

@@ -122,7 +134,7 @@ $ pip install --user --upgrade --pre libvcs
122134
_Backport from 0.13.4_
123135

124136
- {func}`~libvcs.shortcuts.create_project`: Add overloads that return the typed project (e.g.
125-
{class}`~libvcs.projects.git.GitProject`)
137+
{class}`~libvcs.sync.git.GitSync`)
126138

127139
_Backport from 0.13.3_
128140

@@ -165,19 +177,19 @@ $ pip install --user --upgrade --pre libvcs
165177
### Typings
166178

167179
- `create_project()`: Add overloads that return the typed project (e.g.
168-
{class}`~libvcs.projects.git.GitProject`)
180+
{class}`~libvcs.sync.git.GitSync`)
169181

170182
## libvcs 0.13.2 (2022-06-12)
171183

172184
### Typings
173185

174-
- {func}`libvcs.projects.git.GitProject.remotes`: Add overload
186+
- {func}`libvcs.sync.git.GitSync.remotes`: Add overload
175187

176188
## libvcs 0.13.1 (2022-06-01)
177189

178190
### Fixes
179191

180-
- Fix mercurial cloning in {class}`libvcs.projects.hg.MercurialProject`
192+
- Fix mercurial cloning in {class}`libvcs.sync.hg.HgSync`
181193

182194
## libvcs 0.13.0, "Jane" (2022-05-30)
183195

@@ -204,7 +216,7 @@ $ pip install --user --upgrade --pre libvcs
204216

205217
- `run(cmd, ...)` is now `run(args, ...)` to match `Popen`'s convention.
206218

207-
- {class}`libvcs.projects.base.BaseProject`:
219+
- {class}`libvcs.sync.base.BaseSync`:
208220

209221
- Removed `parent_dir`:
210222

@@ -223,13 +235,13 @@ $ pip install --user --upgrade --pre libvcs
223235
Deprecated in >=0.13:
224236

225237
```python
226-
GitProject('https://github.com/vcs-python/libvcs.git')
238+
GitSync('https://github.com/vcs-python/libvcs.git')
227239
```
228240

229241
New style in >=0.13:
230242

231243
```python
232-
GitProject(url='https://github.com/vcs-python/libvcs.git')
244+
GitSync(url='https://github.com/vcs-python/libvcs.git')
233245
```
234246

235247
[pep 570]: https://peps.python.org/pep-0570/
@@ -322,20 +334,20 @@ $ pip install --user --upgrade --pre libvcs
322334

323335
### Breaking
324336

325-
- `GitRepo`, `SVNRepo`, `MercurialRepo`, `BaseRepo` have been renamed to `GitProject`, `SVNProject`,
326-
`MercurialProject`, `BaseProject` (#327)
327-
- `GitProject`, `SVNProject`, `MercurialProject`, `BaseProject` have been moved to
328-
`libvcs.projects.{module}.{Module}Project`
337+
- `GitRepo`, `SVNRepo`, `MercurialRepo`, `BaseRepo` have been renamed to `GitSync`, `SVNProject`,
338+
`HgSync`, `BaseSync` (#327)
339+
- `GitSync`, `SVNProject`, `HgSync`, `BaseSync` have been moved to
340+
`libvcs.sync.{module}.{Module}Project`
329341
- `repo_dir` param is renamed to `dir`:
330342

331-
Before: `GitProject(url='...', repo_dir='...')`
343+
Before: `GitSync(url='...', repo_dir='...')`
332344

333-
After: `GitProject(url='...', dir='...')`
345+
After: `GitSync(url='...', dir='...')`
334346

335347
#324
336348

337-
- `dir` to `pathlib`, `BaseProject.path` -> `BaseProject.dir`
338-
- Logging functions moved to {attr}`libvcs.projects.base.BaseProject.log` (#322)
349+
- `dir` to `pathlib`, `BaseSync.path` -> `BaseSync.dir`
350+
- Logging functions moved to {attr}`libvcs.sync.base.BaseSync.log` (#322)
339351
- Rename `ProjectLoggingAdapter` to `CmdLoggingAdapter`
340352
- `CmdLoggingAdapter`: Rename `repo_name` param to `keyword`
341353
- `create_repo` -> `create_project`
@@ -369,10 +381,10 @@ $ pip install --user --upgrade --pre libvcs
369381
- {meth}`libvcs.cmd.hg.Hg.run`
370382
- {meth}`libvcs.cmd.hg.Hg.clone`
371383

372-
- {class}`libvcs.projects.git.GitProject` now accepts remotes in `__init__`
384+
- {class}`libvcs.sync.git.GitSync` now accepts remotes in `__init__`
373385

374386
```python
375-
repo = GitProject(
387+
repo = GitSync(
376388
url="https://github.com/vcs-python/libvcs",
377389
repo_dir=checkout,
378390
remotes={
@@ -382,7 +394,7 @@ $ pip install --user --upgrade --pre libvcs
382394
```
383395

384396
```python
385-
repo = GitProject(
397+
repo = GitSync(
386398
url="https://github.com/vcs-python/libvcs",
387399
repo_dir=checkout,
388400
remotes={
@@ -394,7 +406,7 @@ $ pip install --user --upgrade --pre libvcs
394406
)
395407
```
396408

397-
- {meth}`libvcs.projects.git.GitProject.update_repo` now accepts `set_remotes=True`
409+
- {meth}`libvcs.sync.git.GitSync.update_repo` now accepts `set_remotes=True`
398410

399411
### Compatibility
400412

@@ -411,9 +423,9 @@ $ pip install --user --upgrade --pre libvcs
411423
[@actions/setup v3.1](https://github.com/actions/setup-python/releases/tag/v3.1.0), (#316)
412424
- New constants for `str` -> class mappings
413425

414-
- {data}`libvcs.projects.constants.DEFAULT_VCS_CLASS_MAP`
415-
- {data}`libvcs.projects.constants.DEFAULT_VCS_CLASS_UNION`
416-
- {data}`libvcs.projects.constants.DEFAULT_VCS_LITERAL`
426+
- {data}`libvcs.sync.constants.DEFAULT_VCS_CLASS_MAP`
427+
- {data}`libvcs.sync.constants.DEFAULT_VCS_CLASS_UNION`
428+
- {data}`libvcs.sync.constants.DEFAULT_VCS_LITERAL`
417429

418430
- Remove tox and tox-poetry-installer. It turns out installing poetry inside a poetry project
419431
doesn't work well. (`poetry update`, `poetry publish`, etc. commands would fail)

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ To **get started**, see the [quickstart](https://libvcs.git-pull.com/quickstart.
1818
$ pip install --user libvcs
1919
```
2020

21-
## URL Parsing (experimental)
21+
## URL Parser
2222

2323
You can validate and parse Git, Mercurial, and Subversion URLs through
24-
[`libvcs.parse`](https://libvcs.git-pull.com/parse/index.html):
24+
[`libvcs.url`](https://libvcs.git-pull.com/url/index.html):
2525

2626
Validate:
2727

2828
```python
29-
>>> from libvcs.parse.git import GitURL
29+
>>> from libvcs.url.git import GitURL
3030

3131
>>> GitURL.is_valid(url='https://github.com/vcs-python/libvcs.git')
3232
True
@@ -35,7 +35,7 @@ True
3535
Parse and adjust a Git URL:
3636

3737
```python
38-
>>> from libvcs.parse.git import GitURL
38+
>>> from libvcs.url.git import GitURL
3939

4040
>>> git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')
4141

@@ -51,7 +51,7 @@ GitURL(url=git@github.com:vcs-python/libvcs.git,
5151
Switch repo libvcs -> vcspull:
5252

5353
```python
54-
>>> from libvcs.parse.git import GitURL
54+
>>> from libvcs.url.git import GitURL
5555

5656
>>> git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')
5757

@@ -84,17 +84,16 @@ git = Git(dir=pathlib.Path.cwd() / 'my_git_repo')
8484
git.clone(url='https://github.com/vcs-python/libvcs.git')
8585
```
8686

87-
## Projects
87+
## Sync
8888

89-
Create a
90-
[`GitProject`](https://libvcs.git-pull.com/projects/git.html#libvcs.projects.git.GitProject) object
91-
of the project to inspect / checkout / update:
89+
Create a [`GitSync`](https://libvcs.git-pull.com/projects/git.html#libvcs.sync.git.GitProject)
90+
object of the project to inspect / checkout / update:
9291

9392
```python
9493
import pathlib
95-
from libvcs.projects.git import GitProject
94+
from libvcs.sync.git import GitSync
9695

97-
repo = GitProject(
96+
repo = GitSync(
9897
url="https://github.com/vcs-python/libvcs",
9998
dir=pathlib.Path().cwd() / "my_repo",
10099
remotes={
@@ -126,9 +125,9 @@ See donation options at <https://www.git-pull.com/support.html>.
126125
- Docs: <https://libvcs.git-pull.com>
127126
- Changelog: <https://libvcs.git-pull.com/history.html>
128127
- APIs for git, hg, and svn:
129-
- [`libvcs.parse`](https://libvcs.git-pull.com/parse/): Detect and Parse
128+
- [`libvcs.url`](https://libvcs.git-pull.com/url/): URL Parser
130129
- [`libvcs.cmd`](https://libvcs.git-pull.com/cmd/): Commands
131-
- [`libvcs.projects`](https://libvcs.git-pull.com/projects/): High-level synchronization commands
130+
- [`libvcs.sync`](https://libvcs.git-pull.com/sync/): Clone and update
132131
- Issues: <https://github.com/vcs-python/libvcs/issues>
133132
- Test Coverage: <https://codecov.io/gh/vcs-python/libvcs>
134133
- pypi: <https://pypi.python.org/pypi/libvcs>

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
:hidden:
1010
1111
quickstart
12-
parse/index
12+
url/index
1313
cmd/index
14-
projects/index
14+
sync/index
1515
```
1616

1717
```{toctree}

docs/parse/base.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/parse/hg.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/redirects.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@
1010
"contributing/internals/query_list.md" "internals/query_list.md"
1111
"contributing/internals/subprocess.md" "internals/subprocess.md"
1212
"contributing/internals/types.md" "internals/types.md"
13+
"parse/index.md" "url/index.md"
14+
"parse/base.md" "url/base.md"
15+
"parse/git.md" "url/git.md"
16+
"parse/hg.md" "url/hg.md"
17+
"parse/svn.md" "url/svn.md"
18+
"projects/index.md" "sync/index.md"
19+
"projects/base.md" "sync/base.md"
20+
"projects/git.md" "sync/git.md"
21+
"projects/hg.md" "sync/hg.md"
22+
"projects/svn.md" "sync/svn.md"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# `libvcs.projects.base`
1+
# `libvcs.sync.base`
22

33
Base objects / classes for projects.
44

5-
Adding your own VCS / Extending libvcs can be done through subclassing `BaseProject`.
5+
Adding your own VCS / Extending libvcs can be done through subclassing `BaseSync`.
66

77
```{eval-rst}
8-
.. automodule:: libvcs.projects.base
8+
.. automodule:: libvcs.sync.base
99
:members:
1010
:show-inheritance:
1111
```

docs/projects/git.md renamed to docs/sync/git.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `libvcs.projects.git`
1+
# `libvcs.sync.git`
22

33
For `git(1)`.
44

@@ -8,7 +8,7 @@ Compare to:
88
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)
99

1010
```{eval-rst}
11-
.. automodule:: libvcs.projects.git
11+
.. automodule:: libvcs.sync.git
1212
:members:
1313
:show-inheritance:
1414
:undoc-members:

docs/projects/hg.md renamed to docs/sync/hg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# `libvcs.projects.hg`
1+
# `libvcs.sync.hg`
22

33
For mercurial, aka `hg(1)`.
44

55
```{eval-rst}
6-
.. automodule:: libvcs.projects.hg
6+
.. automodule:: libvcs.sync.hg
77
:members:
88
:show-inheritance:
99
:undoc-members:

docs/projects/index.md renamed to docs/sync/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(projects)=
22

3-
# Projects - `libvcs.projects`
3+
# Sync - `libvcs.sync`
44

55
Compare to:
66
[`fabtools.require.git`](https://fabtools.readthedocs.io/en/0.19.0/api/require/git.html),
@@ -26,6 +26,6 @@ base
2626
## Constants
2727

2828
```{eval-rst}
29-
.. automodule:: libvcs.projects.constants
29+
.. automodule:: libvcs.sync.constants
3030
:members:
3131
```

0 commit comments

Comments
 (0)