Commit Graph

5 Commits

Author SHA1 Message Date
Jun Wu
9dc21f8d0b codemod: import from the edenscm package
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
2019-01-29 17:25:32 -08:00
Ryan McElroy
9e51fdef40 context: fix sanity check in metadataonlyctx
Summary:
Previously, this check was subtly wrong, causing it to fail for empty
commits (which have the same manifest as their parents). Update the check to
ensure the actual thing we want to ensure -- that the caller isn't creating
incorrect commits.

The failure would happen in this case:

```
  B  empty commit (manifest Am)
  |
  A  draft commit (manifest Am)
 /
M  master (manifest Mm)
```

When metaediting `A`, `metaedit` would then "rebase" `B` onto `A'` to create
`B'`, with both `A'` and `B'` reusing `Am` as their manifest. The old check
would fail here because the parent of `Am` is `Mm`, but the manifest of `A'`
(the parent of `B'`) is `Am`, so when checking the manifest of the parent
against the parent of the manifest, we would find that `Am != Mm` and fail.

The actual check we wanted was that the manifest of the parent of `B'` is the
same as the manifest of the parent of `B` -- which the old check approximated
as long as no manifests were reused in the stack. As this is not sufficient
with empty commits, we instead want to check that the manifest of the old
parent matches the manifest of the new parent, which we now do.

By avoid reading `manifest.parents`, this would also avoid some lazy tree
fetches, therefore speed up metaedit in certain cases.

Reviewed By: quark-zju

Differential Revision: D9013995

fbshipit-source-id: 4d0b05fc9bb81d115cd87ba2bf98aa253ae6f88b
2018-07-27 02:49:19 -07:00
Ryan McElroy
2b7e9e5e8b context: show how metaedit can crash with empty rebased commits
Reviewed By: quark-zju

Differential Revision: D9013996

fbshipit-source-id: f5d1cfc687981e07e51ef58f07fac17602c6233d
2018-07-27 02:49:19 -07:00
Jun Wu
ada59ccd75 check-code: forbid "\S" in egrep regular expression
BSD `egrep` does not like it. So let's forbid it.

Differential Revision: https://phab.mercurial-scm.org/D610
2017-09-01 16:44:30 -07:00
Jun Wu
3f18e3a17c metadataonlyctx: don't crash when reusing the manifest with deletions
This was originally fixed by Mateusz Kwapich for the `metaedit` command in
fb-hgext with a test for the `metaedit` command. It didn't get upstreamed
because `metaedit` was not in core.

This patch fixes the crash and adds a test about `metadataonlyctx` to
avoid future regressions.

Differential Revision: https://phab.mercurial-scm.org/D550
2017-08-28 16:58:59 -07:00