From a8612f4ecc71ea87b25b6b46cf4871659d3d4dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Sat, 24 Jun 2017 14:25:05 +0200 Subject: [PATCH] Allow to cat/less files from deleted packages --- NEWS | 1 + osc/commandline.py | 6 +++++- osc/core.py | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index bd7be4dd..4315fa4b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ - "osc build -M ..": fixed behaviour of falvoured builds - added switch to show only issues in rdiff - show build duration in build history + - allow to cat/less files from deleted packages (using -D option) 0.158 - cat/less/blame command: default to expand to stay in sync with checkout diff --git a/osc/commandline.py b/osc/commandline.py index 136d6b96..6df2a1b0 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -7964,6 +7964,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='(default) force expansion of linked packages.') @cmdln.option('-u', '--unexpand', action='store_true', help='always work with unexpanded packages.') + @cmdln.option('-D', '--deleted', action='store_true', + help='access file in a deleted package') @cmdln.option('-M', '--meta', action='store_true', help='list meta data files') @cmdln.alias('blame') @@ -8017,10 +8019,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. query['view'] = "blame" if opts.meta: query['meta'] = 1 + if opts.deleted: + query['deleted'] = 1 if opts.revision: query['rev'] = opts.revision if not opts.unexpand: - query['rev'] = show_upstream_srcmd5(apiurl, project, package, expand=True, revision=opts.revision, meta=opts.meta) + query['rev'] = show_upstream_srcmd5(apiurl, project, package, expand=True, revision=opts.revision, meta=opts.meta, deleted=opts.deleted) query['expand'] = 1 # important for blame case to follow links in old revisions u = makeurl(apiurl, ['source', project, package, filename], query=query) if subcmd == 'less': diff --git a/osc/core.py b/osc/core.py index 2b9dd2fa..5a8af43a 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3743,7 +3743,7 @@ def edit_meta(metatype, f.sync() -def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, linkrepair=False, meta=False): +def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, linkrepair=False, meta=False, deleted=False): query = {} if revision: query['rev'] = revision @@ -3755,6 +3755,8 @@ def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, query['linkrev'] = 'base' if meta: query['meta'] = 1 + if deleted: + query['deleted'] = 1 if expand: query['expand'] = 1 if linkrepair: @@ -3762,8 +3764,8 @@ def show_files_meta(apiurl, prj, pac, revision=None, expand=False, linkrev=None, f = http_GET(makeurl(apiurl, ['source', prj, pac], query=query)) return f.read() -def show_upstream_srcmd5(apiurl, prj, pac, expand=False, revision=None, meta=False, include_service_files=False): - m = show_files_meta(apiurl, prj, pac, expand=expand, revision=revision, meta=meta) +def show_upstream_srcmd5(apiurl, prj, pac, expand=False, revision=None, meta=False, include_service_files=False, deleted=False): + m = show_files_meta(apiurl, prj, pac, expand=expand, revision=revision, meta=meta, deleted=deleted) et = ET.fromstring(''.join(m)) if include_service_files: try: