Commit 03accd29 authored by Mathieu Parent's avatar Mathieu Parent Committed by Guido Günther

import-orig: Allow to import the requested version with --uscan

Closes: #741148
parent 7ce98d64
......@@ -70,8 +70,8 @@
</listitem>
<listitem>
<para>
<option>--uscan</option>: The latest upstream version is fetched
via &uscan; relying on <filename>debian/watch</filename>.
<option>--uscan</option>: The latest upstream or specified version is
fetched via &uscan; relying on <filename>debian/watch</filename>.
</para>
</listitem>
</orderedlist>
......@@ -112,7 +112,8 @@
<term><option>-u</option><replaceable>version</replaceable></term>
<listitem>
<para>
The upstream version number
The upstream version number. With <option>--uscan</option>, passed to
uscan as <option>--download-debversion</option>
</para>
</listitem>
</varlistentry>
......@@ -333,7 +334,8 @@
<term><option>--uscan</option></term>
<listitem>
<para>
Use &uscan; to fetch new upstream version.
Use &uscan; to fetch new upstream version. The version can be
specified with <option>--upstream-version</option>
</para>
</listitem>
</varlistentry>
......
......@@ -174,16 +174,16 @@ class Uscan(object):
msg = "Uscan failed - debug by running 'uscan --verbose'"
raise UscanError(msg)
def scan(self, destdir='..'):
def scan(self, destdir='..', download_version=None):
"""
Invoke uscan to fetch a new upstream version
@returns: C{True} if a new version was downloaded
"""
p = subprocess.Popen(['uscan', '--symlink', '--destdir=%s' % destdir,
'--dehs'],
cwd=self._dir,
stdout=subprocess.PIPE)
cmd = ['uscan', '--symlink', '--destdir=%s' % destdir, '--dehs']
if download_version:
cmd += ['--download-debversion', download_version]
p = subprocess.Popen(cmd, cwd=self._dir, stdout=subprocess.PIPE)
out = p.communicate()[0].decode()
# uscan exits with 1 in case of uptodate and when an error occurred.
# Don't fail in the uptodate case:
......
......@@ -133,7 +133,7 @@ def detect_name_and_version(repo, source, options):
return (sourcepackage, version)
def find_upstream(use_uscan, args):
def find_upstream(use_uscan, args, version=None):
"""Find the main tarball to import - either via uscan or via command line argument
@return: upstream source filename or None if nothing to import
@rtype: string
......@@ -161,7 +161,7 @@ def find_upstream(use_uscan, args):
uscan = Uscan()
gbp.log.info("Launching uscan...")
try:
if not uscan.scan():
if not uscan.scan(download_version=version):
gbp.log.info("package is up to date, nothing to do.")
return None
except UscanError as e:
......@@ -422,7 +422,7 @@ def main(argv):
if options.download:
upstream = download_orig(args[0])
else:
upstream = find_upstream(options.uscan, args)
upstream = find_upstream(options.uscan, args, options.version)
if not upstream:
return ExitCodes.uscan_up_to_date
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment