4
4
from .version import meta , tags_to_versions
5
5
6
6
7
- def _hg_tagdist_normalize_tagcommit (root , tag , dist , node , branch ):
7
+ def _hg_tagdist_normalize_tagcommit (config , tag , dist , node , branch ):
8
8
dirty = node .endswith ("+" )
9
9
node = "h" + node .strip ("+" )
10
10
@@ -19,14 +19,19 @@ def _hg_tagdist_normalize_tagcommit(root, tag, dist, node, branch):
19
19
tag = tag
20
20
)
21
21
if tag != "0.0" :
22
- commits = do (["hg" , "log" , "-r" , revset , "--template" , "{node|short}" ], root )
22
+ commits = do (
23
+ ["hg" , "log" , "-r" , revset , "--template" , "{node|short}" ],
24
+ config .absolute_root ,
25
+ )
23
26
else :
24
27
commits = True
25
28
trace ("normalize" , locals ())
26
29
if commits or dirty :
27
- return meta (tag , distance = dist , node = node , dirty = dirty , branch = branch )
30
+ return meta (
31
+ tag , distance = dist , node = node , dirty = dirty , branch = branch , config = config
32
+ )
28
33
else :
29
- return meta (tag )
34
+ return meta (tag , config = config )
30
35
31
36
32
37
def parse (root , config = None ):
@@ -40,12 +45,13 @@ def parse(root, config=None):
40
45
return
41
46
node = identity_data .pop (0 )
42
47
branch = identity_data .pop (0 )
48
+ if "tip" in identity_data :
49
+ # tip is not a real tag
50
+ identity_data .remove ("tip" )
43
51
tags = tags_to_versions (identity_data )
44
- # filter tip in degraded mode on old setuptools
45
- tags = [x for x in tags if x != "tip" ]
46
52
dirty = node [- 1 ] == "+"
47
53
if tags :
48
- return meta (tags [0 ], dirty = dirty , branch = branch )
54
+ return meta (tags [0 ], dirty = dirty , branch = branch , config = config )
49
55
50
56
if node .strip ("+" ) == "0" * 12 :
51
57
trace ("initial node" , config .absolute_root )
@@ -57,9 +63,7 @@ def parse(root, config=None):
57
63
if tag == "null" :
58
64
tag = "0.0"
59
65
dist = int (dist ) + 1
60
- return _hg_tagdist_normalize_tagcommit (
61
- config .absolute_root , tag , dist , node , branch
62
- )
66
+ return _hg_tagdist_normalize_tagcommit (config , tag , dist , node , branch )
63
67
except ValueError :
64
68
pass # unpacking failed, old hg
65
69
@@ -80,20 +84,25 @@ def get_graph_distance(root, rev1, rev2="."):
80
84
return len (out .strip ().splitlines ()) - 1
81
85
82
86
83
- def archival_to_version (data ):
87
+ def archival_to_version (data , config = None ):
84
88
trace ("data" , data )
85
89
node = data .get ("node" , "" )[:12 ]
86
90
if node :
87
91
node = "h" + node
88
92
if "tag" in data :
89
- return meta (data ["tag" ])
93
+ return meta (data ["tag" ], config = config )
90
94
elif "latesttag" in data :
91
- return meta (data ["latesttag" ], distance = data ["latesttagdistance" ], node = node )
95
+ return meta (
96
+ data ["latesttag" ],
97
+ distance = data ["latesttagdistance" ],
98
+ node = node ,
99
+ config = config ,
100
+ )
92
101
else :
93
- return meta ("0.0" , node = node )
102
+ return meta ("0.0" , node = node , config = config )
94
103
95
104
96
- def parse_archival (root ):
105
+ def parse_archival (root , config = None ):
97
106
archival = os .path .join (root , ".hg_archival.txt" )
98
107
data = data_from_mime (archival )
99
- return archival_to_version (data )
108
+ return archival_to_version (data , config = config )
0 commit comments