From f407ae932a56ba3d243f9fd75c99e85632e7e9a5 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 25 Aug 2011 18:40:24 +0100 Subject: Abort if there's uncommitted changes, unless --uncommitted is used. --- unperish | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/unperish b/unperish index f884422..78307e7 100755 --- a/unperish +++ b/unperish @@ -74,6 +74,8 @@ class Unperish(cliapp.Application): self.settings.string(['upstream-version'], 'upstream version for project') + self.settings.boolean(['use-uncommitted'], 'use uncommited changes') + self.settings.config_files += ['project.meta'] def process_args(self, args): @@ -191,6 +193,14 @@ class Unperish(cliapp.Application): logging.debug('Does not already exist: %s' % filename) return False + def cmd_committed(self, args): + '''Check that all changes have been committed.''' + + if not self.settings['use-uncommitted']: + out = self.runcmd(['bzr', 'status']) + if out: + raise cliapp.AppException('Uncommitted changes:\n\n%s' % out) + def cmd_dget(self, args): '''Retrieve a Debian source package (.dsc and other files). @@ -208,11 +218,19 @@ class Unperish(cliapp.Application): def cmd_export(self, args): '''Export unpacked source directory to build area.''' + self.run_subcommand('committed') if not self.already_exists(self.join(self.dirname)): self.runcmd(['bzr', 'export', self.join(self.dirname)]) + if self.settings['use-uncommitted']: + out = self.runcmd(['bzr', 'status', '--versioned', '--short']) + for line in out.splitlines(): + status, name = line.split() + target = self.join(self.dirname, name) + shutil.copy2(name, target) def cmd_debian_tarball(self, args): '''Generate Debian tarball (.orig.tar.gz) in build area.''' + self.run_subcommand('committed') origtar = self.join(self.debian_tarball) if not self.already_exists(origtar): self.runcmd(['bzr', 'export', origtar]) -- cgit v1.2.1