~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Mattias Eriksson
  • Date: 2009-06-02 09:18:26 UTC
  • mto: This revision was merged to the branch mainline in revision 4398.
  • Revision ID: snaggen@acc.umu.se-20090602091826-r55iaxfwy9fn1up3
Fix to avoid possible race conditions if import ordering is changed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        self.mapping = mapping
120
120
 
121
121
 
 
122
def show_foreign_properties(rev):
 
123
    """Custom log displayer for foreign revision identifiers.
 
124
 
 
125
    :param rev: Revision object.
 
126
    """
 
127
    # Revision comes directly from a foreign repository
 
128
    if isinstance(rev, ForeignRevision):
 
129
        return rev.mapping.vcs.show_foreign_revid(rev.foreign_revid)
 
130
 
 
131
    # Revision was once imported from a foreign repository
 
132
    try:
 
133
        foreign_revid, mapping = \
 
134
            foreign_vcs_registry.parse_revision_id(rev.revision_id)
 
135
    except errors.InvalidRevisionId:
 
136
        return {}
 
137
 
 
138
    return mapping.vcs.show_foreign_revid(foreign_revid)
 
139
 
 
140
 
122
141
class ForeignVcs(object):
123
142
    """A foreign version control system."""
124
143
 
160
179
        :param revid: The bzr revision id
161
180
        :return: tuple with foreign revid and vcs mapping
162
181
        """
163
 
        if not ":" in revid or not "-" in revid:
 
182
        if not "-" in revid:
164
183
            raise errors.InvalidRevisionId(revid, None)
165
184
        try:
166
185
            foreign_vcs = self.get(revid.split("-")[0])