~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2007-12-01 19:21:10 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20071201192110-o54tcvts81x1st6q
Use dotted revnos in graph-ancestry

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
            self.common = []
127
127
 
128
128
        self.n_history = branch.revision_history()
 
129
        self.n_revnos = branch.get_revision_id_to_revno_map()
129
130
        self.distances = node_distances(self.descendants, self.ancestors,
130
131
                                        self.root)
131
132
        if other_branch is not None:
132
133
            self.base = select_farthest(self.distances, self.common)
133
134
            self.m_history = other_branch.revision_history()
 
135
            self.m_revnos = other_branch.get_revision_id_to_revno_map()
134
136
            new_graph = getattr(branch.repository, 'get_graph', lambda: None)()
135
137
            if new_graph is None:
136
138
                self.new_base = None
144
146
            self.new_base = None
145
147
            self.lcas = set()
146
148
            self.m_history = []
 
149
            self.m_revnos = {}
 
150
 
 
151
    @staticmethod
 
152
    def _get_revno_str(prefix, revno_map, revision_id):
 
153
        try:
 
154
            revno = revno_map[revision_id]
 
155
        except KeyError:
 
156
            return None
 
157
        return '%s%s' % (prefix, '.'.join(str(n) for n in revno))
147
158
 
148
159
    def dot_node(self, node, num):
149
160
        try:
155
166
        except ValueError:
156
167
            m_rev = None
157
168
        if (n_rev, m_rev) == (None, None):
158
 
            name = node[-5:]
 
169
            name = self._get_revno_str('r', self.n_revnos, node)
 
170
            if name is None:
 
171
                name = self._get_revno_str('R', self.m_revnos, node)
 
172
            if name is None:
 
173
                name = node[-5:]
159
174
            cluster = None
160
175
        elif n_rev == m_rev:
161
176
            name = "rR%d" % n_rev