mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +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
67 lines
1.5 KiB
Perl
67 lines
1.5 KiB
Perl
$ hg init
|
|
|
|
$ cat > .hg/hgrc <<EOF
|
|
> [extensions]
|
|
> prefixfilter = prefix.py
|
|
> [encode]
|
|
> *.txt = stripprefix: Copyright 2046, The Masters
|
|
> [decode]
|
|
> *.txt = insertprefix: Copyright 2046, The Masters
|
|
> EOF
|
|
|
|
$ cat > prefix.py <<EOF
|
|
> from edenscm.mercurial import error
|
|
> def stripprefix(s, cmd, filename, **kwargs):
|
|
> header = '%s\n' % cmd
|
|
> if s[:len(header)] != header:
|
|
> raise error.Abort('missing header "%s" in %s' % (cmd, filename))
|
|
> return s[len(header):]
|
|
> def insertprefix(s, cmd):
|
|
> return '%s\n%s' % (cmd, s)
|
|
> def reposetup(ui, repo):
|
|
> repo.adddatafilter('stripprefix:', stripprefix)
|
|
> repo.adddatafilter('insertprefix:', insertprefix)
|
|
> EOF
|
|
|
|
$ cat > .hgignore <<EOF
|
|
> .hgignore
|
|
> prefix.py
|
|
> prefix.pyc
|
|
> EOF
|
|
|
|
$ cat > stuff.txt <<EOF
|
|
> Copyright 2046, The Masters
|
|
> Some stuff to ponder very carefully.
|
|
> EOF
|
|
$ hg add stuff.txt
|
|
$ hg ci -m stuff
|
|
|
|
Repository data:
|
|
|
|
$ hg cat stuff.txt
|
|
Some stuff to ponder very carefully.
|
|
|
|
Fresh checkout:
|
|
|
|
$ rm stuff.txt
|
|
$ hg up -C
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ cat stuff.txt
|
|
Copyright 2046, The Masters
|
|
Some stuff to ponder very carefully.
|
|
$ echo "Very very carefully." >> stuff.txt
|
|
$ hg stat
|
|
M stuff.txt
|
|
|
|
$ echo "Unauthorized material subject to destruction." > morestuff.txt
|
|
|
|
Problem encoding:
|
|
|
|
$ hg add morestuff.txt
|
|
$ hg ci -m morestuff
|
|
abort: missing header "Copyright 2046, The Masters" in morestuff.txt
|
|
[255]
|
|
$ hg stat
|
|
M stuff.txt
|
|
A morestuff.txt
|