~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Robert Collins
  • Date: 2005-10-08 00:39:04 UTC
  • mfrom: (1185.1.52)
  • Revision ID: robertc@robertcollins.net-20051008003904-aaffaea2778efe3e
merge in martins reweave, integrated to fetch, and a bugfix for commit and upgrade with executable files

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.
19
17
 
20
18
import bzrlib.errors
21
19
from bzrlib.graph import node_distances, select_farthest, all_descendants
22
 
from bzrlib.osutils import contains_whitespace
23
20
 
24
21
NULL_REVISION="null:"
25
22
 
34
31
 
35
32
    parent_ids
36
33
        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.
42
34
    """
43
35
    
44
 
    def __init__(self, revision_id, properties=None, **args):
 
36
    def __init__(self, revision_id, **args):
45
37
        self.revision_id = revision_id
46
 
        self.properties = properties or {}
47
 
        self._check_properties()
48
38
        self.__dict__.update(args)
49
39
        self.parent_ids = []
50
40
        self.parent_sha1s = []
62
52
                and self.timestamp == other.timestamp
63
53
                and self.message == other.message
64
54
                and self.timezone == other.timezone
65
 
                and self.committer == other.committer
66
 
                and self.properties == other.properties)
 
55
                and self.committer == other.committer)
67
56
 
68
57
    def __ne__(self, other):
69
58
        return not self.__eq__(other)
70
59
 
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))
 
60
        
 
61
REVISION_ID_RE = None
 
62
 
 
63
def validate_revision_id(rid):
 
64
    """Check rid is syntactically valid for a revision id."""
 
65
    global REVISION_ID_RE
 
66
    if not REVISION_ID_RE:
 
67
        import re
 
68
        REVISION_ID_RE = re.compile('[\w:.-]+@[\w%.-]+--?[\w]+--?[0-9a-f]+\Z')
 
69
 
 
70
    if not REVISION_ID_RE.match(rid):
 
71
        raise ValueError("malformed revision-id %r" % rid)
80
72
 
81
73
 
82
74
def is_ancestor(revision_id, candidate_id, branch):