/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: James Westby
  • Date: 2007-09-18 18:55:00 UTC
  • mto: (2866.1.1 james.westby)
  • mto: This revision was merged to the branch mainline in revision 2867.
  • Revision ID: jw+debian@jameswestby.net-20070918185500-91alkjx8zolds1v8
Fix log against smart server branches that don't support tags. (#140615)

Add get_reverse_tag_dict to DisabledTags for branches that falsely
claim that they support tags (namely smart server branches). When the
remote branch was an old format without tags this caused log to fail.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
from bzrlib.lazy_import import lazy_import
18
18
 
23
23
from StringIO import StringIO
24
24
 
25
25
from bzrlib import (
26
 
    errors,
27
26
    patiencediff,
28
27
    trace,
29
28
    ui,
30
29
    )
31
 
from bzrlib import bencode
 
30
from bzrlib.util import bencode
32
31
""")
33
32
from bzrlib.tuned_gzip import GzipFile
34
33
 
35
34
 
36
 
def topo_iter_keys(vf, keys=None):
37
 
    if keys is None:
38
 
        keys = vf.keys()
39
 
    parents = vf.get_parent_map(keys)
40
 
    return _topo_iter(parents, keys)
41
 
 
42
35
def topo_iter(vf, versions=None):
 
36
    seen = set()
 
37
    descendants = {}
43
38
    if versions is None:
44
39
        versions = vf.versions()
45
 
    parents = vf.get_parent_map(versions)
46
 
    return _topo_iter(parents, versions)
47
 
 
48
 
def _topo_iter(parents, versions):
49
 
    seen = set()
50
 
    descendants = {}
51
40
    def pending_parents(version):
52
 
        if parents[version] is None:
53
 
            return []
54
 
        return [v for v in parents[version] if v in versions and
 
41
        return [v for v in vf.get_parents(version) if v in versions and
55
42
                v not in seen]
56
43
    for version_id in versions:
57
 
        if parents[version_id] is None:
58
 
            # parentless
59
 
            continue
60
 
        for parent_id in parents[version_id]:
 
44
        for parent_id in vf.get_parents(version_id):
61
45
            descendants.setdefault(parent_id, []).append(version_id)
62
46
    cur = [v for v in versions if len(pending_parents(v)) == 0]
63
47
    while len(cur) > 0:
71
55
            yield version_id
72
56
            seen.add(version_id)
73
57
        cur = next
 
58
    assert len(seen) == len(versions)
74
59
 
75
60
 
76
61
class MultiParent(object):
208
193
            elif cur_line[0] == '\n':
209
194
                hunks[-1].lines[-1] += '\n'
210
195
            else:
211
 
                if not (cur_line[0] == 'c'):
212
 
                    raise AssertionError(cur_line[0])
 
196
                assert cur_line[0] == 'c', cur_line[0]
213
197
                parent, parent_pos, child_pos, num_lines =\
214
198
                    [int(v) for v in cur_line.split(' ')[1:]]
215
199
                hunks.append(ParentText(parent, parent_pos, child_pos,
290
274
            ' %(num_lines)r)' % self.__dict__
291
275
 
292
276
    def __eq__(self, other):
293
 
        if self.__class__ is not other.__class__:
 
277
        if self.__class__ != other.__class__:
294
278
            return False
295
279
        return (self.__dict__ == other.__dict__)
296
280
 
316
300
        return version in self._parents
317
301
 
318
302
    def do_snapshot(self, version_id, parent_ids):
319
 
        """Determine whether to perform a snapshot for this version"""
 
303
        """Determine whether to perform a a snapshot for this version"""
320
304
        if self.snapshot_interval is None:
321
305
            return False
322
306
        if self.max_snapshots is not None and\
384
368
        :param single_parent: If true, omit all but one parent text, (but
385
369
            retain parent metadata).
386
370
        """
387
 
        if not (no_cache or not verify):
388
 
            raise ValueError()
 
371
        assert no_cache or not verify
389
372
        revisions = set(vf.versions())
390
373
        total = len(revisions)
391
374
        pb = ui.ui_factory.nested_progress_bar()
397
380
                    if [p for p in parents if p not in self._parents] != []:
398
381
                        continue
399
382
                    lines = [a + ' ' + l for a, l in
400
 
                             vf.annotate(revision)]
 
383
                             vf.annotate_iter(revision)]
401
384
                    if snapshots is None:
402
385
                        force_snapshot = None
403
386
                    else:
409
392
                        self.clear_cache()
410
393
                        vf.clear_cache()
411
394
                        if verify:
412
 
                            if not (lines == self.get_line_list([revision])[0]):
413
 
                                raise AssertionError()
 
395
                            assert lines == self.get_line_list([revision])[0]
414
396
                            self.clear_cache()
415
397
                    pb.update('Importing revisions',
416
398
                              (total - len(revisions)) + len(added), total)
526
508
        self._parents[version_id] = parent_ids
527
509
 
528
510
    def get_diff(self, version_id):
529
 
        try:
530
 
            return self._diffs[version_id]
531
 
        except KeyError:
532
 
            raise errors.RevisionNotPresent(version_id, self)
 
511
        return self._diffs[version_id]
533
512
 
534
513
    def destroy(self):
535
514
        self._diffs = {}
561
540
    def add_diff(self, diff, version_id, parent_ids):
562
541
        outfile = open(self._filename + '.mpknit', 'ab')
563
542
        try:
564
 
            outfile.seek(0, 2)      # workaround for windows bug:
565
 
                                    # .tell() for files opened in 'ab' mode
566
 
                                    # before any write returns 0
567
543
            start = outfile.tell()
568
544
            try:
569
545
                zipfile = GzipFile(None, mode='ab', fileobj=outfile)