@@ -425,7 +425,7 @@ def add(dest):
425425 def remove (dest ):
426426 info ("Removing reference \" %s\" " % dest )
427427 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' ])))
429429 except ProcessException :
430430 pass
431431
@@ -646,7 +646,7 @@ def add(dest):
646646 def remove (dest ):
647647 info ("Removing reference " + dest )
648648 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' ]))
650650 except ProcessException :
651651 pass
652652
@@ -1025,14 +1025,14 @@ def pathtype(cls, path=None):
10251025
10261026 return "directory" if depth == 0 else ("program" if depth == 1 else "library" )
10271027
1028- @classmethod
1029- def revtype (cls , rev , ret_rev = False ):
1028+ def revtype (self , rev = None , ret_type = True , ret_rev = True ):
10301029 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 '' )
10321031 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 '' )
10341034 else :
1035- return 'branch' + (' ' + rev if ret_rev else '' )
1035+ return ( 'branch/tag' if ret_type else '' ) + (' " ' + rev + '"' if ret_rev else '' )
10361036
10371037 @classmethod
10381038 def isurl (cls , url ):
@@ -1829,17 +1829,17 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
18291829 warning ("Importing from a local folder \" %s\" , not from a URL" % orig_url )
18301830
18311831 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 ))))
18331833 if repo .clone (repo .url , repo .path , rev = repo .rev , depth = depth , protocol = protocol ):
18341834 with cd (repo .path ):
18351835 Program (repo .path ).set_root ()
18361836 try :
18371837 if repo .rev and repo .getrev () != repo .rev :
18381838 repo .checkout (repo .rev , True )
18391839 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 ))
18411841 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 )))
18431843 if ignore :
18441844 warning (err )
18451845 else :
@@ -2033,14 +2033,14 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
20332033 action ("Updating %s \" %s\" to %s" % (
20342034 cwd_type if top else cwd_dest ,
20352035 os .path .basename (repo .path ) if top else relpath (cwd_root , repo .path ),
2036- repo .revtype (rev , True )))
2036+ repo .revtype (rev )))
20372037
20382038 try :
20392039 repo .update (rev , clean , clean_files , repo .is_local )
20402040 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 ))
20422042 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 )))
20442044 if ignore :
20452045 warning (err )
20462046 else :
@@ -2177,10 +2177,8 @@ def sync(recursive=True, keep_refs=False, top=True):
21772177 "View the dependency tree of the current program or library." ))
21782178def list_ (detailed = False , prefix = '' , p_path = None , ignore = False ):
21792179 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 ''
21822180
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' ))
21842182
21852183 for i , lib in enumerate (sorted (repo .libs , key = lambda l : l .path )):
21862184 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
22032201 repo = Repo .fromrepo ()
22042202 tags = repo .scm .gettags ()
22052203 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 ''
22072204 regex_rels = regex_rels_all if unstable else regex_rels_official
22082205
22092206 # Generate list of tags
@@ -2213,7 +2210,7 @@ def releases_(detailed=False, unstable=False, recursive=False, prefix='', p_path
22132210 rels .append (tag [1 ] + " %s%s" % ('#' + tag [0 ] if detailed else "" , " <- current" if tag [1 ] in revtags else "" ))
22142211
22152212 # 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' ))
22172214
22182215 # Print list of tags
22192216 rprefix = (prefix [:- 3 ] + ('| ' if prefix [- 3 ] == '|' else ' ' )) if recursive and prefix else ''
0 commit comments