Commit Graph

11 Commits

Author SHA1 Message Date
Durham Goode
9a40d36329 pushrebase: add test demonstrating corruption with treeonly
Summary:
There's a corruption that occurs because pushrebase caches a fulltext
instead of a tree. Let's write a test to expose it. The next diff will fix it.

Reviewed By: mitrandir77

Differential Revision: D13154341

fbshipit-source-id: e2ac040c59c677b414b6eddd39d7dc2ebb25f082
2018-11-21 08:33:48 -08:00
Jun Wu
5a3842e136 hgsql: add a test demonstrating issues we saw with treeonly pushrebases
Summary:
This happens if during prepushrebase hook, a hgsql repo sync (db -> local)
is completed by another process. `repo.manifestlog` does not get invalidated
correctly if it's treeonly.

The issue was partially detected by a C program modified from fanotify (2)
manpage example monitoring `00manifesttree.i` changes:

  [00:32:35.780] pid 7734 opens 00manifesttree.i (size 1000264)                       # First open.
  [00:32:35.930] pid 7734 reads closes (no write) 00manifesttree.i (size 1000264)
  [00:32:38.685] pid 9175 opens 00manifesttree.i (size 1000264)
  [00:32:38.885] pid 9175 reads 00manifesttree.i (size 1000264)
  [00:32:38.886] pid 9175 closes (no write) 00manifesttree.i (size 1000264)
  [00:32:39.235] pid 9175 opens 00manifesttree.i (size 1000264)
  [00:32:39.235] pid 9175 closes (no write) 00manifesttree.i (size 1000264)
  [00:32:39.236] pid 9175 opens 00manifesttree.i (size 1000264)
  [00:32:39.236] pid 9175 modifies closes 00manifesttree.i (size 1000328)             # Appended by another process.
  [00:32:41.169] pid 10759 opens 00manifesttree.i (size 1000328)
  [00:32:41.355] pid 10759 reads 00manifesttree.i (size 1000328)
  [00:32:41.355] pid 10759 closes (no write) 00manifesttree.i (size 1000328)
  [00:32:41.537] pid 10759 opens closes (no write) 00manifesttree.i (size 1000328)
  [00:32:41.537] pid 10759 opens 00manifesttree.i (size 1000392)
  [00:32:41.537] pid 10759 modifies closes 00manifesttree.i (size 1000392)            # Appended by another process.
  [00:32:44.930] pid 7734 opens closes (no write) 00manifesttree.i (size 1000392)     # Main process picked up changes.
  [00:32:44.930] pid 7734 opens 00manifesttree.i (size 1000392)
  [00:32:44.930] pid 7734 reads 00manifesttree.i (size 1000392)
  [00:32:44.930] pid 7734 modifies closes 00manifesttree.i (size 1000456)             # Main process wrote data.
  [00:32:45.275] pid 7734 opens 00manifesttree.i (size 1000456)
  [00:32:45.459] pid 7734 reads 00manifesttree.i (size 1000456)
  [00:32:45.459] pid 7734 closes (no write) 00manifesttree.i (size 1000456)
  [00:32:45.550] pid 7734 opens closes (no write) 00manifesttree.i (size 1000456)
  [00:32:45.550] pid 7734 opens 00manifesttree.i (size 1000264)
  [00:32:45.550] pid 7734 closes 00manifesttree.i (size 1000264)                      # Main process truncated to the wrong position.

Pid 7734 had "IntegrityError: 1062 (23000): Duplicate entry" error. The
fanotify log showed it truncated the revlog to a wrong location, indicating
an outdated revlog was kept in memory.

The C program was sent as D10418991.

Reviewed By: DurhamG

Differential Revision: D10417797

fbshipit-source-id: 7ccc0a976d05efbca5b3ed6fb5ff7886766d06d2
2018-10-17 20:07:47 -07:00
Durham Goode
85a676e406 treemanifest: add test for pushing treeonly commits to a treeonly repo via pushrebase
Summary:
This flow has a bug, so let's introduce a test to expose the break. The
next diff will fix the bug.

Reviewed By: quark-zju, singhsrb

Differential Revision: D10156424

fbshipit-source-id: 51d1d8da6728ee930dc1440cd3e685d7c5b5df2a
2018-10-03 08:52:18 -07:00
Jun Wu
8c33c0736a pushrebase: handle tree commits correctly for merges and renames
Summary:
In pushrebase code path, `_getmanifest` needs to be used to obtain the manifest
correctly for pushes from treeonly repos. The merge commit code path missed this
change. Fix it.

Besides, the rename checking code patch can also hit flat manifest errors via
repo.commitctx -> ... -> fctx._copied -> ctx.filenode -> ctx._fileinfo. Patch
that path too.

Reviewed By: phillco

Differential Revision: D9977904

fbshipit-source-id: 8c51aa9cc6bd85b0147d88c61a5af074e36cdb61
2018-09-21 10:26:40 -07:00
Jun Wu
1dc9519dda registrar: add a namespace predicate
Summary:
Previously, there is no easy API to add a namespace with desired order. There
is `extensions.afterloaded`, but that only works for `ui/extsetup`, not for
`reposetup`.

This diff add a namespace predicate so registering a namespace is similar to
registering a revset. It also provides an optional `after` parameter to define
the desired order, like:

  from mercurial import registrar, namespaces

  namespacepredicate = registrar.namespacepredicate()

  namespacepredicate("svn", after=["remotenames"])
  def svn(repo):
      return namespaces.namespace("svn", ...)

Existing namespaces will be migrated by upcoming changes.

This is useful for things wanting to resolve custom names, like globalrevs and
commit cloud.

Reviewed By: singhsrb

Differential Revision: D9775703

fbshipit-source-id: f15827b042d605b9cebc1ee1af6479903f47ee9c
2018-09-11 19:51:56 -07:00
Jun Wu
35b4a2b556 test-dirstate-rebuild: demonstrate dirstate rebuild problems
Summary:
With treedirstate and treestate, dirstate becomes harder to recover. The test
demonstrates related problems.

Reviewed By: DurhamG

Differential Revision: D9375195

fbshipit-source-id: a42ea84e810fe6cd9db8412c2a75fffbebdb6dc7
2018-08-17 11:38:26 -07:00
Phil Cohen
917604f2f5 tests: fold tglog into tinit; standardize
Summary:
Like D9323267, hg tests commonly reinvent common aliases to render the DAG, and they often differ very slightly. This makes adding a test require more boilerplate, and reading a test in a foreign new area slightly more overhead.

Let's standardize these to reduce the copypasta.

It's necessary to define this as a shell function instead of an hgrc alias to prevent tests that list aliases from printing it. Plus that enforces a nice separation of test/stdlib logic.

Bookmarks and branches are easy enough to add since they're empty if not used. A good number added `{phase}` -- I renamed this to `tglogp`.

Reviewed By: quark-zju

Differential Revision: D9347072

fbshipit-source-id: 6aac7de3e65d2295a7ebecd2ab30901709af3ff1
2018-08-16 10:53:43 -07:00
Phil Cohen
c6317e40fa tests: add {node|short} to showgraph()
Summary:
I hit a bug where commit hashes were useful, but it only showed up in the `hg rebase` output late in a test.

I think adding hashes to log output is generally a best practice in tests, since it prevents accidental regressions.

Reviewed By: quark-zju

Differential Revision: D9323265

fbshipit-source-id: a76a01ddd416c68fe8a1c440584b21e5d88dc82a
2018-08-14 23:20:24 -07:00
Phil Cohen
d56ff5d1de tests: move showgraph() to tinit.sh
Summary:
It's duplicate in all the fbamend tests, and I want to make a change to it. Rather than duplicate it, let's fold it into `tinit`.

In the future, I'll unify this with tglog, printdag, etc.

Reviewed By: quark-zju

Differential Revision: D9323267

fbshipit-source-id: c1db0f2f22ffadbcb8ad3c0bde329798db06f089
2018-08-14 23:20:23 -07:00
Jun Wu
320fc31e4c tinit: add drawdag and setconfig functions
Summary: They help making tests easier to write.

Reviewed By: phillco

Differential Revision: D7121645

fbshipit-source-id: 9c7181d45c4e28155eb68f355cf1c4cfc077d191
2018-04-13 21:51:20 -07:00
Jun Wu
c6742cd74c run-tests: source tinit.sh for all .t tests
Summary:
`.t` tests have some highly repeatitive logics, like creating a repo, etc.
This patch adds a common shell file that defines frequently used functions.

For now, `newrepo` and `enable` are added. The latter can be used to
enable a feature (ex. obsstore), or an extension.

`test-fb-hgext-fbamend-next.t` and `test-fb-hgext-absorb.t` are migrated
to use the new shell functions.

Reviewed By: phillco

Differential Revision: D7121485

fbshipit-source-id: 167fcc20e4e30864199b6c5af0958b80bfb68817
2018-04-13 21:51:20 -07:00