1 # Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 """Branch property access and caching."""
19 from bzrlib.errors import NoSuchRevision
20 from bzrlib.trace import mutter
23 from core import SubversionException
26 class PathPropertyProvider(object):
27 def __init__(self, log):
30 def get_properties(self, path, revnum):
31 """Obtain all the directory properties set on a path/revnum pair.
33 :param path: Subversion path
34 :param revnum: Subversion revision number
35 :return: Dictionary with properties
37 assert isinstance(path, str)
38 path = path.lstrip("/")
41 (_, _, props) = self.log._transport.get_dir(path,
43 except SubversionException, (_, num):
44 if num == constants.ERR_FS_NO_SUCH_REVISION:
45 raise NoSuchRevision(self, revnum)
50 def get_changed_properties(self, path, revnum):
51 """Get the contents of a Subversion file property.
55 :param path: Subversion path.
56 :param revnum: Subversion revision number.
57 :return: Contents of property or default if property didn't exist.
59 assert isinstance(revnum, int)
60 assert isinstance(path, str)
61 if not path in self.log.get_revision_paths(revnum):
63 current = self.get_properties(path, revnum)
66 (prev_path, prev_revnum) = self.log.get_previous(path, revnum)
67 if prev_path is None and prev_revnum == -1:
70 previous = self.get_properties(prev_path.encode("utf-8"),
73 for key, val in current.items():
74 if previous.get(key) != val: