aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2015-02-13 17:10:09 +0200
committerGuido Günther <agx@sigxcpu.org>2016-05-27 11:46:12 +0200
commit5a7483e3e8343d56315f70d9f9b8aa3b3429d441 (patch)
treec9d7715e020cccc6a6337e4a5fbfc6859869901e
parent09ff1110155c411362122639540a32be33d49115 (diff)
import_dsc: remove excess indentation in code
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/scripts/import_dsc.py215
1 files changed, 107 insertions, 108 deletions
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index 1765d97..2db7fdc 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -302,117 +302,116 @@ def main(argv):
if len(args) != 1:
gbp.log.err("Need to give exactly one package to import. Try --help.")
raise GbpError
+ try:
+ repo = DebianGitRepository('.')
+ is_empty = repo.is_empty()
+
+ (clean, out) = repo.is_clean()
+ if not clean and not is_empty:
+ gbp.log.err("Repository has uncommitted changes, commit these first: ")
+ raise GbpError(out)
+ except GitRepositoryError:
+ # no repo found, create one
+ needs_repo = True
+ is_empty = True
+
+ pkg = args[0]
+ if options.download:
+ dsc = download_source(pkg,
+ dirs=dirs,
+ unauth=options.allow_unauthenticated)
else:
- try:
- repo = DebianGitRepository('.')
- is_empty = repo.is_empty()
-
- (clean, out) = repo.is_clean()
- if not clean and not is_empty:
- gbp.log.err("Repository has uncommitted changes, commit these first: ")
- raise GbpError(out)
- except GitRepositoryError:
- # no repo found, create one
- needs_repo = True
- is_empty = True
-
- pkg = args[0]
- if options.download:
- dsc = download_source(pkg,
- dirs=dirs,
- unauth=options.allow_unauthenticated)
+ dsc = pkg
+
+ src = DscFile.parse(dsc)
+ if src.pkgformat not in [ '1.0', '3.0' ]:
+ raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
+ if options.verbose:
+ print_dsc(src)
+
+ if needs_repo:
+ if os.path.exists(src.pkg):
+ raise GbpError("Directory '%s' already exists. If you want to import into it, "
+ "please change into this directory otherwise move it away first."
+ % src.pkg)
+ gbp.log.info("No git repository found, creating one.")
+ repo = DebianGitRepository.create(src.pkg)
+ os.chdir(repo.path)
+
+ if repo.bare:
+ disable_pristine_tar(options, "Bare repository")
+
+ dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
+ upstream = DebianUpstreamSource(src.tgz)
+ upstream.unpack(dirs['tmp'], options.filters)
+ for tarball in src.additional_tarballs.values():
+ gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
+ subtarball = DebianUpstreamSource(tarball)
+ subtarball.unpack(upstream.unpacked, options.filters)
+
+ format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
+ tag = repo.version_to_tag(format[0], src.upstream_version)
+ msg = "%s version %s" % (format[1], src.upstream_version)
+
+ if repo.find_version(options.debian_tag, src.version):
+ gbp.log.warn("Version %s already imported." % src.version)
+ if options.allow_same_version:
+ gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
+ move_tag_stamp(repo, options.debian_tag, src.version)
else:
- dsc = pkg
-
- src = DscFile.parse(dsc)
- if src.pkgformat not in [ '1.0', '3.0' ]:
- raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
- if options.verbose:
- print_dsc(src)
-
- if needs_repo:
- if os.path.exists(src.pkg):
- raise GbpError("Directory '%s' already exists. If you want to import into it, "
- "please change into this directory otherwise move it away first."
- % src.pkg)
- gbp.log.info("No git repository found, creating one.")
- repo = DebianGitRepository.create(src.pkg)
- os.chdir(repo.path)
-
- if repo.bare:
- disable_pristine_tar(options, "Bare repository")
-
- dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
- upstream = DebianUpstreamSource(src.tgz)
- upstream.unpack(dirs['tmp'], options.filters)
- for tarball in src.additional_tarballs.values():
- gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
- subtarball = DebianUpstreamSource(tarball)
- subtarball.unpack(upstream.unpacked, options.filters)
-
- format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
- tag = repo.version_to_tag(format[0], src.upstream_version)
- msg = "%s version %s" % (format[1], src.upstream_version)
-
- if repo.find_version(options.debian_tag, src.version):
- gbp.log.warn("Version %s already imported." % src.version)
- if options.allow_same_version:
- gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
- move_tag_stamp(repo, options.debian_tag, src.version)
- else:
- raise SkipImport
-
- if not repo.find_version(format[0], src.upstream_version):
- gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
- if is_empty:
- branch = None
- else:
- branch = [options.upstream_branch,
- options.debian_branch][src.native]
- if not repo.has_branch(branch):
- if options.create_missing_branches:
- gbp.log.info("Creating missing branch '%s'" % branch)
- repo.create_branch(branch)
- else:
- gbp.log.err(no_upstream_branch_msg % branch +
- "\nAlso check the --create-missing-branches option.")
- raise GbpError
-
- if src.native:
- author = get_author_from_changelog(upstream.unpacked)
- committer = get_committer_from_author(author, options)
- else:
- author = committer = {}
-
- commit = repo.commit_dir(upstream.unpacked,
- "Imported %s" % msg,
- branch,
- author=author,
- committer=committer)
-
- if not (src.native and options.skip_debian_tag):
- repo.create_tag(name=tag,
- msg=msg,
- commit=commit,
- sign=options.sign_tags,
- keyid=options.keyid)
- if not src.native:
- if is_empty:
- repo.create_branch(options.upstream_branch, commit)
- if options.pristine_tar:
- generate_pristine_tarballs(repo, src, options.upstream_branch)
- if (not repo.has_branch(options.debian_branch)
- and (is_empty or options.create_missing_branches)):
- repo.create_branch(options.debian_branch, commit)
+ raise SkipImport
+
+ if not repo.find_version(format[0], src.upstream_version):
+ gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
+ if is_empty:
+ branch = None
+ else:
+ branch = [options.upstream_branch,
+ options.debian_branch][src.native]
+ if not repo.has_branch(branch):
+ if options.create_missing_branches:
+ gbp.log.info("Creating missing branch '%s'" % branch)
+ repo.create_branch(branch)
+ else:
+ gbp.log.err(no_upstream_branch_msg % branch +
+ "\nAlso check the --create-missing-branches option.")
+ raise GbpError
+
+ if src.native:
+ author = get_author_from_changelog(upstream.unpacked)
+ committer = get_committer_from_author(author, options)
+ else:
+ author = committer = {}
+
+ commit = repo.commit_dir(upstream.unpacked,
+ "Imported %s" % msg,
+ branch,
+ author=author,
+ committer=committer)
+
+ if not (src.native and options.skip_debian_tag):
+ repo.create_tag(name=tag,
+ msg=msg,
+ commit=commit,
+ sign=options.sign_tags,
+ keyid=options.keyid)
if not src.native:
- if src.diff or src.deb_tgz:
- apply_debian_patch(repo, upstream.unpacked, src, options,
- tag)
- else:
- gbp.log.warn("Didn't find a diff to apply.")
- if repo.get_branch() == options.debian_branch or is_empty:
- # Update HEAD if we modified the checked out branch
- repo.force_head(options.debian_branch, hard=True)
+ if is_empty:
+ repo.create_branch(options.upstream_branch, commit)
+ if options.pristine_tar:
+ generate_pristine_tarballs(repo, src, options.upstream_branch)
+ if (not repo.has_branch(options.debian_branch)
+ and (is_empty or options.create_missing_branches)):
+ repo.create_branch(options.debian_branch, commit)
+ if not src.native:
+ if src.diff or src.deb_tgz:
+ apply_debian_patch(repo, upstream.unpacked, src, options,
+ tag)
+ else:
+ gbp.log.warn("Didn't find a diff to apply.")
+ if repo.get_branch() == options.debian_branch or is_empty:
+ # Update HEAD if we modified the checked out branch
+ repo.force_head(options.debian_branch, hard=True)
except KeyboardInterrupt:
ret = 1
gbp.log.err("Interrupted. Aborting.")