[packages/git-core-slug] - rel 10; better keyboard interrupt handling
arekm
arekm at pld-linux.org
Fri Nov 28 18:08:50 CET 2014
commit b64091ff3bf26add6d2d6712485dd3d4fc1697ca
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Fri Nov 28 18:08:45 2014 +0100
- rel 10; better keyboard interrupt handling
git-core-slug-git.patch | 77 ++++++++++++++++++-------------------------------
git-core-slug.spec | 2 +-
2 files changed, 29 insertions(+), 50 deletions(-)
---
diff --git a/git-core-slug.spec b/git-core-slug.spec
index 3136a2e..6b507d5 100644
--- a/git-core-slug.spec
+++ b/git-core-slug.spec
@@ -3,7 +3,7 @@ Summary: Tools to interact with PLD git repositories
Summary(pl.UTF-8): Narzędzia do pracy z repozytoriami gita w PLD
Name: git-core-slug
Version: 0.13.4
-Release: 9
+Release: 10
License: GPL v2
Group: Development/Building
Source0: https://github.com/draenog/slug/tarball/v%{version}/%{name}-%{version}.tar.gz
diff --git a/git-core-slug-git.patch b/git-core-slug-git.patch
index 2b09cf4..2da8b87 100644
--- a/git-core-slug-git.patch
+++ b/git-core-slug-git.patch
@@ -52,7 +52,7 @@ index 4354ac4..67592f8 100644
for line in data:
(sha1_old, sha1, ref) = line.split()
diff --git a/slug.py b/slug.py
-index 69bd3b9..b4ac0fd 100755
+index 69bd3b9..17a67e7 100755
--- a/slug.py
+++ b/slug.py
@@ -7,26 +7,18 @@ import os
@@ -85,7 +85,7 @@ index 69bd3b9..b4ac0fd 100755
class UnquoteConfig(configparser.ConfigParser):
def get(self, section, option, **kwargs):
value = super().get(section, option, **kwargs)
-@@ -43,25 +35,15 @@ class DelAppend(argparse._AppendAction):
+@@ -43,25 +35,30 @@ class DelAppend(argparse._AppendAction):
item.append(values)
setattr(namespace, self.dest, item)
@@ -117,10 +117,25 @@ index 69bd3b9..b4ac0fd 100755
+
+def pool_worker_init():
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
++
++def run_worker(function, options, args):
++ ret = []
++ pool = WorkerPool(options.jobs, pool_worker_init)
++ try:
++ ret = pool.starmap(function, args)
++ pool.close()
++ pool.join()
++ ret = list(filter(None, ret))
++ except KeyboardInterrupt:
++ print('Keyboard interrupt received, finishing...', file=sys.stderr)
++ pool.terminate()
++ pool.join()
++ sys.exit(1)
++ return ret
def readconfig(path):
config = UnquoteConfig(delimiters='=', interpolation=None, strict=False)
-@@ -114,38 +96,62 @@ def getrefs(*args):
+@@ -114,38 +111,45 @@ def getrefs(*args):
sys.exit(2)
return refs
@@ -161,14 +176,7 @@ index 69bd3b9..b4ac0fd 100755
+ if not os.path.isdir(gitdir):
+ pkgs_new.append(pkgdir)
+
-+ pool = WorkerPool(options.jobs, pool_worker_init)
-+ try:
-+ pool.starmap(initpackage, zip(pkgs_new, [options] * len(pkgs_new)))
-+ except KeyboardInterrupt:
-+ pool.terminate()
-+ else:
-+ pool.close()
-+ pool.join()
++ run_worker(initpackage, options, zip(pkgs_new, [options] * len(pkgs_new)))
+
+ args = []
for pkgdir in sorted(refs.heads):
@@ -193,21 +201,11 @@ index 69bd3b9..b4ac0fd 100755
+ args.append((gitrepo, refs.heads[pkgdir], options))
- fetch_queue.join()
-+ updated_repos = []
-+ pool = WorkerPool(options.jobs, pool_worker_init)
-+ try:
-+ updated_repos = pool.starmap(fetch_package, args)
-+ except KeyboardInterrupt:
-+ pool.terminate()
-+ else:
-+ pool.close()
-+ pool.join()
-+
-+ updated_repos = list(filter(None, updated_repos))
++ updated_repos = run_worker(fetch_package, options, args)
if options.prune:
refs = getrefs('*')
-@@ -158,26 +164,60 @@ def fetch_packages(options, return_all=False):
+@@ -158,26 +162,47 @@ def fetch_packages(options, return_all=False):
if return_all:
return refs.heads
else:
@@ -233,14 +231,8 @@ index 69bd3b9..b4ac0fd 100755
- except GitRepoError as e:
- print('Problem with checking branch {} in repo {}: {}'.format(options.checkout, repo.gdir, e), file=sys.stderr)
+ repos.append(GitRepo(os.path.join(options.packagesdir, pkgdir)))
-+ pool = WorkerPool(options.jobs)
-+ try:
-+ pool.starmap(checkout_package, zip(repos, [options] * len(repos)))
-+ except KeyboardInterrupt:
-+ pool.terminate()
-+ else:
-+ pool.close()
-+ pool.join()
++
++ run_worker(checkout_package, options, zip(repos, [options] * len(repos)))
+
+def clone_package(repo, options):
+ try:
@@ -255,14 +247,7 @@ index 69bd3b9..b4ac0fd 100755
- except GitRepoError as e:
- print('Problem with checking branch master in repo {}: {}'.format(repo.gdir, e), file=sys.stderr)
+ repos = fetch_packages(options)
-+ pool = WorkerPool(options.jobs)
-+ try:
-+ pool.starmap(clone_package, zip(repos, [options] * len(repos)))
-+ except KeyboardInterrupt:
-+ pool.terminate()
-+ else:
-+ pool.close()
-+ pool.join()
++ run_worker(clone_package, options, zip(repos, [options] * len(repos)))
+
+def pull_package(gitrepo, options):
+ directory = os.path.basename(gitrepo.wtree)
@@ -279,7 +264,7 @@ index 69bd3b9..b4ac0fd 100755
def pull_packages(options):
repolist = []
-@@ -189,19 +229,14 @@ def pull_packages(options):
+@@ -189,19 +214,8 @@ def pull_packages(options):
else:
repolist = fetch_packages(options, False)
print('--------Pulling------------')
@@ -297,17 +282,11 @@ index 69bd3b9..b4ac0fd 100755
- pass
-
+ pool = WorkerPool(options.jobs, pool_worker_init)
-+ try:
-+ pool.starmap(pull_package, zip(repolist, [options] * len(repolist)))
-+ except KeyboardInterrupt:
-+ pool.terminate()
-+ else:
-+ pool.close()
-+ pool.join()
++ run_worker(pull_package, options, zip(repolist, [options] * len(repolist)))
def list_packages(options):
refs = getrefs(options.branch, options.repopattern)
-@@ -213,7 +248,7 @@ common_options.add_argument('-d', '--packagesdir', help='local directory with gi
+@@ -213,7 +227,7 @@ common_options.add_argument('-d', '--packagesdir', help='local directory with gi
default=os.path.expanduser('~/rpm/packages'))
common_fetchoptions = argparse.ArgumentParser(add_help=False, parents=[common_options])
@@ -316,7 +295,7 @@ index 69bd3b9..b4ac0fd 100755
common_fetchoptions.add_argument('repopattern', nargs='*', default = ['*'])
common_fetchoptions.add_argument('--depth', help='depth of fetch', default=0)
-@@ -253,10 +288,14 @@ default_options['fetch'] = {'branch': '[*]', 'prune': False, 'newpkgs': False, '
+@@ -253,10 +267,14 @@ default_options['fetch'] = {'branch': '[*]', 'prune': False, 'newpkgs': False, '
pull = subparsers.add_parser('pull', help='git-pull in all existing repositories', parents=[common_fetchoptions],
formatter_class=argparse.RawDescriptionHelpFormatter)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/git-core-slug.git/commitdiff/b64091ff3bf26add6d2d6712485dd3d4fc1697ca
More information about the pld-cvs-commit
mailing list