From 38c0621a9089f150f0709ea130ab0e452ee0a95a Mon Sep 17 00:00:00 2001 From: Juergen Weigert Date: Mon, 8 Mar 2010 23:52:51 +0100 Subject: [PATCH] osc ls -u -- same logic here as mls suggests for osc cat. --- NEWS | 2 +- osc/commandline.py | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 0acd902..44a5c68 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ - suggest git, svn, ... if indicated, after oscerr.NoWorkingCopy - - "osc cat" now auto-expands through link. + - "osc cat" & "osc ls" now auto-expands through link. - fixed "osc add" after "osc delete". 0.126 diff --git a/osc/commandline.py b/osc/commandline.py index aefec04..6b491e5 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -199,6 +199,8 @@ class Osc(cmdln.Cmdln): help='specify revision (only for sources)') @cmdln.option('-e', '--expand', action='store_true', help='expand linked package (only for sources)') + @cmdln.option('-u', '--unexpand', action='store_true', + help='always work with unexpanded (source) packages') @cmdln.option('-v', '--verbose', action='store_true', help='print extra information') @cmdln.option('-l', '--long', action='store_true', dest='verbose', @@ -338,28 +340,40 @@ class Osc(cmdln.Cmdln): print '\n'.join(meta_get_packagelist(conf.config['apiurl'], project)) elif len(args) == 2 or len(args) == 3: - l = meta_get_filelist(conf.config['apiurl'], + link_seen = False + print_not_found = True + for i in [ 1, 2 ]: + l = meta_get_filelist(conf.config['apiurl'], project, package, verbose=opts.verbose, expand=opts.expand, revision=opts.revision) - if opts.verbose: - out = [ '%s %7s %9d %s %s' % (i.md5, i.rev, i.size, shorttime(i.mtime), i.name) \ + if opts.verbose: + for i in l: + if i.name == '_link': + link_seen = True + out = [ '%s %7s %9d %s %s' % (i.md5, i.rev, i.size, shorttime(i.mtime), i.name) \ for i in l if not fname or fname == i.name ] - if len(out) == 0: - if fname: - print 'file \'%s\' does not exist' % fname + if len(out) > 0: + print_not_found = False + print '\n'.join(out) else: - print '\n'.join(out) - else: - if fname: - if fname in l: - print fname + if '_link' in l: + link_seen = True + if fname: + if fname in l: + print fname + print_not_found = False else: - print 'file \'%s\' does not exist' % fname - else: - print '\n'.join(l) + print '\n'.join(l) + if opts.expand or opts.unexpand or link_seen == 0: break + m = show_files_meta(conf.config['apiurl'], project, package) + xml = ET.fromstring(''.join(m)).find('linkinfo') + print "# -> %s %s" % (xml.get('project'), xml.get('package')) + opts.expand = True + if fname and print_not_found: + print 'file \'%s\' does not exist' % fname @cmdln.option('-f', '--force', action='store_true', -- 2.1.4