tests/test-convert-bzr-directories.t
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Tue, 02 Jun 2015 02:28:33 +0900
branchstable
changeset 25392 ed18f4acf435
parent 15487 3c72117a7a0e
child 26066 89872688893f
permissions -rw-r--r--
templatekw: compare target context and its parent exactly (issue4690) Before this patch, template keywords `{file_mods}`, `{file_adds}` and `{file_dels}` use values gotten by `repo.status(ctx.p1().node(), ctx.node())`. But this doesn't work as expected if `ctx` is `memctx` or `workingcommitctx`. Typical case of templating with these contexts is customization of the text shown in the commit message editor by `[committemplate]` configuration. In this case, `ctx.node()` returns None and it causes comparison between `ctx.p1()` and `workingctx`. `workingctx` lists up all changed files in the working directory even at selective committing. BTW, `{files}` uses `ctx.files()` and it works as expected. To compare target context and its parent exactly, this patch passes `ctx.p1()` and `ctx` without `node()`-nize. This avoids unexpected comparison with `workingctx`. This patch uses a little redundant template configurations in `test-commit.t`, but they are needed to avoid regression around problems fixed by a4958cdb2202 and 1e6fb8db666e: accessing on `ctx` may break `ctx._status` field.


  $ . "$TESTDIR/bzr-definitions"

empty directory

  $ mkdir test-empty
  $ cd test-empty
  $ bzr init -q source
  $ cd source
  $ echo content > a
  $ bzr add -q a
  $ bzr commit -q -m 'Initial add'
  $ mkdir empty
  $ bzr add -q empty
  $ bzr commit -q -m 'Empty directory added'
  $ echo content > empty/something
  $ bzr add -q empty/something
  $ bzr commit -q -m 'Added file into directory'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  2 Initial add
  1 Empty directory added
  0 Added file into directory
  $ manifest source-hg 1
  % manifest of 1
  644   a
  $ manifest source-hg tip
  % manifest of tip
  644   a
  644   empty/something
  $ cd ..

directory renames

  $ mkdir test-dir-rename
  $ cd test-dir-rename
  $ bzr init -q source
  $ cd source
  $ mkdir tpyo
  $ echo content > tpyo/something
  $ bzr add -q tpyo
  $ bzr commit -q -m 'Added directory'
  $ bzr mv tpyo typo
  tpyo => typo
  $ bzr commit -q -m 'Oops, typo'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  1 Added directory
  0 Oops, typo
  $ manifest source-hg 0
  % manifest of 0
  644   tpyo/something
  $ manifest source-hg tip
  % manifest of tip
  644   typo/something
  $ cd ..

nested directory renames

  $ mkdir test-nested-dir-rename
  $ cd test-nested-dir-rename
  $ bzr init -q source
  $ cd source
  $ mkdir -p firstlevel/secondlevel/thirdlevel
  $ echo content > firstlevel/secondlevel/file
  $ echo this_needs_to_be_there_too > firstlevel/secondlevel/thirdlevel/stuff
  $ bzr add -q firstlevel
  $ bzr commit -q -m 'Added nested directories'
  $ bzr mv firstlevel/secondlevel secondlevel
  firstlevel/secondlevel => secondlevel
  $ bzr commit -q -m 'Moved secondlevel one level up'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  1 Added nested directories
  0 Moved secondlevel one level up
  $ manifest source-hg tip
  % manifest of tip
  644   secondlevel/file
  644   secondlevel/thirdlevel/stuff
  $ cd ..

directory remove

  $ mkdir test-dir-remove
  $ cd test-dir-remove
  $ bzr init -q source
  $ cd source
  $ mkdir src
  $ echo content > src/sourcecode
  $ bzr add -q src
  $ bzr commit -q -m 'Added directory'
  $ bzr rm -q src
  $ bzr commit -q -m 'Removed directory'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  1 Added directory
  0 Removed directory
  $ manifest source-hg 0
  % manifest of 0
  644   src/sourcecode
  $ manifest source-hg tip
  % manifest of tip
  $ cd ..

directory replace

  $ mkdir test-dir-replace
  $ cd test-dir-replace
  $ bzr init -q source
  $ cd source
  $ mkdir first second
  $ echo content > first/file
  $ echo morecontent > first/dummy
  $ echo othercontent > second/something
  $ bzr add -q first second
  $ bzr commit -q -m 'Initial layout'
  $ bzr mv first/file second/file
  first/file => second/file
  $ bzr mv first third
  first => third
  $ bzr commit -q -m 'Some conflicting moves'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  1 Initial layout
  0 Some conflicting moves
  $ manifest source-hg tip
  % manifest of tip
  644   second/file
  644   second/something
  644   third/dummy
  $ cd ..

divergent nested renames (issue3089)

  $ mkdir test-divergent-renames
  $ cd test-divergent-renames
  $ bzr init -q source
  $ cd source
  $ mkdir -p a/c
  $ echo a > a/fa
  $ echo c > a/c/fc
  $ bzr add -q a
  $ bzr commit -q -m 'Initial layout'
  $ bzr mv a b
  a => b
  $ mkdir a
  $ bzr add a
  add(ed|ing) a (re)
  $ bzr mv b/c a/c
  b/c => a/c
  $ bzr status
  added:
    a/
  renamed:
    a/? => b/? (re)
    a/c/? => a/c/? (re)
  $ bzr commit -q -m 'Divergent renames'
  $ cd ..
  $ hg convert source source-hg
  initializing destination source-hg repository
  scanning source...
  sorting...
  converting...
  1 Initial layout
  0 Divergent renames
  $ hg -R source-hg st -C --change 1
  A b/fa
    a/fa
  R a/fa
  $ hg -R source-hg manifest -r 1
  a/c/fc
  b/fa
  $ cd ..