graph: align the dots with the middle of the first *visible* child element
The changelog graph will have invisible first elements when a range is selected. That caused an odd graph. Fixed by adding the :visible selector that was lost in 5258b66bf5d7.
docs: add documentation about internationalization from a user perspective
While there is already documentation about creating and updating translations (developer perspective), there was nothing for the user/admin of Kallithea. Since the handling in TurboGears2 is different, this is a good time to add it.
i18n: use TG2 compatible settings names i18n.lang and i18n.enabled
Following changes are made: - Remove list of available translations: severely outdated and hard to maintain. - Replace lang with i18n.lang, reasons: - Follow TurboGears2 conventions - Align with 'i18n.enabled' which cannot be shortened - Scoped settings provide grouping and are more clear The old 'lang' is still recognized though, so no upgrade issue. - Introduce/document i18n.enabled
Comments are intentionally kept concise in favor of the documentation.
Under TurboGears2, automatic user language detection based on browser settings is enabled by default. If a user has 'English' as preferred language in the browser, then the old English .mo file with a few dummy entries would be read and used first, before trying the language configured in the Kallithea .ini file (e.g. French). This renders a mix of languages in the UI ... which is unexpected.
The hiding of configured translation is fixed by removing the old english translationfile. It was preserved via commit 7d6c4bd58abd when removing all other .mo files. The next release will require major config changes anyway, and we don't try to be backwards compatible.
When the browser size has been changed, the dots may no longer be correctly aligned with the table rows. Currently, the graph will just overflow without changing size, but that can soon change.
style: use plain Bootstrap with existing CSS styling
This is an intermediate step, trying to make our markup stay as close to plain Bootstrap as possible, minimize the amount of customizations, and accept small visual differences.
More long term, we will try to move to generated CSS with Bootstrap and our customizations.
email: don't crash on sending mails with unicode comments without appropriate environment configuration (Issue #275)
For example, on Linux, running `gearbox serve` with LANG=C, would crash in:
File ".../kallithea/lib/celerylib/tasks.py", line 307, in send_email % (' '.join(recipients), headers, subject, body, html_body)) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 224: ordinal not in range(128)
Replacing render with render_unicode works in this case ... but there might be other problems elsewhere.
make-config: use %(here)s in the generated file instead of hardcoding absolute path
Restore what paster make-config did until we introduced gearbox in d2aa8b1625a4. The make-config sub command was re-introduced in 6c8af2d22deb but created files with absolute paths.
Neither git nor mercurial nodes have a _mimetype attribute. Only test_nodes.test_mimetype monkey patches it and that to me seems just wrong. Thus, remove that part and fix the test with some usefull assertions.
pylint found import-error 'import objgraph'. This is bit-rotten and doesn't seem like something we need. If we need it, there is probably a better way to do it now.
docs: clarify that Session usually should be called - methods should not be used directly
Documentation based on clarification by Søren Løvborg:
Session is the factory/singleton manager, which tracks the current session (per thread). To end the current session entirely and destroy the Session object, we call remove on the manager (Session.remove()). (A new session will be created on-demand.)
Session() returns the current session for the active thread (or creates a new session, if there's none). commit is a method of the SQLAlchemy Session class, thus called as Session().commit() ... it's a method call on the current Session object, not the session factory/manager.
SQLAlchemy may have some hackery to allow Session.commit() to be called, and the call automatically redirect to the actual Session object... but that's a hack and should be avoided.
TL;DR: for remove, call it on Session; for everything else, call it on Session().
setup: don't use setuptools 34 - it has indirect conflicts with the celery version supported on the stable branch (Issue #266)
Setuptools==34 requires packaging>=16.8 which has an unconstrained requirement of pyparsing ... but actually it doesn't work with pyparsing==1.5.7 ... which is required by celery<2.3 ... which this version of Kallithea requires.
Celery has been upgraded on the development branch but we don't want to do that on the stable branch.
tests: check returncode from executing external commands
If a command fails, it could lead to undefined behavior, which lets tests fail without clear indication of the cause of the failures. Therefore, if not stated otherwise, check the return code.
pullrequests: fix "additional changes" js error - make sure all cs tables have a first column to align with (Issue #274)
A slight simplification of 16234f629cfb and fixing a JavaScript failure for unauthenticated visits to PRs with pending available changesets.
nextFirstincell would be undefined becuase the "Current revision - no change" line didn't have any elements in td, and nextFirstincell.offsetTop would thus fail.
Fixed by adding a span around the text.
Also clarify that any element is fine - there is no need to check for visibility.
logging: don't change the log level in the handler config
I find it confusing that even though the log level for sqlalchemy.engine was INFO, because the log level of handler_console_sql was WARN, there were no INFO output from sqlalchemy.engine. Therefore remove the level setting for the handlers in the default settings. I think this makes it (a bit) more intuitive.
repositories: make sure repositories not only differ in casing
Repositories only differing in case cause problems: * it can't be stored on case insensitive filesystems (Windows and MacOS) * some databases can't easily handle case sensitive queries * users will most certainly be confused by names that only differ in case
We will keep trying to be case sensitive on systems that can ... but on some systems wrong casings might work. We don't care.
The validators are changed to prevent mixed case repo and repo group names.
Repository sensitivity tests are removed, and insensitivity tests are added instead.
tests: clarify that default parameters are for form - direct model access requires different types
_get_repo_group_create_params parent_group_id is thus set to the form value '-1' instead of None. It worked before anyway because the model failed to find the repo '-1' and thus got pretty much the same as None.
db: drop and re-create old schemas instead of Base.metadata.drop_all()
Sadly, Base.metadata.drop_all() sometimes doesn't work because of foreign key constraints. We only know this is the case on PostgreSQL and MySQL - use workarounds for these.
db: upgrade to SQLAlchemy 1.1, fixing invalid PostgreSQL SQL in User.is_default_user
eea19c23b741 triggered a bug in SQLAlchemy 1.0.17, causing invalid SQL to be emitted for PostgreSQL: For the (Python) query '(x == y) == z', SQLAlchemy generates the SQL 'x = y = z'. SQLite and MySQL accepts this, but PostgreSQL does not. This bug has been fixed in 1.1.
lock: fix encoding error when Mercurial emits a localized warning with the Kallithea "repository locked" message
Mercurial use (utf8) encoded localized messages. Things failed when it tried to convert the encoded Mercurial format string to unicode so it could insert Kallithea's unicode (but ascii compatible) "repository locked" exception string.
That could for example be reproduced by running the (manual) vcs test test_push_on_locked_repo_by_other_user_hg with environment LANG=de_DE for the server side.
To fix this, make sure the "repository locked" message is encoded so Mercurial handles it correctly.
tests: use relative path when adding file to git repo (fixes error with newer git versions)
Newer git versions would fail 'git add /path/to/file' with: fatal: /path/to/file: '/path/to/file' is outside repository That caused test_push_unlocks_repository_git to fail.
To fix that, use relative instead of absolute path.
tests: add workaround for failing manual vcs tests test_ip_restriction_*
Back out a part of ee88c8c07111; invalidate_all_caches would expire beaker caches ... but that doesn't work so well for expiring the cache in the separate server process used for vcs tests.
When a pull request is created, stick a reference to it in the refs/pull namespace, similarly to what GitHub does, and remove it when the pull request is deleted. That reference guarantees the commits stay around and don't get garbage-collected when a PR is rebased or revised. Also, that makes it possible to access head of historic pull requests using Git by fetching a ref from the source repository.
Unlike GitHub though, we don't put the ref into the destination repository and don't copy commits there to prevent undesired repository growth. Kallithea uses global pull request identifiers, so there should not be any confusion as to what pull request the ref corresponds to. We may later provide a shim to redirect users to the source repository if that deems needed.
admin: clean-up of Gravatar and IP in user profile headers
Move things around and use Bootstrap compatible markup.
The user IP will rarely be relevant - especially not on the admin pages; the IP configuration there is more for other user's IP. It might however be somewhat relevant for a (non-admin) user to know his own IP. There is no obvious place to show that - it doesn't really fit in as a part of the user profile. Anyway, just show it under Show Permissions.
gearbox: fix setup-db failure when db is created for the first time (Issue #272)
The port to TG2 in e1ab82613133 replaced pylonsconfig.init_app for gearbox commands with middleware setup code. That introduced reading of the database for commands that don't need a database - for example the command for creating databases ... which thus failed.
To fix that, move the middleware setup with database access so it only is run for gearbox command that requires a db session. There is apparently no need for a direct replacement for pylonsconfig.init_app .
gearbox: avoid duplicate logging setup when calling make_app
make_app initialized logging, while the gearbox common code does it too. Split make_app in two to be able to avoid the redundant call.
The logging setup in make_app cannot be removed because it is needed for 'gearbox serve' and direct WSGI invocation, which does not pass through gearbox common.py.
This fixes manual_test_vcs_operations.py failures after e1ab82613133 dropped test_env and test_index parameters to load_environment without fixing handle_git_receive().
It is unfortunate that generic lib code depends on kallithea.lib.paster_commands.common - it would make more sense if it was the other way around. We thus move the import down to inside the function that needs it.
The import of kallithea.lib.paster_commands.common in db_manage triggered its import of logging.config . middleware.py thus also got logging.config when it just imported logging and things worked. Without this import of paster_commands, we also have to fix the import in db_manage.
pullrequests: fix broken "new PR iteration" handling of ancestor changes
An earlier refactor (5d60c9a391cd) flubbed this code and accidentally assumed the most recent common ancestor would not change when iterating, which is of course only the case when there are no merges from 'other' to 'org' among the new revisions.
This was not only not caught during manual testing (nor review), but neither did the test suite test this. That has now also been rectified.
Jenkinsfile: run each py.test on a separate executor
Running all py.test processes in parallel on the same executor is not a good idea. If a node has not much RAM, it could run out of memory when all py.test processes run at the same time. And If there are only 2 CPU cores, it doesn't make sense to run more then 2 processes either. Therefore use a separate executor for each one. The py.test processes will thus only run in parallel if there are multiple Jenkins executors available.