44from .version import meta , tags_to_versions
55
66
7- def _hg_tagdist_normalize_tagcommit (root , tag , dist , node , branch ):
7+ def _hg_tagdist_normalize_tagcommit (config , tag , dist , node , branch ):
88 dirty = node .endswith ("+" )
99 node = "h" + node .strip ("+" )
1010
@@ -19,14 +19,19 @@ def _hg_tagdist_normalize_tagcommit(root, tag, dist, node, branch):
1919 tag = tag
2020 )
2121 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+ )
2326 else :
2427 commits = True
2528 trace ("normalize" , locals ())
2629 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+ )
2833 else :
29- return meta (tag )
34+ return meta (tag , config = config )
3035
3136
3237def parse (root , config = None ):
@@ -40,12 +45,13 @@ def parse(root, config=None):
4045 return
4146 node = identity_data .pop (0 )
4247 branch = identity_data .pop (0 )
48+ if "tip" in identity_data :
49+ # tip is not a real tag
50+ identity_data .remove ("tip" )
4351 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" ]
4652 dirty = node [- 1 ] == "+"
4753 if tags :
48- return meta (tags [0 ], dirty = dirty , branch = branch )
54+ return meta (tags [0 ], dirty = dirty , branch = branch , config = config )
4955
5056 if node .strip ("+" ) == "0" * 12 :
5157 trace ("initial node" , config .absolute_root )
@@ -57,9 +63,7 @@ def parse(root, config=None):
5763 if tag == "null" :
5864 tag = "0.0"
5965 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 )
6367 except ValueError :
6468 pass # unpacking failed, old hg
6569
@@ -80,20 +84,25 @@ def get_graph_distance(root, rev1, rev2="."):
8084 return len (out .strip ().splitlines ()) - 1
8185
8286
83- def archival_to_version (data ):
87+ def archival_to_version (data , config = None ):
8488 trace ("data" , data )
8589 node = data .get ("node" , "" )[:12 ]
8690 if node :
8791 node = "h" + node
8892 if "tag" in data :
89- return meta (data ["tag" ])
93+ return meta (data ["tag" ], config = config )
9094 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+ )
92101 else :
93- return meta ("0.0" , node = node )
102+ return meta ("0.0" , node = node , config = config )
94103
95104
96- def parse_archival (root ):
105+ def parse_archival (root , config = None ):
97106 archival = os .path .join (root , ".hg_archival.txt" )
98107 data = data_from_mime (archival )
99- return archival_to_version (data )
108+ return archival_to_version (data , config = config )
0 commit comments