Patchwork D1652: tests: add a simple test for in-memory rebase

login
register
mail settings
Submitter phabricator
Date Dec. 11, 2017, 6:21 a.m.
Message ID <differential-rev-PHID-DREV-tmr3mykgju7gl7mtiwwm-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26209/
State Superseded
Headers show

Comments

phabricator - Dec. 11, 2017, 6:21 a.m.
phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is just a very simple start, but verifies some of the basic cases of an
  in-memory rebase.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1652

AFFECTED FILES
  tests/test-imm.t
  tests/test-rebase-inmemory.t

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-imm.t b/tests/test-rebase-inmemory.t
rename from tests/test-imm.t
rename to tests/test-rebase-inmemory.t
--- a/tests/test-imm.t
+++ b/tests/test-rebase-inmemory.t
@@ -1,13 +1,15 @@ 
-Setup
   $ cat << EOF >> $HGRCPATH
   > [extensions]
+  > amend=
   > rebase=
   > debugdrawdag=$TESTDIR/drawdag.py
   > [diff]
   > git=1
+  > [alias]
+  > tglog = log -G --template "{rev}: {node|short} '{desc}'\n"
   > EOF
 
-It works well for disparate parents.
+Rebase a simple DAG:
   $ hg init repo1
   $ cd repo1
   $ hg debugdrawdag <<'EOS'
@@ -19,89 +21,37 @@ 
   > EOS
   $ hg up -C a
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  o  814f6bd05178: 3 (c)
+  $ hg tglog
+  o  3: 814f6bd05178 'c'
   |
-  | o  db0e82a16a62: 2 (b)
+  | o  2: db0e82a16a62 'b'
   |/
-  o  02952614a83d: 1 (d)
+  o  1: 02952614a83d 'd'
   |
-  @  b173517d0057: 0 (a)
+  @  0: b173517d0057 'a'
   
-
-  $ hg export 3
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 814f6bd051784616494e0d357c1cf342c4412d9b
-  # Parent  02952614a83d315dda1e5f11662dca1c0cdb4de8
-  c
-  
-  diff --git a/c b/c
-  new file mode 100644
-  --- /dev/null
-  +++ b/c
-  @@ -0,0 +1,1 @@
-  +c
-  \ No newline at end of file
-
   $ hg cat -r 3 c
   c (no-eol)
   $ hg cat -r 2 b
   b (no-eol)
-
   $ hg rebase --inmemory --debug -r b -d c | grep rebasing
   rebasing in-memory
   rebasing 2:db0e82a16a62 "b" (b)
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  o  ca58782ad1e4: 3 (b)
+  $ hg tglog
+  o  3: ca58782ad1e4 'b'
   |
-  o  814f6bd05178: 2 (c)
+  o  2: 814f6bd05178 'c'
   |
-  o  02952614a83d: 1 (d)
+  o  1: 02952614a83d 'd'
   |
-  @  b173517d0057: 0 (a)
+  @  0: b173517d0057 'a'
   
   $ hg cat -r 3 b
   b (no-eol)
-  $ hg cat -r 1 c
-  c: no such file in rev 02952614a83d
-  [1]
-  $ hg log -r 3 -T json
-  [
-   {
-    "rev": 3,
-    "node": "ca58782ad1e4f59977cdedfd7bca25fe048aaed8",
-    "branch": "default",
-    "phase": "draft",
-    "user": "test",
-    "date": [0, 0],
-    "desc": "b",
-    "bookmarks": [],
-    "tags": ["tip"],
-    "parents": ["814f6bd051784616494e0d357c1cf342c4412d9b"]
-   }
-  ]
-  $ hg export 3
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID ca58782ad1e4f59977cdedfd7bca25fe048aaed8
-  # Parent  814f6bd051784616494e0d357c1cf342c4412d9b
-  b
-  
-  diff --git a/b b/b
-  new file mode 100644
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +b
-  \ No newline at end of file
+  $ hg cat -r 2 c
+  c (no-eol)
 
-
-Not so well for:
+Case 2:
   $ hg init repo2
   $ cd repo2
   $ hg debugdrawdag <<'EOS'
@@ -111,138 +61,96 @@ 
   > |
   > a
   > EOS
-  $ hg up -C a
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  o  814f6bd05178: 3 (c)
+
+Add a symlink and executable file:
+  $ hg up -C c
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ ln -s somefile e
+  $ echo f > f
+  $ chmod +x f
+  $ hg add e f
+  $ hg amend -q
+  $ hg up -Cq a
+
+Write files to the working copy, and ensure they're still there after the rebase
+  $ echo "abc" > a
+  $ ln -s def b
+  $ echo "ghi" > c
+  $ echo "jkl" > d
+  $ echo "mno" > e
+  $ hg tglog
+  o  3: f56b71190a8f 'c'
   |
-  | o  db0e82a16a62: 2 (b)
+  | o  2: db0e82a16a62 'b'
   |/
-  o  02952614a83d: 1 (d)
+  o  1: 02952614a83d 'd'
   |
-  @  b173517d0057: 0 (a)
+  @  0: b173517d0057 'a'
   
-
-
   $ hg cat -r 3 c
   c (no-eol)
   $ hg cat -r 2 b
   b (no-eol)
-  $ hg rebase --inmemory --debug -r b -d a | grep rebasing
+  $ hg cat -r 3 e
+  somefile (no-eol)
+  $ hg rebase --inmemory --debug -s b -d a | grep rebasing
   rebasing in-memory
   rebasing 2:db0e82a16a62 "b" (b)
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  o  fc055c3b4d33: 3 (b)
+  $ hg tglog
+  o  3: fc055c3b4d33 'b'
   |
-  | o  814f6bd05178: 2 (c)
+  | o  2: f56b71190a8f 'c'
   | |
-  | o  02952614a83d: 1 (d)
+  | o  1: 02952614a83d 'd'
   |/
-  @  b173517d0057: 0 (a)
+  @  0: b173517d0057 'a'
   
-
-
-  $ echo "aaa" > a
-  $ echo "aaa" > b
-  $ echo "aaa" > c
-  $ echo "aaa" > d
-  $ echo "aaa" > e
+  $ hg cat -r 2 c
+  c (no-eol)
+  $ hg cat -r 3 b
+  b (no-eol)
   $ hg rebase --inmemory --debug -s 1 -d 3 | grep rebasing
   rebasing in-memory
   rebasing 1:02952614a83d "d" (d)
-  rebasing 2:814f6bd05178 "c" (c)
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  o  231d1cda1460: 3 (c)
+  rebasing 2:f56b71190a8f "c"
+  $ hg tglog
+  o  3: 753feb6fd12a 'c'
+  |
+  o  2: 09c044d2cb43 'd'
+  |
+  o  1: fc055c3b4d33 'b'
   |
-  o  09c044d2cb43: 2 (d)
+  @  0: b173517d0057 'a'
+  
+Ensure working copy files are still there:
+  $ cat a
+  abc
+  $ readlink b
+  def
+  $ cat e
+  mno
+
+Ensure symlink and executable files were rebased properly:
+  $ hg up -Cq 3
+  $ readlink e
+  somefile
+  $ ls -l f | cut -f1 -d ' '
+  -rwxr-xr-x
+
+Rebase the working copy parent, which should default to an on-disk merge even if
+we requested in-memory.
+  $ hg up -C 3
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg rebase -r 3 -d 0 --inmemory --debug | grep rebasing
+  rebasing on disk
+  rebasing 3:753feb6fd12a "c" (tip)
+  $ hg tglog
+  @  3: 844a7de3e617 'c'
   |
-  o  fc055c3b4d33: 1 (b)
-  |
-  @  b173517d0057: 0 (a)
+  | o  2: 09c044d2cb43 'd'
+  | |
+  | o  1: fc055c3b4d33 'b'
+  |/
+  o  0: b173517d0057 'a'
   
 
-  $ cat a
-  aaa
-  $ cat e
-  aaa
-  $ hg export -r 0::
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID b173517d005764ebeb1685517a79fe8842b4e194
-  # Parent  0000000000000000000000000000000000000000
-  a
-  
-  diff --git a/a b/a
-  new file mode 100644
-  --- /dev/null
-  +++ b/a
-  @@ -0,0 +1,1 @@
-  +a
-  \ No newline at end of file
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID fc055c3b4d33c6796302568c90cb986fb3fe3ba0
-  # Parent  b173517d005764ebeb1685517a79fe8842b4e194
-  b
-  
-  diff --git a/b b/b
-  new file mode 100644
-  --- /dev/null
-  +++ b/b
-  @@ -0,0 +1,1 @@
-  +b
-  \ No newline at end of file
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 09c044d2cb4341921ce69b4b17a8c38c3ed5e85a
-  # Parent  fc055c3b4d33c6796302568c90cb986fb3fe3ba0
-  d
-  
-  diff --git a/d b/d
-  new file mode 100644
-  --- /dev/null
-  +++ b/d
-  @@ -0,0 +1,1 @@
-  +d
-  \ No newline at end of file
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 231d1cda1460bc732cb22d61ad3485d1f39a9e5c
-  # Parent  09c044d2cb4341921ce69b4b17a8c38c3ed5e85a
-  c
-  
-  diff --git a/c b/c
-  new file mode 100644
-  --- /dev/null
-  +++ b/c
-  @@ -0,0 +1,1 @@
-  +c
-  \ No newline at end of file
-
-
-
-
-Rebase the WCP:
-  $ hg up -C 3
-  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg rebase -r 3 -d 0 --inmemory --debug | grep rebasing
-  rebasing on disk
-  rebasing 3:231d1cda1460 "c" (tip)
-  $ hg log -G -T '{node|short}: {rev} ({desc})'
-  @  72df2b4d62bc: 3 (c)
-  |
-  | o  09c044d2cb43: 2 (d)
-  | |
-  | o  fc055c3b4d33: 1 (b)
-  |/
-  o  b173517d0057: 0 (a)
-  
-