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 (100 lines) | stat: -rw-r--r-- 3,621 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
-- Test/demonstrate handling of a duplicate name conflict; Abe and
-- Beth add files with the same names.
--
-- For checkout.sh, the user intent is that there be
-- one file with that name; the contents should be merged.
--
-- For thermostat.c, there should be two files;
-- thermostat-westinghouse.c and thermostat-honeywell.c

mtn_setup()

--  Get a non-empty base revision
addfile("randomfile", "blah blah blah")
commit()
base = base_revision()

-- Abe adds conflict files
addfile("checkout.sh", "checkout.sh abe 1")
addfile("thermostat.c", "thermostat westinghouse")
commit("testbranch", "abe_1")
abe_1 = base_revision()

revert_to(base)

-- Beth adds files, and attempts to merge
addfile("checkout.sh", "checkout.sh beth 1")
addfile("thermostat.c", "thermostat honeywell")
commit("testbranch", "beth_1")
beth_1 = base_revision()

-- This fails due to duplicate name conflicts
check(mtn("merge"), 1, nil, false)

-- Beth fixes the conflicts.
--
-- For checkout.sh, she retrieves Abe's version to merge with hers,
-- using 'automate get_file'. This requires knowing the file id
-- of Abe's commit, which we get from 'automate show_conflicts'.
--
-- mtn is not up to actually doing the merge of checkout.sh yet (that
-- requires sutures), so we specify a conflict resolution that drops
-- Abe's version and keeps Beth's manual merge.
--
-- For thermostat.c, she specifies a conflict resolution that renames
-- both versions.

check(mtn("conflicts", "store"), 0, nil, true)
check(samelines("stderr", {"mtn: 2 conflicts with supported resolutions.",
                           "mtn: stored in '_MTN/conflicts'"}))
check(samefilestd("conflicts-1", "_MTN/conflicts"))

-- Find out what the first unresolved conflict is
check(mtn("conflicts", "show_first"), 0, nil, true)

-- invalid resolution identifier
check(mtn("conflicts", "resolve_first_left", "foo"), 1, nil, true)
check(qgrep("'foo' is not a supported conflict resolution for duplicate_name", "stderr"))

-- Retrieve Abe's version of checkout.sh, and pretend we did a manual
-- merge, using our favorite merge tool. We put the files in the
-- bookkeeping area, so mtn doesn't see them.
mkdir("_MTN/resolutions")
check(mtn("automate", "get_file", "61b8d4fb0e5d78be111f691b955d523c782fa92e"), 0, true, nil)
rename("stdout", "_MTN/resolutions/checkout.sh-abe")
check(readfile("_MTN/resolutions/checkout.sh-abe") == "checkout.sh abe 1")

writefile("_MTN/resolutions/checkout.sh", "checkout.sh beth 2")

-- specify a part of the resolution for the first unresolved conflict in the file.
check(mtn("conflicts", "resolve_first_left", "drop"), 0, nil, nil)

-- and now the other part
check(mtn("conflicts", "show_first"), 0, nil, true)
check(mtn("conflicts", "resolve_first_right", "user", "_MTN/resolutions/checkout.sh"), 0, nil, nil)

-- Find out what the next unresolved conflict is
check(mtn("conflicts", "show_first"), 0, nil, true)

check(mtn("conflicts", "resolve_first_left", "rename", "thermostat-westinghouse.c"), 0, nil, nil)
check(mtn("conflicts", "resolve_first_right", "rename", "thermostat-honeywell.c"), 0, nil, nil)

check(samefilestd("conflicts-resolved", "_MTN/conflicts"))

-- This succeeds
logmsg = "rename thermostat, merge/drop checkout"
check(mtn("merge", "--resolve-conflicts", "--message", logmsg), 0, nil, true)
canonicalize("stderr")
check(samefilestd("merge-1", "stderr"))

check(mtn("conflicts", "clean"), 0, nil, true)

check(mtn("update"), 0, nil, false)
merged = base_revision()

check(mtn("automate", "certs", merged), 0, true, nil)
check(qgrep(logmsg, "stdout"), 0)

check("checkout.sh beth 2" == readfile("checkout.sh"))

-- end of file