@@ -533,13 +533,13 @@ def getrev():
533
533
def getbranch ():
534
534
return pquery ([hg_cmd , 'branch' ]).strip () or ""
535
535
536
- def gettags (rev = None ):
536
+ def gettags ():
537
537
tags = []
538
538
refs = pquery ([hg_cmd , 'tags' ]).strip ().splitlines () or []
539
539
for ref in refs :
540
540
m = re .match (r'^(.+?)\s+(\d+)\:([a-f0-9]+)$' , ref )
541
- if m and ( not rev or m .group (1 ). startswith ( rev )) :
542
- tags .append (m . group ( 1 ) if rev else [m .group (3 ), m .group (1 )])
541
+ if m and m .group (1 ) != 'tips' :
542
+ tags .append ([m .group (3 ), m .group (1 )])
543
543
return tags
544
544
545
545
def remoteid (url , rev = None ):
@@ -822,19 +822,19 @@ def getbranches(rev=None, ret_rev=False):
822
822
return result
823
823
824
824
# Finds tags. Will match rev if specified
825
- def gettags (rev = None ):
825
+ def gettags ():
826
826
tags = []
827
827
refs = Git .getrefs ()
828
828
for ref in refs :
829
829
m = re .match (r'^(.+)\s+refs\/tags\/(.+)$' , ref )
830
- if m and ( not rev or m . group ( 1 ). startswith ( rev )) :
830
+ if m :
831
831
t = m .group (2 )
832
832
if re .match (r'^(.+)\^\{\}$' , t ): # detect tag "pointer"
833
833
t = re .sub (r'\^\{\}$' , '' , t ) # remove "pointer" chars, e.g. some-tag^{}
834
834
for tag in tags :
835
835
if tag [1 ] == t :
836
836
tags .remove (tag )
837
- tags .append (t if rev else [m .group (1 ), t ])
837
+ tags .append ([m .group (1 ), t ])
838
838
return tags
839
839
840
840
# Finds branches a rev belongs to
@@ -1029,7 +1029,7 @@ def revtype(self, rev=None, ret_type=True, ret_rev=True, fmt=3):
1029
1029
if rev is None or len (rev ) == 0 :
1030
1030
output = ('latest' if fmt & 1 else '' ) + (' revision in the current branch' if fmt & 2 else '' )
1031
1031
elif re .match (r'^([a-fA-F0-9]{6,40})$' , rev ) or re .match (r'^([0-9]+)$' , rev ):
1032
- revtags = self .scm . gettags (rev ) if self . scm and rev else []
1032
+ revtags = self .gettags (rev ) if rev else []
1033
1033
output = ('rev ' if fmt & 1 else '' ) + (('#' + rev [:12 ] + ((' (tag' + ('s' if len (revtags ) > 1 else '' ) + ': ' + ', ' .join (revtags [0 :2 ]) + ')' ) if len (revtags ) else '' )) if fmt & 2 and rev else '' )
1034
1034
else :
1035
1035
output = ('branch/tag' if fmt & 1 else '' ) + (' "' + rev + '"' if fmt & 2 else '' )
@@ -1087,6 +1087,13 @@ def getscm(self):
1087
1087
if os .path .isdir (os .path .join (self .path , '.' + name )):
1088
1088
return scm
1089
1089
1090
+ def gettags (self , rev = None ):
1091
+ tags = self .scm .gettags () if self .scm else []
1092
+ if rev :
1093
+ return [tag [1 ] for tag in tags if tag [0 ].startswith (rev )]
1094
+ else :
1095
+ return tags
1096
+
1090
1097
# Pass backend SCM commands and parameters if SCM exists
1091
1098
def __wrap_scm (self , method ):
1092
1099
def __scm_call (* args , ** kwargs ):
@@ -2201,8 +2208,8 @@ def list_(detailed=False, prefix='', p_path=None, ignore=False):
2201
2208
"Show release tags for the current program or library." ))
2202
2209
def releases_ (detailed = False , unstable = False , recursive = False , prefix = '' , p_path = None ):
2203
2210
repo = Repo .fromrepo ()
2204
- tags = repo .scm . gettags ()
2205
- revtags = repo .scm . gettags (repo .rev ) if repo .rev else [] # associated tags with current commit
2211
+ tags = repo .gettags ()
2212
+ revtags = repo .gettags (repo .rev ) if repo .rev and len ( tags ) else [] # associated tags with current commit
2206
2213
regex_rels = regex_rels_all if unstable else regex_rels_official
2207
2214
2208
2215
# Generate list of tags
0 commit comments