mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
9dc21f8d0b
Summary: D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`. That has nasty problems if both `import mercurial` and `import edenscm.mercurial` are used, because Python would think `mercurial.foo` and `edenscm.mercurial.foo` are different modules so code like `try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)` would fail to handle the `edenscm.mercurial` version. There are also some module-level states (ex. `extensions._extensions`) that would cause trouble if they have multiple versions in a single process. Change imports to use the `edenscm` so ideally the `mercurial` is no longer imported at all. Add checks in extensions.py to catch unexpected extensions importing modules from the old (wrong) locations when running tests. Reviewed By: phillco Differential Revision: D13868981 fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
51 lines
1.6 KiB
Perl
51 lines
1.6 KiB
Perl
Tests about metadataonlyctx
|
|
|
|
$ hg init
|
|
$ echo A > A
|
|
$ hg commit -A A -m 'Add A'
|
|
$ echo B > B
|
|
$ hg commit -A B -m 'Add B'
|
|
$ hg rm A
|
|
$ echo C > C
|
|
$ echo B2 > B
|
|
$ hg add C -q
|
|
$ hg commit -m 'Remove A'
|
|
|
|
$ cat > metaedit.py <<EOF
|
|
> from __future__ import absolute_import
|
|
> from edenscm.mercurial import context, registrar
|
|
> cmdtable = {}
|
|
> command = registrar.command(cmdtable)
|
|
> @command('metaedit')
|
|
> def metaedit(ui, repo, arg):
|
|
> # Modify commit message to "FOO"
|
|
> with repo.wlock(), repo.lock(), repo.transaction('metaedit'):
|
|
> old = repo['.']
|
|
> kwargs = dict(s.split('=', 1) for s in arg.split(';'))
|
|
> if 'parents' in kwargs:
|
|
> kwargs['parents'] = kwargs['parents'].split(',')
|
|
> new = context.metadataonlyctx(repo, old, **kwargs)
|
|
> new.commit()
|
|
> EOF
|
|
$ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'text=Changed'
|
|
$ hg log -r tip
|
|
changeset: 3:ad83e9e00ec9
|
|
tag: tip
|
|
parent: 1:3afb7afe6632
|
|
user: test
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
summary: Changed
|
|
|
|
$ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0' 2>&1 | egrep '^RuntimeError'
|
|
RuntimeError: new p1 manifest (007d8c9d88841325f5c6b06371b35b4e8a2b1a83) is not the old p1 manifest (cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd)
|
|
|
|
$ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'user=foo <foo@example.com>'
|
|
$ hg log -r tip
|
|
changeset: 4:1f86eaeca92b
|
|
tag: tip
|
|
parent: 1:3afb7afe6632
|
|
user: foo <foo@example.com>
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
summary: Remove A
|
|
|