~bzr/ubuntu/maverick/bzr-svn/bzr-ppa

« back to all changes in this revision

Viewing changes to branchprops.py

  • Committer: Jelmer Vernooij
  • Date: 2008-05-11 19:29:26 UTC
  • mfrom: (220.36.144 0.4)
  • Revision ID: jelmer@samba.org-20080511192926-7mh02j45r25qmzkz
Merge 0.4 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
 
5
# the Free Software Foundation; either version 3 of the License, or
6
6
# (at your option) any later version.
7
7
 
8
8
# This program is distributed in the hope that it will be useful,
19
19
from bzrlib.errors import NoSuchRevision
20
20
from bzrlib.trace import mutter
21
21
 
22
 
from svn.core import SubversionException, Pool
 
22
from svn.core import SubversionException
23
23
import svn.core
24
24
 
25
25
 
26
 
class PathPropertyProvider:
 
26
class PathPropertyProvider(object):
27
27
    def __init__(self, log):
28
28
        self.log = log
29
29
 
38
38
        path = path.lstrip("/")
39
39
 
40
40
        try:
41
 
            (_, _, props) = self.log._get_transport().get_dir(path, 
 
41
            (_, _, props) = self.log._transport.get_dir(path, 
42
42
                revnum)
43
43
        except SubversionException, (_, num):
44
44
            if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
58
58
        """
59
59
        assert isinstance(revnum, int)
60
60
        assert isinstance(path, str)
61
 
        if not self.log.touches_path(path, revnum):
 
61
        if not path in self.log.get_revision_paths(revnum):
62
62
            return {}
63
63
        current = self.get_properties(path, revnum)
64
64
        if current == {}:
74
74
            if previous.get(key) != val:
75
75
                ret[key] = val
76
76
        return ret
77
 
 
78
 
    def get_property_diff(self, path, revnum, name):
79
 
        """Returns the new lines that were added to a particular property."""
80
 
        assert isinstance(path, str)
81
 
        # If the path this property is set on didn't change, then 
82
 
        # the property can't have changed.
83
 
        if not self.log.touches_path(path, revnum):
84
 
            return ""
85
 
 
86
 
        current = self.get_properties(path, revnum).get(name, "")
87
 
        (prev_path, prev_revnum) = self.log.get_previous(path, revnum)
88
 
        if prev_path is None and prev_revnum == -1:
89
 
            previous = ""
90
 
        else:
91
 
            previous = self.get_properties(prev_path.encode("utf-8"), prev_revnum).get(name, "")
92
 
        if len(previous) > len(current) or current[0:len(previous)] != previous:
93
 
            mutter('original part changed for %r between %s:%d -> %s:%d' % (name, prev_path, prev_revnum, path, revnum))
94
 
            return ""
95
 
        return current[len(previous):] 
96