~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Robert Collins
  • Date: 2005-10-15 23:27:44 UTC
  • mfrom: (1456)
  • mto: This revision was merged to the branch mainline in revision 1457.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051015232744-be395943ade852d4
merge from integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
# TODO: Some kind of command-line display of revision properties: 
 
18
# perhaps show them in log -v and allow them as options to the commit command.
17
19
 
18
20
import bzrlib.errors
19
21
from bzrlib.graph import node_distances, select_farthest, all_descendants
 
22
from bzrlib.osutils import contains_whitespace
20
23
 
21
24
NULL_REVISION="null:"
22
25
 
31
34
 
32
35
    parent_ids
33
36
        List of parent revision_ids
 
37
 
 
38
    properties
 
39
        Dictionary of revision properties.  These are attached to the
 
40
        revision as extra metadata.  The name must be a single 
 
41
        word; the value can be an arbitrary string.
34
42
    """
35
43
    
36
 
    def __init__(self, revision_id, **args):
 
44
    def __init__(self, revision_id, properties=None, **args):
37
45
        self.revision_id = revision_id
 
46
        self.properties = properties or {}
 
47
        self._check_properties()
38
48
        self.__dict__.update(args)
39
49
        self.parent_ids = []
40
50
        self.parent_sha1s = []
52
62
                and self.timestamp == other.timestamp
53
63
                and self.message == other.message
54
64
                and self.timezone == other.timezone
55
 
                and self.committer == other.committer)
 
65
                and self.committer == other.committer
 
66
                and self.properties == other.properties)
56
67
 
57
68
    def __ne__(self, other):
58
69
        return not self.__eq__(other)
59
70
 
 
71
    def _check_properties(self):
 
72
        """Verify that all revision properties are OK.
 
73
        """
 
74
        for name, value in self.properties.iteritems():
 
75
            if not isinstance(name, basestring) or contains_whitespace(name):
 
76
                raise ValueError("invalid property name %r" % name)
 
77
            if not isinstance(value, basestring):
 
78
                raise ValueError("invalid property value %r for %r" % 
 
79
                                 (name, value))
 
80
 
60
81
 
61
82
def is_ancestor(revision_id, candidate_id, branch):
62
83
    """Return true if candidate_id is an ancestor of revision_id.