tests/test-mq-qrename.t
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 27 Feb 2016 18:22:49 -0800
branchstable
changeset 28289 d493d64757eb
parent 23402 2963d5c9d90b
permissions -rw-r--r--
hg: obtain lock when creating share from pooled repo (issue5104) There are race conditions between clients performing a shared clone to pooled storage: 1) Clients race to create the new shared repo in the pool directory 2) 1 client is seeding the repo in the pool directory and another goes to share it before it is fully cloned We prevent these race conditions by obtaining a lock in the pool directory that is derived from the name of the repo we will be accessing. To test this, a simple generic "lockdelay" extension has been added. The extension inserts an optional, configurable delay before or after lock acquisition. In the test, we delay 2 seconds after lock acquisition in the first process and 1 second before lock acquisition in the 2nd process. This means the first process has 1s to obtain the lock. There is a race condition here. If we encounter it in the wild, we could change the dummy extension to wait on the lock file to appear instead of relying on timing. But that's more complicated. Let's see what happens first.


  $ echo "[extensions]" >> $HGRCPATH
  $ echo "mq=" >> $HGRCPATH

  $ hg init a
  $ cd a

  $ echo 'base' > base
  $ hg ci -Ambase
  adding base

  $ hg qnew -mmqbase mqbase

  $ hg qrename mqbase renamed
  $ mkdir .hg/patches/foo
  $ hg qrename renamed foo

  $ hg qseries
  foo/renamed

  $ ls .hg/patches/foo
  renamed

  $ mkdir .hg/patches/bar
  $ hg qrename foo/renamed bar

  $ hg qseries
  bar/renamed

  $ ls .hg/patches/bar
  renamed

  $ hg qrename bar/renamed baz

  $ hg qseries
  baz

  $ ls .hg/patches/baz
  .hg/patches/baz

  $ hg qrename baz new/dir

  $ hg qseries
  new/dir

  $ ls .hg/patches/new/dir
  .hg/patches/new/dir

  $ cd ..

Test patch being renamed before committed:

  $ hg init b
  $ cd b
  $ hg qinit -c
  $ hg qnew x
  $ hg qrename y
  $ hg qcommit -m rename

  $ cd ..

Test overlapping renames (issue2388)

  $ hg init c
  $ cd c
  $ hg qinit -c
  $ echo a > a
  $ hg add
  adding a
  $ hg qnew patcha
  $ echo b > b
  $ hg add
  adding b
  $ hg qnew patchb
  $ hg ci --mq -m c1
  $ hg qrename patchb patchc
  $ hg qrename patcha patchb
  $ hg st --mq
  M patchb
  M series
  A patchc
  R patcha
  $ cd ..

Test renames with mq repo (issue2097)

  $ hg init issue2097
  $ cd issue2097
  $ hg qnew p0
  $ (cd .hg/patches && hg init)
  $ hg qren p0 p1
  $ hg debugstate --mq
  $ hg ci --mq -mq0
  nothing changed
  [1]
  $ cd ..

Test renaming to a folded patch (issue3058)

  $ hg init issue3058
  $ cd issue3058
  $ hg init --mq
  $ echo a > a
  $ hg add a
  $ hg qnew adda
  $ echo b >> a
  $ hg qnew addb
  $ hg qpop
  popping addb
  now at: adda
  $ hg ci --mq -m "save mq"
  $ hg qfold addb
  $ hg qmv addb
  $ cat .hg/patches/addb
  # HG changeset patch
  # Parent  0000000000000000000000000000000000000000
  
  diff -r 000000000000 a
  --- /dev/null	* (glob)
  +++ b/a	* (glob)
  @@ -0,0 +1,2 @@
  +a
  +b
  $ cd ..