File: __driver__.lua

package info (click to toggle)
monotone 1.1-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,984 kB
  • ctags: 8,622
  • sloc: cpp: 86,450; sh: 6,906; perl: 924; makefile: 813; python: 517; lisp: 379; sql: 118; exp: 91; ansic: 52
file content (75 lines) | stat: -rw-r--r-- 2,318 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- Demonstrate that all non-workspace merge commands support --resolve-conflicts.
--
-- The merge commands are defined in cmd_merging.cc; search for CMD.
-- They are: merge, propagate, explicit_merge, merge_into_dir.
--
-- propagate is implemented by calling merge_into_dir,
-- so we don't need to test the latter explicitly.

-- We don't explicitly test --resolve-conflicts-file, because that is
-- handled by the same code, and other tests show it works.
--
-- See other resolve_conflicts_* tests for individual conflict
-- resolutions.

-- The test structure is borrowed from ../conflict_messages/__driver__.lua

mtn_setup()

function setup(branch)
    remove("_MTN")
    remove("foo")
    remove("bar")
    remove("baz")
    remove(branch)
    check(mtn("setup", ".", "--branch", branch), 0, false, false)
end

function merged_revision()
  local workrev = readfile("stderr")
  local extract = string.gsub(workrev, "^.*mtn: %[merged%] (%x*).*$", "%1")
  if extract == workrev then
    err("failed to extract merged revision from stderr")
  end
  return extract
end

branch = "content-attached"
setup(branch)

addfile("foo", branch .. "-foo")
commit(branch)
base = base_revision()

writefile("foo", branch .. "-foo first revision")
commit(branch)
first = base_revision()

revert_to(base)

writefile("foo", branch .. "-foo second revision")

commit(branch .. "-propagate")
second = base_revision()

check(mtn("conflicts", "store", "h:" .. branch , "h:" .. branch .. "-propagate"), 0, nil, true)
check(mtn("conflicts", "resolve_first", "user", "foo"), 0, nil, nil)

check(mtn("propagate", branch , branch .. "-propagate", "--resolve-conflicts"), 0, nil, true)
merged = merged_revision()
check(mtn("local", "kill_revision", merged), 0, nil, true)

check(mtn("explicit_merge", first, second, branch,"--resolve-conflicts"), 0, nil, true)
merged = merged_revision()
check(mtn("local", "kill_revision", merged), 0, nil, true)

-- create a second head on 'branch'
writefile("foo", branch .. "-foo third revision")
commit(branch)
check(mtn("conflicts", "store"), 0, nil, true)
check(mtn("conflicts", "resolve_first", "user", "foo"), 0, nil, nil)
check(mtn("merge", "--branch", branch, "--resolve-conflicts"), 0, nil, true)
merged = merged_revision()
check(mtn("local", "kill_revision", merged), 0, nil, true)

-- end of file