@@ -425,7 +425,7 @@ def add(dest):
425
425
def remove (dest ):
426
426
info ("Removing reference \" %s\" " % dest )
427
427
try :
428
- popen ([hg_cmd , 'rm' , '-f' , dest ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
428
+ pquery ([hg_cmd , 'rm' , '-f' , dest ] + (['-v' ] if very_verbose else ([] if verbose else ['-q' ])))
429
429
except ProcessException :
430
430
pass
431
431
@@ -646,7 +646,7 @@ def add(dest):
646
646
def remove (dest ):
647
647
info ("Removing reference " + dest )
648
648
try :
649
- popen ([git_cmd , 'rm' , '-f' , dest ] + ([] if very_verbose else ['-q' ]))
649
+ pquery ([git_cmd , 'rm' , '-f' , dest ] + ([] if very_verbose else ['-q' ]))
650
650
except ProcessException :
651
651
pass
652
652
@@ -1025,14 +1025,14 @@ def pathtype(cls, path=None):
1025
1025
1026
1026
return "directory" if depth == 0 else ("program" if depth == 1 else "library" )
1027
1027
1028
- @classmethod
1029
- def revtype (cls , rev , ret_rev = False ):
1028
+ def revtype (self , rev = None , ret_type = True , ret_rev = True ):
1030
1029
if rev is None or len (rev ) == 0 :
1031
- return 'latest' + (' revision in the current branch' if ret_rev else '' )
1030
+ return ( 'latest' if ret_type else '' ) + (' revision in the current branch' if ret_rev else '' )
1032
1031
elif re .match (r'^([a-fA-F0-9]{6,40})$' , rev ) or re .match (r'^([0-9]+)$' , rev ):
1033
- return 'rev' + (' #' + rev [0 :12 ] if ret_rev else '' )
1032
+ revtags = self .scm .gettags (rev ) if self .scm and rev else []
1033
+ return ('rev ' if ret_type else '' ) + (('#' + rev [:12 ] + ((' (tag' + ('s' if len (revtags ) > 1 else '' ) + ': ' + ', ' .join (revtags [0 :2 ]) + ')' ) if len (revtags ) else '' )) if ret_rev and rev else '' )
1034
1034
else :
1035
- return 'branch' + (' ' + rev if ret_rev else '' )
1035
+ return ( 'branch/tag' if ret_type else '' ) + (' " ' + rev + '"' if ret_rev else '' )
1036
1036
1037
1037
@classmethod
1038
1038
def isurl (cls , url ):
@@ -1829,17 +1829,17 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
1829
1829
warning ("Importing from a local folder \" %s\" , not from a URL" % orig_url )
1830
1830
1831
1831
text = "Importing program" if top else "Adding library"
1832
- action ("%s \" %s\" from \" %s\" %s" % (text , relpath (cwd_root , repo .path ), formaturl (repo .url , protocol ), ' at ' + (repo .revtype (repo .rev , True ))))
1832
+ action ("%s \" %s\" from \" %s\" %s" % (text , relpath (cwd_root , repo .path ), formaturl (repo .url , protocol ), ' at ' + (repo .revtype (repo .rev ))))
1833
1833
if repo .clone (repo .url , repo .path , rev = repo .rev , depth = depth , protocol = protocol ):
1834
1834
with cd (repo .path ):
1835
1835
Program (repo .path ).set_root ()
1836
1836
try :
1837
1837
if repo .rev and repo .getrev () != repo .rev :
1838
1838
repo .checkout (repo .rev , True )
1839
1839
except ProcessException as e :
1840
- err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev , True ))
1840
+ err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (repo .rev ))
1841
1841
if depth :
1842
- err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev , True )))
1842
+ err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev )))
1843
1843
if ignore :
1844
1844
warning (err )
1845
1845
else :
@@ -2033,14 +2033,14 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
2033
2033
action ("Updating %s \" %s\" to %s" % (
2034
2034
cwd_type if top else cwd_dest ,
2035
2035
os .path .basename (repo .path ) if top else relpath (cwd_root , repo .path ),
2036
- repo .revtype (rev , True )))
2036
+ repo .revtype (rev )))
2037
2037
2038
2038
try :
2039
2039
repo .update (rev , clean , clean_files , repo .is_local )
2040
2040
except ProcessException as e :
2041
- err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (rev , True ))
2041
+ err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (rev ))
2042
2042
if depth :
2043
- err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev , True )))
2043
+ err = err + ("\n The --depth option might prevent fetching the whole revision tree and checking out %s." % (repo .revtype (repo .rev )))
2044
2044
if ignore :
2045
2045
warning (err )
2046
2046
else :
@@ -2177,10 +2177,8 @@ def sync(recursive=True, keep_refs=False, top=True):
2177
2177
"View the dependency tree of the current program or library." ))
2178
2178
def list_ (detailed = False , prefix = '' , p_path = None , ignore = False ):
2179
2179
repo = Repo .fromrepo ()
2180
- revtags = repo .scm .gettags (repo .rev ) if repo .rev else []
2181
- revstr = ('#' + repo .rev [:12 ] + (', tags: ' + ', ' .join (revtags [0 :2 ]) if len (revtags ) else '' )) if repo .rev else ''
2182
2180
2183
- print "%s (%s)" % (prefix + (relpath (p_path , repo .path ) if p_path else repo .name ), ((repo .url + ('#' + str (repo .rev )[:12 ] if repo .rev else '' ) if detailed else revstr ) or 'no revision' ))
2181
+ print "%s (%s)" % (prefix + (relpath (p_path , repo .path ) if p_path else repo .name ), ((repo .url + ('#' + str (repo .rev )[:12 ] if repo .rev else '' ) if detailed else repo . revtype ( repo . rev , False ) ) or 'no revision' ))
2184
2182
2185
2183
for i , lib in enumerate (sorted (repo .libs , key = lambda l : l .path )):
2186
2184
nprefix = (prefix [:- 3 ] + ('| ' if prefix [- 3 ] == '|' else ' ' )) if prefix else ''
@@ -2203,7 +2201,6 @@ def releases_(detailed=False, unstable=False, recursive=False, prefix='', p_path
2203
2201
repo = Repo .fromrepo ()
2204
2202
tags = repo .scm .gettags ()
2205
2203
revtags = repo .scm .gettags (repo .rev ) if repo .rev else [] # associated tags with current commit
2206
- revstr = ('#' + repo .rev [:12 ] + (', tags: ' + ', ' .join (revtags [0 :2 ]) if len (revtags ) else '' )) if repo .rev else ''
2207
2204
regex_rels = regex_rels_all if unstable else regex_rels_official
2208
2205
2209
2206
# Generate list of tags
@@ -2213,7 +2210,7 @@ def releases_(detailed=False, unstable=False, recursive=False, prefix='', p_path
2213
2210
rels .append (tag [1 ] + " %s%s" % ('#' + tag [0 ] if detailed else "" , " <- current" if tag [1 ] in revtags else "" ))
2214
2211
2215
2212
# Print header
2216
- print "%s (%s)" % (prefix + (relpath (p_path , repo .path ) if p_path else repo .name ), ((repo .url + ('#' + str (repo .rev )[:12 ] if repo .rev else '' ) if detailed else revstr ) or 'no revision' ))
2213
+ print "%s (%s)" % (prefix + (relpath (p_path , repo .path ) if p_path else repo .name ), ((repo .url + ('#' + str (repo .rev )[:12 ] if repo .rev else '' ) if detailed else repo . revtype ( repo . rev , False ) ) or 'no revision' ))
2217
2214
2218
2215
# Print list of tags
2219
2216
rprefix = (prefix [:- 3 ] + ('| ' if prefix [- 3 ] == '|' else ' ' )) if recursive and prefix else ''
0 commit comments