Mercurial > evolve
annotate hgext3rd/topic/common.py @ 6880:906b5af0b2a6
topic: use FQBN for displaying topic name when it grows multiple changesets
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 17 Sep 2024 21:17:56 +0400 |
parents | f8ea46c21b56 |
children |
rev | line source |
---|---|
4531
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 # Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net> |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 # |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 # GNU General Public License version 2 or any later version. |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 def hastopicext(repo): |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 """True if the repo use the topic extension""" |
1d1f8f56daac
topic: introduce a `hastopicext(repo)` function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 return getattr(repo, 'hastopicext', False) |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
9 |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
10 def parsefqbn(string): |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
11 """parse branch//namespace/topic string into branch, namespace and topic |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
12 |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
13 >>> parsefqbn(b'branch//topic') |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
14 ('branch', 'none', 'topic') |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
15 >>> parsefqbn(b'//namespace/topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
16 ('default', 'namespace', 'topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
17 >>> parsefqbn(b'branch//') |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
18 ('branch', 'none', '') |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
19 >>> parsefqbn(b'//namespace/') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
20 ('default', 'namespace', '') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
21 >>> parsefqbn(b'/topic') |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
22 ('/topic', 'none', '') |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
23 >>> parsefqbn(b'//topic') |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
24 ('default', 'none', 'topic') |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
25 >>> parsefqbn(b'branch//namespace/topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
26 ('branch', 'namespace', 'topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
27 >>> parsefqbn(b'file:///tmp/branch//') |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
28 ('file:///tmp/branch', 'none', '') |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
29 >>> parsefqbn(b'http://example.com/branch//namespace/topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
30 ('http://example.com/branch', 'namespace', 'topic') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
31 """ |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
32 branch, sep, other = string.rpartition(b'//') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
33 if not sep: |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
34 # when there's no // anywhere in the string, rpartition returns |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
35 # untouched string as the 3rd element, and the first two are empty |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
36 branch, other = other, b'' |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
37 if not branch: |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
38 branch = b'default' |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
39 tns, sep, topic = other.partition(b'/') |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
40 if not sep: |
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
41 # when there's no / in the rest of the string, there can only be topic |
6487
963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
Anton Shestakov <av6@dwimlabs.net>
parents:
6335
diff
changeset
|
42 tns, topic = b'none', tns |
6236
7ad8107d953a
topic: introduce topic namespaces concept starting with simple parsing
Anton Shestakov <av6@dwimlabs.net>
parents:
4531
diff
changeset
|
43 return branch, tns, topic |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
44 |
6877
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
45 # Fully qualified branch name length constants for formatfqbn() etc |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
46 # |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
47 # Selecting different length only matters when at least one FQBN component is |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
48 # empty/default. The general idea is: short length will skip all empty |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
49 # components (except for branch if there's nothing else to show), normal length |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
50 # will only skip default topic namespace and empty topic, full length will not |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
51 # skip anything and will show everything. For example: |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
52 # |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
53 # - formatfqbn(topic=foo, length=FQBN_SHORT) gives: |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
54 # //foo |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
55 # |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
56 # - formatfqbn(topic=foo, length=FQBN_NORMAL) gives: |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
57 # default//foo |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
58 # |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
59 # - formatfqbn(topic=foo, length=FQBN_FULL) gives: |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
60 # default//none/foo |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
61 # |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
62 # See also: tests for debug-format-fqbn command. |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
63 FQBN_SHORT = 1 |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
64 FQBN_NORMAL = 2 |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
65 FQBN_FULL = 3 |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
66 |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
67 def formatfqbn(branch=b'', namespace=b'', topic=b'', length=FQBN_NORMAL): |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
68 """format branch, namespace and topic into branch//namespace/topic string |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
69 |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
70 >>> formatfqbn(branch=b'branch', topic=b'topic') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
71 'branch//topic' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
72 >>> formatfqbn(namespace=b'namespace', topic=b'topic') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
73 '//namespace/topic' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
74 >>> formatfqbn(branch=b'branch') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
75 'branch' |
6244
945d27da146c
topic: format fqbn correctly from only a branch if it contains //
Anton Shestakov <av6@dwimlabs.net>
parents:
6237
diff
changeset
|
76 >>> formatfqbn(branch=b'branch//') |
945d27da146c
topic: format fqbn correctly from only a branch if it contains //
Anton Shestakov <av6@dwimlabs.net>
parents:
6237
diff
changeset
|
77 'branch////' |
6335
394c795d7ba4
tests: add "double//slash" example to topic.common.formatfqbn() docstring
Anton Shestakov <av6@dwimlabs.net>
parents:
6296
diff
changeset
|
78 >>> formatfqbn(branch=b'double//slash') |
394c795d7ba4
tests: add "double//slash" example to topic.common.formatfqbn() docstring
Anton Shestakov <av6@dwimlabs.net>
parents:
6296
diff
changeset
|
79 'double//slash//' |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
80 >>> formatfqbn(namespace=b'namespace') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
81 '//namespace/' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
82 >>> formatfqbn(branch=b'/topic') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
83 '/topic' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
84 >>> formatfqbn(topic=b'topic') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
85 '//topic' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
86 >>> formatfqbn(branch=b'branch', namespace=b'namespace', topic=b'topic') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
87 'branch//namespace/topic' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
88 >>> formatfqbn(branch=b'foo/bar', namespace=b'user26', topic=b'feature') |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
89 'foo/bar//user26/feature' |
6244
945d27da146c
topic: format fqbn correctly from only a branch if it contains //
Anton Shestakov <av6@dwimlabs.net>
parents:
6237
diff
changeset
|
90 >>> formatfqbn(branch=b'http://example.com/branch', namespace=b'namespace', topic=b'topic') |
945d27da146c
topic: format fqbn correctly from only a branch if it contains //
Anton Shestakov <av6@dwimlabs.net>
parents:
6237
diff
changeset
|
91 'http://example.com/branch//namespace/topic' |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
92 """ |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
93 result = b'' |
6877
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
94 showbranch = branch and not (length == FQBN_SHORT and branch == b'default') |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
95 shownamespace = namespace and not (length != FQBN_FULL and namespace == b'none') |
f8ea46c21b56
topic: make formatfqbn() able to produce FQBN of 3 different lengths
Anton Shestakov <av6@dwimlabs.net>
parents:
6487
diff
changeset
|
96 if not shownamespace and not topic: |
6266
213db29a19e9
topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents:
6244
diff
changeset
|
97 # if there's nothing to show, show at least branch |
213db29a19e9
topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents:
6244
diff
changeset
|
98 showbranch = True |
213db29a19e9
topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents:
6244
diff
changeset
|
99 if showbranch: |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
100 result += branch |
6266
213db29a19e9
topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents:
6244
diff
changeset
|
101 if shownamespace or topic or b'//' in branch: |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
102 result += b'//' |
6266
213db29a19e9
topic: ability to shorten branch//namespace/topic strings when possible
Anton Shestakov <av6@dwimlabs.net>
parents:
6244
diff
changeset
|
103 if shownamespace: |
6237
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
104 result += namespace + b'/' |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
105 result += topic |
0b9042408809
topic: formatting branch, namespace and topic into fully qualified branch name
Anton Shestakov <av6@dwimlabs.net>
parents:
6236
diff
changeset
|
106 return result |
6296
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
107 |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
108 def upgradeformat(branch): |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
109 """take branch and topic in ":" format and return fqbn in "//" format |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
110 |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
111 This function can be used for transforming branchmap contents of peers that |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
112 don't support topic namespaces yet to work with peers with topic namespaces |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
113 support. |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
114 |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
115 >>> upgradeformat(b'branch') |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
116 'branch' |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
117 >>> upgradeformat(b'branch:topic') |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
118 'branch//topic' |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
119 >>> upgradeformat(b'branch//') |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
120 'branch////' |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
121 >>> upgradeformat(b'branch//:topic') |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
122 'branch////topic' |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
123 """ |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
124 if b':' not in branch: |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
125 # formatting anyway, because named branch could contain "//" |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
126 return formatfqbn(branch=branch) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
127 # topic namespace cannot be extracted from ":" format |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
128 branch, topic = branch.split(b':', 1) |
a2855aff1268
topic: call a different wire protocol command to get tns-aware branchmap
Anton Shestakov <av6@dwimlabs.net>
parents:
6267
diff
changeset
|
129 return formatfqbn(branch=branch, topic=topic) |