diff -u duplicity-0.6.18/debian/changelog duplicity-0.6.18/debian/changelog --- duplicity-0.6.18/debian/changelog +++ duplicity-0.6.18/debian/changelog @@ -1,3 +1,10 @@ +duplicity (0.6.18-0ubuntu4) precise-proposed; urgency=low + + * debian/patches/07caching.dpatch: + - Backport caching work done by Steve Atwell. (LP: #1013446) + + -- Chris J Arges Wed, 14 Nov 2012 10:41:17 -0600 + duplicity (0.6.18-0ubuntu3) precise; urgency=low * debian/patches/06lazywarnings.dpatch: diff -u duplicity-0.6.18/debian/patches/00list duplicity-0.6.18/debian/patches/00list --- duplicity-0.6.18/debian/patches/00list +++ duplicity-0.6.18/debian/patches/00list @@ -4,0 +5 @@ +07caching only in patch2: unchanged: --- duplicity-0.6.18.orig/debian/patches/07caching.dpatch +++ duplicity-0.6.18/debian/patches/07caching.dpatch @@ -0,0 +1,218 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 07caching.dpatch by Chris J Arges +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: This patch backports caching support. (LP: #1013446) + +@DPATCH@ +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/Changelog.GNU duplicity-0.6.18/Changelog.GNU +--- duplicity-0.6.18~/Changelog.GNU 2012-02-29 13:24:04.000000000 -0600 ++++ duplicity-0.6.18/Changelog.GNU 2012-11-14 10:40:16.771375106 -0600 +@@ -1,3 +1,9 @@ ++2012-11-14 chris.j.arges@canonical.com ++ ++ * Merged in lp:~satwell/duplicity/caching ++ - Add a cache for password and group lookups. This significantly improves ++ runtime with very large password and group configurations. ++ + 2012-02-29 kenneth@loafman.com + + Changes for 0.6.18. +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/cached_ops.py duplicity-0.6.18/cached_ops.py +--- duplicity-0.6.18~/cached_ops.py 1969-12-31 18:00:00.000000000 -0600 ++++ duplicity-0.6.18/cached_ops.py 2012-11-14 10:38:07.139372741 -0600 +@@ -0,0 +1,62 @@ ++# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- ++# ++# Copyright 2012 Google Inc. ++# ++# This file is part of duplicity. ++# ++# Duplicity is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by the ++# Free Software Foundation; either version 2 of the License, or (at your ++# option) any later version. ++# ++# Duplicity is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with duplicity; if not, write to the Free Software Foundation, ++# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ ++"""Cache-wrapped functions for grp and pwd lookups.""" ++ ++import grp ++import pwd ++ ++ ++class CachedCall(object): ++ """Decorator for caching the results of function calls.""" ++ ++ def __init__(self, f): ++ self.cache = {} ++ self.f = f ++ ++ def __call__(self, *args): ++ try: ++ return self.cache[args] ++ except (KeyError, TypeError), e: ++ result = self.f(*args) ++ if not isinstance(e, TypeError): ++ # TypeError most likely means that args is not hashable ++ self.cache[args] = result ++ return result ++ ++ ++@CachedCall ++def getgrgid(gid): ++ return grp.getgrgid(gid) ++ ++ ++@CachedCall ++def getgrnam(name): ++ return grp.getgrnam(name) ++ ++ ++@CachedCall ++def getpwnam(name): ++ return pwd.getpwnam(name) ++ ++ ++@CachedCall ++def getpwuid(uid): ++ return pwd.getpwuid(uid) +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/cached_ops.py duplicity-0.6.18/duplicity/cached_ops.py +--- duplicity-0.6.18~/duplicity/cached_ops.py 1969-12-31 18:00:00.000000000 -0600 ++++ duplicity-0.6.18/duplicity/cached_ops.py 2012-11-14 10:38:11.539372820 -0600 +@@ -0,0 +1,62 @@ ++# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- ++# ++# Copyright 2012 Google Inc. ++# ++# This file is part of duplicity. ++# ++# Duplicity is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by the ++# Free Software Foundation; either version 2 of the License, or (at your ++# option) any later version. ++# ++# Duplicity is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with duplicity; if not, write to the Free Software Foundation, ++# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ ++"""Cache-wrapped functions for grp and pwd lookups.""" ++ ++import grp ++import pwd ++ ++ ++class CachedCall(object): ++ """Decorator for caching the results of function calls.""" ++ ++ def __init__(self, f): ++ self.cache = {} ++ self.f = f ++ ++ def __call__(self, *args): ++ try: ++ return self.cache[args] ++ except (KeyError, TypeError), e: ++ result = self.f(*args) ++ if not isinstance(e, TypeError): ++ # TypeError most likely means that args is not hashable ++ self.cache[args] = result ++ return result ++ ++ ++@CachedCall ++def getgrgid(gid): ++ return grp.getgrgid(gid) ++ ++ ++@CachedCall ++def getgrnam(name): ++ return grp.getgrnam(name) ++ ++ ++@CachedCall ++def getpwnam(name): ++ return pwd.getpwnam(name) ++ ++ ++@CachedCall ++def getpwuid(uid): ++ return pwd.getpwuid(uid) +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/path.py duplicity-0.6.18/duplicity/path.py +--- duplicity-0.6.18~/duplicity/path.py 2012-02-29 13:24:04.000000000 -0600 ++++ duplicity-0.6.18/duplicity/path.py 2012-11-14 10:38:11.539372820 -0600 +@@ -26,7 +26,7 @@ + + """ + +-import stat, errno, socket, time, re, gzip, pwd, grp ++import stat, errno, socket, time, re, gzip + + from duplicity import tarfile + from duplicity import file_naming +@@ -36,6 +36,7 @@ + from duplicity import librsync + from duplicity import log #@UnusedImport + from duplicity import dup_time ++from duplicity import cached_ops + from duplicity.lazy import * #@UnusedWildImport + + _copy_blocksize = 64 * 1024 +@@ -206,13 +207,13 @@ + try: + if globals.numeric_owner: + raise KeyError +- self.stat.st_uid = pwd.getpwnam(tarinfo.uname)[2] ++ self.stat.st_uid = cached_ops.getpwnam(tarinfo.uname)[2] + except KeyError: + self.stat.st_uid = tarinfo.uid + try: + if globals.numeric_owner: + raise KeyError +- self.stat.st_gid = grp.getgrnam(tarinfo.gname)[2] ++ self.stat.st_gid = cached_ops.getgrnam(tarinfo.gname)[2] + except KeyError: + self.stat.st_gid = tarinfo.gid + +@@ -284,11 +285,11 @@ + ti.mtime = int(self.stat.st_mtime) + + try: +- ti.uname = pwd.getpwuid(ti.uid)[0] ++ ti.uname = cached_ops.getpwuid(ti.uid)[0] + except KeyError: + ti.uname = '' + try: +- ti.gname = grp.getgrgid(ti.gid)[0] ++ ti.gname = cached_ops.getgrgid(ti.gid)[0] + except KeyError: + ti.gname = '' + +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/tarfile.py duplicity-0.6.18/duplicity/tarfile.py +--- duplicity-0.6.18~/duplicity/tarfile.py 2012-02-29 13:24:04.000000000 -0600 ++++ duplicity-0.6.18/duplicity/tarfile.py 2012-11-14 10:38:11.539372820 -0600 +@@ -53,10 +53,8 @@ + import re + import operator + +-try: +- import grp, pwd +-except ImportError: +- grp = pwd = None ++from duplicity import cached_ops ++grp = pwd = cached_ops + + # from tarfile import * + __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]