[PATCH 8 of 8 RFC] tests: add a new test for merging with memctx
Sean Farley
sean.michael.farley at gmail.com
Thu Aug 7 19:52:15 UTC 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1406609617 18000
# Mon Jul 28 23:53:37 2014 -0500
# Node ID 4be20ab8a08265e2359f67d4023debdc6572931c
# Parent fd349f8559b631416eecd1c7f3a320fe075a3d76
tests: add a new test for merging with memctx
diff --git a/tests/test-merge-memctx.t b/tests/test-merge-memctx.t
new file mode 100644
--- /dev/null
+++ b/tests/test-merge-memctx.t
@@ -0,0 +1,83 @@
+
+Create a python script to test merging with memctx
+
+ $ cat > memmerge.py << EOF
+ > #!/usr/bin/env python
+ > from mercurial import context, hg, merge, ui as uimod
+ > from mercurial.node import nullid
+ >
+ > ui = uimod.ui()
+ > myrepo = hg.repository(ui, '.')
+ >
+ > ctxa = myrepo.changectx(2)
+ > ctxb = myrepo.changectx(3)
+ > orig = myrepo['.']
+ >
+ > # build a memctx off of ctxa (but set parents to ctxa and ctxb)
+ > rctx = context.memctx(myrepo, [ctxa.node(), ctxb.node()], 'test merge',
+ > ctxa.files(), ctxa, user=ctxa.user(), date=ctxa.date(),
+ > extra=ctxa.extra())
+ >
+ > stats = merge.update(myrepo, ctxa.node(), True, True, False, ctxa.p1().node(), rctx=rctx)
+ >
+ > del rctx._status
+ > del rctx._manifest
+ >
+ > wlock = myrepo.wlock()
+ > try:
+ > node = myrepo.commitctx(rctx)
+ > myrepo.setparents(orig.node(), nullid)
+ > myrepo.dirstate.write()
+ > finally:
+ > wlock.release()
+ > EOF
+
+The test requires a repo with two heads
+
+ $ hg init main
+ $ cd main
+ $ echo line1 > a
+ $ hg commit -Am0
+ adding a
+ $ echo lineA > b
+ $ hg commit -Am1
+ adding b
+ $ echo line2 >> a
+ $ hg commit -Am2
+ $ hg update 1
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ echo lineB >> b
+ $ hg commit -Am3
+ created new head
+
+
+Merge with a dirty working directory
+
+ $ echo dirty >> b
+ $ python $TESTTMP/memmerge.py
+ $ hg log -pr tip
+ changeset: 4:d17d631aeace
+ tag: tip
+ parent: 2:fc28dc423489
+ parent: 3:c9ea6e4408ad
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: test merge
+
+ diff -r fc28dc423489 -r d17d631aeace b
+ --- a/b Thu Jan 01 00:00:00 1970 +0000
+ +++ b/b Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,2 @@
+ lineA
+ +lineB
+
+Make sure the directory is still dirty
+
+ $ hg diff --git --nodates
+ diff --git a/b b/b
+ --- a/b
+ +++ b/b
+ @@ -1,2 +1,3 @@
+ lineA
+ lineB
+ +dirty
More information about the Mercurial-devel
mailing list