annotate tests/test-namespaces.t @ 6266:213db29a19e9

topic: ability to shorten branch//namespace/topic strings when possible
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 31 May 2022 12:14:51 +0400
parents a2491c578d2b
children 1eb543272657
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6236
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
1 https://www.mercurial-scm.org/wiki/TopicPlan#sub_branches.2C_namespacing_and_representation
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
2
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
3 $ . "$TESTDIR/testlib/topic_setup.sh"
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
4
6238
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
5 $ hg init repo
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
6 $ cd repo
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
7
6239
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
8 $ hg debug-topic-namespace space-name
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
9 marked working directory as topic namespace: space-name
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
10 $ hg debug-topic-namespaces
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
11 space-name
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
12
6241
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
13 $ hg log -r 'wdir()' -T '{topic_namespace}\n'
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
14 space-name
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
15
6243
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
16 $ hg log -r 'wdir()' -T '{fqbn}\n'
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
17 default//space-name/
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
18
6239
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
19 $ hg branches
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
20
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
21 $ hg debug-topic-namespace --clear
6238
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
22 $ hg debug-topic-namespaces
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
23 default
6bbd16579f0f topic: list namespaces with debug-namespaces
Anton Shestakov <av6@dwimlabs.net>
parents: 6237
diff changeset
24
6239
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
25 $ hg debugtopicnamespace --clear nonsense
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
26 abort: cannot use --clear when setting a topic namespace
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
27 [255]
8861e33f3bb2 topic: setting current repo namespace with debug-namespace
Anton Shestakov <av6@dwimlabs.net>
parents: 6238
diff changeset
28
6240
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
29 $ hg branch stable
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
30 marked working directory as branch stable
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
31 (branches are permanent and global, did you want a bookmark?)
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
32 $ hg debug-topic-namespace alice
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
33 marked working directory as topic namespace: alice
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
34 $ hg topic feature
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
35 marked working directory as topic: feature
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
36 $ echo a > a
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
37 $ hg ci -qAm a
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
38
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
39 $ hg debug-topic-namespaces
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
40 alice
2686ecc90791 topic: store topic namespace in commit extras
Anton Shestakov <av6@dwimlabs.net>
parents: 6239
diff changeset
41
6241
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
42 $ hg log -r . -T '{rev}: {branch} {topic_namespace} {topic}\n'
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
43 0: stable alice feature
85abf58c3d8c topic: namespace template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6240
diff changeset
44
6243
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
45 $ hg log -r . -T '{rev}: {fqbn}\n'
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
46 0: stable//alice/feature
91d9a279b84a topic: fqbn template keyword
Anton Shestakov <av6@dwimlabs.net>
parents: 6241
diff changeset
47
6245
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
48 Updating to a revision with a namespace should activate it
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
49
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
50 $ hg up null
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
51 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
52 $ hg debug-topic-namespace
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
53 default
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
54 $ hg topics
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
55 feature (1 changesets)
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
56 $ hg up 0
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
57 switching to topic-namespace alice
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
58 switching to topic feature
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
60 $ hg debug-topic-namespace
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
61 alice
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
62 $ hg topics
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
63 * feature (1 changesets)
a54db3e55c88 topic: switch to namespace when updating to a commit, similar to topic
Anton Shestakov <av6@dwimlabs.net>
parents: 6243
diff changeset
64
6261
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
65 Revsets
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
66
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
67 $ nslog() {
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
68 > hg log -T '{rev}: {topic_namespace}\n' -r "$1"
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
69 > }
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
70
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
71 $ nslog 'topicnamespace(:)'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
72 0: alice
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
73 $ nslog 'topicnamespace(all())'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
74 0: alice
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
75 $ nslog 'topicnamespace(topicnamespace("alice"))'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
76 0: alice
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
77 $ nslog 'topicnamespace(wdir())'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
78 0: alice
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
79 $ nslog 'topicnamespace("re:ice$")'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
80 0: alice
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
81 $ nslog 'topicnamespace(nonsense)'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
82 abort: unknown revision 'nonsense'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
83 [10]
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
84
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
85 $ nslog 'topicnamespace("re:nonsense")'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
86 $ nslog 'topicnamespace("literal:nonsense")'
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
87 abort: topic namespace 'nonsense' does not exist
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
88 [10]
a2491c578d2b topic: namespace revset predicate
Anton Shestakov <av6@dwimlabs.net>
parents: 6245
diff changeset
89
6236
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
90 Parsing
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
91
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
92 $ hg debugparsefqbn foo/bar//user26/feature -T '[{branch}] <{topic_namespace}> ({topic})\n'
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
93 [foo/bar] <user26> (feature)
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
94
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
95 no double slashes means it's a named branch
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
96 $ hg debug-parse-fqbn foo/bar
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
97 branch: foo/bar
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
98 namespace: default
7ad8107d953a topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
99 topic:
6237
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
100
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
101 Formatting
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
102
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
103 $ hg debugformatfqbn -b branch -n namespace -t topic
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
104 branch//namespace/topic
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
105
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
106 $ hg debug-format-fqbn -n namespace
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
107 //namespace/
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
108
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
109 $ hg debug-format-fqbn -b foo/bar -n user26 -t feature
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
110 foo/bar//user26/feature
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
111
6266
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
112 default values
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
113
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
114 $ hg debug-format-fqbn -b default -n default -t ''
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
115 default//default/
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
116 $ hg debug-format-fqbn -b default -n default -t '' --short
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
117 default
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
118
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
119 $ hg debug-format-fqbn -b default -n namespace -t ''
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
120 default//namespace/
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
121 $ hg debug-format-fqbn -b default -n namespace -t '' --short
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
122 default//namespace/
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
123
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
124 $ hg debug-format-fqbn -b default -n default -t topic
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
125 default//default/topic
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
126 $ hg debug-format-fqbn -b default -n default -t topic --short
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
127 default//topic
213db29a19e9 topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents: 6261
diff changeset
128
6237
0b9042408809 topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents: 6236
diff changeset
129 $ cd ..