Fossil SCM

fossil-scm / test / branch-tag.test
Blame History Raw 145 lines
1
#
2
# Copyright (c) 2026 D. Richard Hipp
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the Simplified BSD License (also
6
# known as the "2-Clause License" or "FreeBSD License".)
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but without any warranty; without even the implied warranty of
10
# merchantability or fitness for a particular purpose.
11
#
12
# Author contact information:
13
# [email protected]
14
# http://www.hwaci.com/drh/
15
#
16
############################################################################
17
#
18
# Creating, closing and reopening a branch, and adding and cancelling a
19
# tag, a tag with a value and a propagating tag.
20
#
21
22
set path [file dirname [info script]]
23
24
require_no_open_checkout
25
26
# Returns the hash of the current check-out.
27
#
28
proc branchtag_current {} {
29
fossil timeline before current -n 1 -t ci -F %H
30
return [first_data_line]
31
}
32
33
# Returns the output lines of the last command, without leading and
34
# trailing white space, as a sorted list.
35
#
36
proc branchtag_lines {} {
37
set lines [list]
38
foreach line [split [normalize_result] \n] {
39
lappend lines [string trim $line]
40
}
41
return [lsort $lines]
42
}
43
44
test_setup
45
46
commit_file a.txt "a\n" "bt-c1"
47
set c1 [checkin_hash bt-c1]
48
write_file a.txt "a2\n"
49
fossil commit -m "bt-c2"
50
set c2 [checkin_hash bt-c2]
51
52
###############################################################################
53
#
54
# A new branch is listed as open, and a check-in on it stays on it.
55
#
56
fossil branch new bt-branch $c2
57
fossil branch list
58
test_eq branch-tag-new-listed [branchtag_lines] \
59
[lsort [list bt-branch {* trunk}]]
60
61
fossil update bt-branch
62
fossil branch current
63
test_eq branch-tag-new-current [normalize_result] bt-branch
64
write_file a.txt "on branch\n"
65
fossil commit -m "bt-b1"
66
fossil branch current
67
test_eq branch-tag-new-commit [normalize_result] bt-branch
68
69
###############################################################################
70
#
71
# A closed branch is listed only with --closed, and a check-in on it is
72
# refused. Reopened, it is listed as open and accepts check-ins.
73
#
74
fossil branch close bt-branch
75
fossil branch list
76
test_eq branch-tag-close-open-list [branchtag_lines] [list trunk]
77
fossil branch list --closed
78
test_eq branch-tag-close-closed-list [branchtag_lines] [list {* bt-branch}]
79
80
write_file a.txt "on closed branch\n"
81
fossil commit -m "bt-on-closed" -expectError
82
test_eq branch-tag-close-commit [normalize_result] \
83
"cannot commit against a closed leaf"
84
85
fossil branch reopen bt-branch
86
fossil branch list
87
test_eq branch-tag-reopen-list [branchtag_lines] [list {* bt-branch} trunk]
88
fossil commit -m "bt-b2"
89
fossil branch current
90
test_eq branch-tag-reopen-commit [normalize_result] bt-branch
91
92
###############################################################################
93
#
94
# A tag on a check-in is listed for that check-in only, and "fossil
95
# update TAG" moves the check-out to it. Cancelled, the tag is not
96
# listed and "fossil update TAG" fails.
97
#
98
fossil update trunk
99
fossil tag add bt-rel $c1
100
fossil tag list $c1
101
test_eq branch-tag-add-list [branchtag_lines] [list branch=trunk bt-rel trunk]
102
fossil tag list $c2
103
test_eq branch-tag-add-other [branchtag_lines] [list branch=trunk trunk]
104
105
fossil update bt-rel
106
test_eq branch-tag-add-update [branchtag_current] $c1
107
108
fossil update trunk
109
fossil tag cancel bt-rel $c1
110
fossil tag list $c1
111
test_eq branch-tag-cancel-list [branchtag_lines] [list branch=trunk trunk]
112
fossil update bt-rel -expectError
113
test_eq branch-tag-cancel-update [branchtag_current] $c2
114
115
###############################################################################
116
#
117
# A tag with a value is listed as NAME=VALUE.
118
#
119
fossil tag add bt-value $c1 hello
120
fossil tag list $c1
121
test_eq branch-tag-value-list [branchtag_lines] \
122
[list branch=trunk bt-value=hello trunk]
123
124
###############################################################################
125
#
126
# A propagating tag is listed for the check-in and its descendants on
127
# the branch. Cancelled on the check-in, it is not listed for either.
128
#
129
fossil tag add --propagate bt-prop $c1
130
fossil tag list $c2
131
test_eq branch-tag-propagate-descendant [branchtag_lines] \
132
[list branch=trunk bt-prop trunk]
133
134
fossil tag cancel bt-prop $c1
135
fossil tag list $c1
136
test_eq branch-tag-propagate-cancel [branchtag_lines] \
137
[list branch=trunk bt-value=hello trunk]
138
fossil tag list $c2
139
test_eq branch-tag-propagate-cancel-descendant [branchtag_lines] \
140
[list branch=trunk trunk]
141
142
###############################################################################
143
144
test_cleanup
145

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button