|
|
Mads Kiilerich
|
da519b9782e8
|
4 years ago
|
|
|
|
|
Mads Kiilerich
|
de59ad8185e1
|
4 years ago
|
|
git: fix whitespace in previous commit scripts/whitespacecleanup.sh will remove tabs introduced in f0fbb0fe4462 ... but that is fine; it was just an example.
|
|
|
Mads Kiilerich
|
f0fbb0fe4462
|
4 years ago
|
|
git: update check for invalid URL characters to work with Python versions that include an attempt at fixing the very same problem With changes like https://github.com/python/cpython/commit/76cd81d60310d65d01f9d7b48a8985d8ab89c8b4making it to Python 3.10 and being backported to previous Python versions, the approach in a8a51a3bdb61 no longer works when combined with urllib.parse.urlparse in d2f59de17bef: path will never contain the invalid characters. To catch this case anyway, add a new check to verify that the parsed URL can roundtrip back to the original representation with urllib.parse.urlunparse . The actual exception might vary, but one of them should always fire. There is a risk that the new check will reject some URLs that somehow isn't normalized. No such cases have been found yet.
|
|
|
Mads Kiilerich
|
9a2c0a067c6e
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
911669ac48a5
|
5 years ago
|
|
vcs: drop repo contact ... and the odd uses of it
A half-baked and essentially unused hgweb feature.
The reference in get_commits_stats doesn't seem reachable in any relevant use cases.
|
|
|
Mads Kiilerich
|
d2f59de17bef
|
5 years ago
|
|
vcs: use urlparse in _check_url
This makes URL checking more standard and more explicit.
|
|
|
Mads Kiilerich
|
526c8751d75b
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
2fac3c55f9bc
|
5 years ago
|
|
vcs: slight clean up of _check_url
Make static void function static and without return value.
|
|
|
Mads Kiilerich
|
7b7afdbe57af
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
a8a51a3bdb61
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
3ea3d3a2b3e3
|
5 years ago
|
|
git: make sure _check_url only accept the protocols accepted by is_valid_repo_uri
Avoid unnecessary flexibility, ambiguity, and complexity.
The file protocol was never used. But when cloning existing managed repos, is_valid_repo_url would be skipped and _check_url would be called with absolute paths.
|
|
|
Mads Kiilerich
|
aee4c451566f
|
5 years ago
|
|
|
|
|
Mads Kiilerich
|
f3fab7b124f2
|
5 years ago
|
|
imports: try to use global imports unless it is a layering violation
To minimize the impact, do imports that violate the layering at runtime instead of at import time.
|
|
|
Mads Kiilerich
|
16a359ce1801
|
5 years ago
|
|
vcs: move changeset diff from controller to vcs
Remove unfortunate model dependency on controller ... and put the VCS details where they belong, with less VCS specific knowledge in the controllers.
|
|
|
Mads Kiilerich
|
07cb7b42057e
|
5 years ago
|
|
|
|
|
Thomas De Schampheleire
|
d1521d421610
|
5 years ago
|
|
vcs: extract get_urllib_request_handlers out of {hg,git}/repository.py
Avoid some duplication between hg and git backends. A subsequent commit will need bugfixes in this area.
|
|
|
Mads Kiilerich
|
75e2d061385a
|
6 years ago
|
|
vcs: fix validation of Git https URLs (Issue #365)
Fix py3 migration bug.
|
|
|
Mads Kiilerich
|
5b1f43027662
|
6 years ago
|
|
scripts: drop isort --wrap-length 160 - it is broken with py3 and not really necessary Under Python 3, isort 4.3.21 failed with https://github.com/timothycrosley/isort/issues/741 on kallithea/controllers/api/api.py : Traceback (most recent call last): File "data/env/bin/isort", line 10, in <module> sys.exit(main()) File ".../env/lib64/python3.7/site-packages/isort/main.py", line 379, in main for sort_attempt in attempt_iterator: File ".../env/lib64/python3.7/site-packages/isort/main.py", line 377, in <genexpr> attempt_iterator = (sort_imports(file_name, **arguments) for file_name in file_names) File ".../env/lib64/python3.7/site-packages/isort/main.py", line 88, in sort_imports result = SortImports(file_name, **arguments) File ".../env/lib64/python3.7/site-packages/isort/isort.py", line 207, in __init__ self._add_formatted_imports() File ".../env/lib64/python3.7/site-packages/isort/isort.py", line 606, in _add_formatted_imports self._add_from_imports(from_modules, section, section_output, sort_ignore_case) File ".../env/lib64/python3.7/site-packages/isort/isort.py", line 526, in _add_from_imports import_statement = self._multi_line_reformat(import_start, from_import_section, comments) File ".../env/lib64/python3.7/site-packages/isort/isort.py", line 552, in _multi_line_reformat dynamic_indent, indent, line_length, comments) File ".../env/lib64/python3.7/site-packages/isort/isort.py", line 705, in _output_grid if len(next_statement.split(self.line_separator)[-1]) + 1 > line_length: TypeError: '>' not supported between instances of 'int' and 'str'
|
|
|
Thomas De Schampheleire
|
37ec17c1344c
|
6 years ago
|
|
vcs: fix repo creation with a remote clone uri under Python 3
When trying to add a new repository based on a remote clone, it fails in Python 3 as follows, for git:
ERROR kallithea.model.validators:validators.py:413 URL validation failed Traceback (most recent call last): File ".../kallithea/model/validators.py", line 411, in _validate_python is_valid_repo_uri(repo_type, url, make_ui()) File ".../kallithea/lib/utils.py", line 250, in is_valid_repo_uri GitRepository._check_url(url) File ".../kallithea/lib/vcs/backends/git/repository.py", line 174, in _check_url if not test_uri.endswith('info/refs'): TypeError: endswith first arg must be bytes or a tuple of bytes, not str
and for hg, the other way around:
ERROR kallithea.model.validators:validators.py:413 URL validation failed Traceback (most recent call last): File ".../kallithea/model/validators.py", line 411, in _validate_python is_valid_repo_uri(repo_type, url, make_ui()) File ".../kallithea/lib/utils.py", line 233, in is_valid_repo_uri MercurialRepository._check_url(url, ui) File ".../kallithea/lib/vcs/backends/hg/repository.py", line 297, in _check_url if os.path.isdir(url) or url.startswith(b'file:'): TypeError: startswith first arg must be str or a tuple of str, not bytes
In both cases, the code seems to actually expect a bytes url.
|
|
|
Mads Kiilerich
|
5725fa4cfecd
|
6 years ago
|
|
cleanup: minimize use of lambda expressions - we have 'def' for that purpose
Fix some flake8 warnings "E731 do not assign a lambda expression, use a def".
|
|
|
Mads Kiilerich
|
e63bcce18fef
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
f9988201a3c4
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
1112e440b921
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
08eec03c9485
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e51ad2cd400e
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e35373106528
|
6 years ago
|
|
py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings
(The remaining safe_unicode calls are still needed and can't just be removed, generally because we in these cases still have to convert from bytes to unicode strings.)
|
|
|
Mads Kiilerich
|
22b40db44a41
|
6 years ago
|
|
py3: migrate from urllib2 to urllib
Based on 2to3 urllib, but with unnecessary imports removed.
|
|
|
Mads Kiilerich
|
fb4b72c1c0f1
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
756e46bd926b
|
6 years ago
|
|
py3: trivial renaming of .iteritems() to .items()
A bit like "2to3 -f dict", but we don't want list().
|
|
|
Mads Kiilerich
|
42ef4ea26efa
|
6 years ago
|
|
vcs: drop unused get_hook_location (Issue #353)
Also, the hg implementation was odd - the '.hgrc' directory name looks very similar to 'hgrc' but could be anything, such as 'hooks'.
|
|
|
Mads Kiilerich
|
5ddd6b930dd0
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
c78fd87d362b
|
6 years ago
|
|
vcs: tweak how revisions and repo names are shown in error messages
Decode bytes to str, and show repo name instead of repr or full server file system path. In some places, it will only report the "basename" of the repository, without any "group names" that also would be nice to have. The easy alternative would be to show the full file system path ... but it would be unfortunate to leak absolute server side paths to end users.
|
|
|
Mads Kiilerich
|
135bbd1862cf
|
6 years ago
|
|
vcs: minor cleanup
Make it more friendly to humans and py3.
|
|
|
Mads Kiilerich
|
4eacfdf08b9a
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
f713a37564c0
|
6 years ago
|
|
vcs: drop the superfluous and leaky hgcompat "layer"
Explicit is better. And gives less pyflakes noise.
|
|
|
Mads Kiilerich
|
e7dbe089e10d
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
45bfab30d433
|
6 years ago
|
|
py3: add b'' annotations in some places where they will be needed later
Mostly entirely trivial adding of b prefix that is a ignored for py2 ... and also a bit of related trivial reformatting/refactorings.
|
|
|
Mads Kiilerich
|
000aa9cb25f1
|
6 years ago
|
|
vcs: refactor and simplify _get_revision
This will be more thorough checking that revisions actually exist, and will in some cases give better error messages.
But mainly, prepare for py3 where this was easier to make work correctly.
|
|
|
Mads Kiilerich
|
ca9df5a30ab2
|
6 years ago
|
|
vcs: refactor run_git_command to just return stdout as unicode string
This will be convenient for py3.
|
|
|
Mads Kiilerich
|
450f34f29f89
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
59456e7a12b6
|
6 years ago
|
|
vcs: change get_diff to use _run_git_command directly
This will allow run_git_command to return strings while get_diff still return raw bytes.
|
|
|
Mads Kiilerich
|
804dc8c6d204
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
e7b6a0ce123c
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
ad8328c8ed40
|
6 years ago
|
|
vcs: fix get_changesets to .reverse() list of revision hashes in place instead of using reversed()
This is slightly more performant, and will also make CollectionGenerator work with reverse=True. Before, CollectionGenerator was used on get_changesets, but never with reverse option. Trying to use reverse, it would fail when applying len():
TypeError: object of type 'listreverseiterator' has no len()
|
|
|
Mads Kiilerich
|
8dbe46ca608f
|
6 years ago
|
|
vcs: close SubprocessIOChunker after use - it has a close method, so let's make sure we use it
It might not be strictly necessary, but it might free some resources earlier.
|
|
|
Mads Kiilerich
|
fcfc62767107
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
548357c4301d
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
0a277465fddf
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
708f1a55f174
|
6 years ago
|
|
|
|
|
Mads Kiilerich
|
75b128508fa8
|
6 years ago
|
|
|
|
|
domruf
|
32e6957d0aac
|
8 years ago
|
|
api: add max_revisions option to get_changesets
The returning JSON can become pretty big and hard to parse. Therefore add an option that allows a client to request the changesets in smaller chuncks.
|
|
|
Mads Kiilerich
|
2a96678c8cd9
|
8 years ago
|
|
|
|
|
branko
|
55d2b08d9c44
|
8 years ago
|
|
vcs: sanitize diff context values (Issue #306)
- Updated Git repository implementation to ensure context falls within 0 to 2**31-1 range (inclusive) when fetching a diff. - Added tests for Git repositories for checking passed-in negative and overflowing contexts (for the --unified option). - Updated Mercurial repository implementation to ensure context is not negative when fetching a diff. - Added tests for Mercurial repositories for checking passed-in negative context (for the --unified option).
|
|
|
Lars Kruse
|
c1ed9572b965
|
8 years ago
|
|
codingstyle: replace "not ... in ..." with "... not in ..."
Reported by flake8.
|
|
|
Lars Kruse
|
7691290837d2
|
8 years ago
|
|
codingstyle: trivial whitespace fixes
Reported by flake8.
|
|
|
Eivind Tagseth
|
6fb68819e58e
|
8 years ago
|
|
git: improve performance working with git changesets
GitRepository._repo instantiates a new dulwich.repo.Repo on every usage, rather than once at initialization time of GitRepository. As this involves a lot of filesystem access, this is a costly operation.
Instead, let GitRepository.__init__ instantiate a dulwich.repo.Repo once, and let GitRepository._repo just return it.
This improves performance significantly. On test_graphmod_git, performance improves from 6.29 seconds median to 3.06 seconds median.
[Thomas De Schampheleire: extend improvement to _all_ usage of GitRepository._repo instead of only some. To limit the delta, retain the _repo property but simply return self.repo.]
|
|
|
Mads Kiilerich
|
182f46d62ab4
|
8 years ago
|
|
|
|
|
Andrew Shadura
|
81ff11476d16
|
9 years ago
|
|
git: make sure repository path and name are Unicode strings
This is needed for supporting latest Dulwich version, but it also works with out supported version.
|
|
|
Mads Kiilerich
|
092ea4d40d60
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
1ea1761bab12
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
7d0727d11104
|
10 years ago
|
|
cleanup: remove unused imports
Found with pyflakes.
|
|
|
Mads Kiilerich
|
d69aa464f373
|
10 years ago
|
|
cleanup: consistently use 'except ... as ...:'
Use the Python 2.6+ syntax instead of the old confusing 'except ..., ...' syntax.
|
|
|
Andrew Bartlett
|
c082a017b366
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
0e2d450feb03
|
10 years ago
|
|
|
|
|
Mads Kiilerich
|
06c4ff173b5b
|
10 years ago
|
|
|
|
|
Matthias Zilk
|
c44885d0e546
|
10 years ago
|
|
vcs: added proper windows quoting to git commands (Issue #135)
Git repositories could not be forked on windows.
|
|
|
Mads Kiilerich
|
d8993baa00dc
|
10 years ago
|
|
git: avoid OSError when encountering invalid lock file
This avoids crashing when repo scanning makes dulwich look at its own pip install directory.
|
|
|
Thomas De Schampheleire
|
dabdc356393b
|
11 years ago
|
|
|
|
|
Mads Kiilerich
|
8996b4f57dad
|
11 years ago
|
|
git: preserve line endings when calling out to git \r line endings were replaced with \n, and some diffs would thus fail to parse. That would be the cases similar to what was addressed in fbb992c719aa. The leading text would be ignored anyway in diffs.py so there is no need to strip it here. The stripping do also not seem very reliable. But for now we will keep it.
|
|
|
Mads Kiilerich
|
cc1ab5ef6686
|
11 years ago
|
|
cleanup: avoid some 'except Exception' catching - catch specific exceptions or log it and show what happened
This has a risk of introducing regressions ... but we want to get rid of all exception muting and make the whole system less fragile and easier to debug.
|
|
|
Mads Kiilerich
|
395be5fa6eef
|
11 years ago
|
|
|
|
|
Mads Kiilerich
|
df33fcf96df2
|
11 years ago
|
|
|
|
|
Daniel Anderson
|
a6dfd14d4b20
|
11 years ago
|
|
Escape shell command parts for Git backend
Python 2.x uses pipes.quote and Python 3.3+ uses shlex.quote in GitRepository._run_git_command()
|
|
|
Mads Kiilerich
|
e50e6384c529
|
11 years ago
|
|
|
|
|
Bradley M. Kuhn
|
d1addaf7a91e
|
11 years ago
|
|
Second step in two-part process to rename directories. This is the actual directory rename.
|