tests/test-mq-pull-from-bundle.t
author Matt Harbison <matt_harbison@yahoo.com>
Sat, 03 Aug 2024 01:33:13 -0400
changeset 51871 cfd30df0f8e4
parent 39480 89630d0b3e23
permissions -rw-r--r--
bundlerepo: fix mismatches with repository and revlog classes Both pytype and PyCharm complained that `write()` and `_write()` in the bundlephasecache class aren't proper overrides- indeed they seem to be missing an argument that the base class has. PyCharm and pytype also complained that the `revlog.revlog` class doesn't have a `_chunk()` method. That looks like it was moved from revlog to `_InnerRevlog` back in e8ad6d8de8b8, and wasn't caught because this module wasn't type checked. However, I couldn't figure out a syntax with `revlog.revlog._inner._chunk(self, rev)`, as it complained about passing too many args. `bundlerevlog._rawtext()` uses this `super(...)` style to call the super class, so hopefully that works, even with the wonky dynamic subclassing. The revlog class needed the `_InnerRevlog` field typed because it isn't set in the constructor. Finally, the vfs type hints look broken. This initially failed with: File "/mnt/c/Users/Matt/hg/mercurial/bundlerepo.py", line 65, in __init__: Function readonlyvfs.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, vfs: mercurial.vfs.vfs) Actually passed: (self, vfs: Callable) Called from (traceback): line 232, in dirlog line 214, in __init__ I don't see a raw Callable, but I tried changing some of the vfs args to be typed as `vfsmod.abstractvfs`, but that class doesn't have `options`, so it failed elsewhere. `readonlyvfs` isn't a subclass of `vfs` (it's a subclass of `abstractvfs`), so I'm not sure how to handle that. It would be a shame to have to make a union of vfs subclasses (but not all of them have `options` either).

#require repobundlerepo

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > mq=
  > [alias]
  > tlog = log --template "{rev}: {node|short} {desc}\\n"
  > theads = heads --template "{rev}: {desc}\\n"
  > tincoming = incoming --template "{rev}: {desc}\\n"
  > EOF

Setup main:

  $ hg init base
  $ cd base
  $ echo "One" > one
  $ hg add
  adding one
  $ hg ci -m "main: one added"
  $ echo "++" >> one
  $ hg ci -m "main: one updated"

Bundle main:

  $ hg bundle --base=null ../main.hg
  2 changesets found

  $ cd ..

Incoming to fresh repo:

  $ hg init fresh

  $ hg -R fresh tincoming main.hg
  comparing with main.hg
  0: main: one added
  1: main: one updated
  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true

  $ hg -R fresh tincoming bundle:fresh+main.hg
  comparing with bundle:fresh+main.hg
  0: main: one added
  1: main: one updated


Setup queue:

  $ cd base
  $ hg qinit -c
  $ hg qnew -m "patch: two added" two.patch
  $ echo two > two
  $ hg add
  adding two
  $ hg qrefresh
  $ hg qcommit -m "queue: two.patch added"
  $ hg qpop -a
  popping two.patch
  patch queue now empty

Bundle queue:

  $ hg -R .hg/patches bundle --base=null ../queue.hgq
  1 changesets found
  $ test -f ./fresh/.hg/hg-bundle* && echo 'temp. bundle file remained' || true

  $ cd ..


Clone base:

  $ hg clone base copy
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd copy
  $ hg qinit -c

Incoming queue bundle:

  $ hg -R .hg/patches tincoming ../queue.hgq
  comparing with ../queue.hgq
  0: queue: two.patch added
  $ test -f .hg/hg-bundle* && echo 'temp. bundle file remained' || true

Pull queue bundle:

  $ hg -R .hg/patches pull --update ../queue.hgq
  pulling from ../queue.hgq
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 3 changes to 3 files
  new changesets d7553909353d (1 drafts)
  merging series
  2 files updated, 1 files merged, 0 files removed, 0 files unresolved
  $ test -f .hg/patches/hg-bundle* && echo 'temp. bundle file remained' || true

  $ hg -R .hg/patches theads
  0: queue: two.patch added

  $ hg -R .hg/patches tlog
  0: d7553909353d queue: two.patch added

  $ hg qseries
  two.patch

  $ cd ..


Clone base again:

  $ hg clone base copy2
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd copy2
  $ hg qinit -c

Unbundle queue bundle:

  $ hg -R .hg/patches unbundle --update ../queue.hgq
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 3 changes to 3 files
  new changesets d7553909353d (1 drafts)
  merging series
  2 files updated, 1 files merged, 0 files removed, 0 files unresolved

  $ hg -R .hg/patches theads
  0: queue: two.patch added

  $ hg -R .hg/patches tlog
  0: d7553909353d queue: two.patch added

  $ hg qseries
  two.patch

  $ cd ..