~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-04 14:00:29 UTC
  • mto: (1711.2.74 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1837.
  • Revision ID: john@arbash-meinel.com-20060704140029-f7d23145ea05d75a
Add emacs ignores, remove old ignores

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/python
2
2
 
3
3
# Copyright (C) 2005 Canonical Ltd
4
 
#
 
4
 
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
#
 
9
 
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
14
 
#
 
14
 
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
75
75
import time
76
76
import warnings
77
77
 
78
 
from bzrlib import (
79
 
    progress,
80
 
    )
81
78
from bzrlib.trace import mutter
82
79
from bzrlib.errors import (WeaveError, WeaveFormatError, WeaveParentMismatch,
83
80
        RevisionAlreadyPresent,
247
244
 
248
245
    def _lookup(self, name):
249
246
        """Convert symbolic version name to index."""
250
 
        self.check_not_reserved_id(name)
251
247
        try:
252
248
            return self._name_map[name]
253
249
        except KeyError:
269
265
 
270
266
    def has_version(self, version_id):
271
267
        """See VersionedFile.has_version."""
272
 
        return (version_id in self._name_map)
 
268
        return self._name_map.has_key(version_id)
273
269
 
274
270
    __contains__ = has_version
275
271
 
607
603
        else:
608
604
            return self.get_ancestry(version_ids)
609
605
 
610
 
    def get_ancestry(self, version_ids, topo_sorted=True):
 
606
    def get_ancestry(self, version_ids):
611
607
        """See VersionedFile.get_ancestry."""
612
608
        if isinstance(version_ids, basestring):
613
609
            version_ids = [version_ids]
641
637
        """
642
638
        return len(other_parents.difference(my_parents)) == 0
643
639
 
 
640
    def annotate(self, version_id):
 
641
        if isinstance(version_id, int):
 
642
            warnings.warn('Weave.annotate(int) is deprecated. Please use version names'
 
643
                 ' in all circumstances as of 0.8',
 
644
                 DeprecationWarning,
 
645
                 stacklevel=2
 
646
                 )
 
647
            result = []
 
648
            for origin, lineno, text in self._extract([version_id]):
 
649
                result.append((origin, text))
 
650
            return result
 
651
        else:
 
652
            return super(Weave, self).annotate(version_id)
 
653
    
644
654
    def annotate_iter(self, version_id):
645
655
        """Yield list of (version-id, line) pairs for the specified version.
646
656
 
654
664
        """_walk has become visit, a supported api."""
655
665
        return self._walk_internal()
656
666
 
657
 
    def iter_lines_added_or_present_in_versions(self, version_ids=None,
658
 
                                                pb=None):
 
667
    def iter_lines_added_or_present_in_versions(self, version_ids=None):
659
668
        """See VersionedFile.iter_lines_added_or_present_in_versions()."""
660
669
        if version_ids is None:
661
670
            version_ids = self.versions()
1107
1116
 
1108
1117
    def _add_lines(self, version_id, parents, lines, parent_texts):
1109
1118
        """Add a version and save the weave."""
1110
 
        self.check_not_reserved_id(version_id)
1111
1119
        result = super(WeaveFile, self)._add_lines(version_id, parents, lines,
1112
1120
                                                   parent_texts)
1113
1121
        self._save()
1124
1132
        sio = StringIO()
1125
1133
        write_weave_v5(self, sio)
1126
1134
        sio.seek(0)
1127
 
        transport.put_file(name + WeaveFile.WEAVE_SUFFIX, sio, self._filemode)
 
1135
        transport.put(name + WeaveFile.WEAVE_SUFFIX, sio, self._filemode)
1128
1136
 
1129
1137
    def create_empty(self, name, transport, filemode=None):
1130
1138
        return WeaveFile(name, transport, filemode, create=True)
1135
1143
        sio = StringIO()
1136
1144
        write_weave_v5(self, sio)
1137
1145
        sio.seek(0)
1138
 
        self._transport.put_file(self._weave_name + WeaveFile.WEAVE_SUFFIX,
1139
 
                                 sio,
1140
 
                                 self._filemode)
 
1146
        self._transport.put(self._weave_name + WeaveFile.WEAVE_SUFFIX,
 
1147
                            sio,
 
1148
                            self._filemode)
1141
1149
 
1142
1150
    @staticmethod
1143
1151
    def get_suffixes():