~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2009-11-28 21:54:08 UTC
  • mto: This revision was merged to the branch mainline in revision 4842.
  • Revision ID: john@arbash-meinel.com-20091128215408-d9jtxbxyiklmiurh
Add a static_tuple.as_tuples() helper.

It will pass over an iterable, and ensure that it and all children
are simple tuples. Useful for formatting.
Also fix a small bug in the reference checking code that assumes
the values passed in are the same type, but sometimes they are a
list rather than a tuple.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    lru_cache,
70
70
    pack,
71
71
    progress,
 
72
    static_tuple,
72
73
    trace,
73
74
    tsort,
74
75
    tuned_gzip,
2944
2945
        if not random_id:
2945
2946
            present_nodes = self._get_entries(keys)
2946
2947
            for (index, key, value, node_refs) in present_nodes:
 
2948
                parents = node_refs[:1]
 
2949
                # Sometimes these are passed as a list rather than a tuple
 
2950
                passed = static_tuple.as_tuples(keys[key])
 
2951
                passed_parents = passed([1][:1])
2947
2952
                if (value[0] != keys[key][0][0] or
2948
 
                    node_refs[:1] != keys[key][1][:1]):
 
2953
                    parents != passed_parents):
 
2954
                    node_refs = static_tuple.as_tuples(node_refs)
2949
2955
                    raise KnitCorrupt(self, "inconsistent details in add_records"
2950
 
                        ": %s %s" % ((value, node_refs), keys[key]))
 
2956
                        ": %s %s" % ((value, node_refs), passed))
2951
2957
                del keys[key]
2952
2958
        result = []
2953
2959
        if self._parents: