/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/foreign.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-02 09:21:20 UTC
  • mfrom: (4396 +trunk)
  • mto: (4396.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4397.
  • Revision ID: v.ladeuil+lp@free.fr-20090602092120-xs1ikguqckiu820o
Merge bzr.dev

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
 
 
141
122
class ForeignVcs(object):
142
123
    """A foreign version control system."""
143
124
 
179
160
        :param revid: The bzr revision id
180
161
        :return: tuple with foreign revid and vcs mapping
181
162
        """
182
 
        if not "-" in revid:
 
163
        if not ":" in revid or not "-" in revid:
183
164
            raise errors.InvalidRevisionId(revid, None)
184
165
        try:
185
166
            foreign_vcs = self.get(revid.split("-")[0])
282
263
 
283
264
 
284
265
class cmd_dpush(Command):
285
 
    """Push into a foreign VCS without any custom bzr metadata.
 
266
    """Push into a different VCS without any custom bzr metadata.
286
267
 
287
 
    This will afterwards rebase the local Bazaar branch on the remote
 
268
    This will afterwards rebase the local branch on the remote
288
269
    branch unless the --no-rebase option is used, in which case 
289
270
    the two branches will be out of sync after the push. 
290
271
    """
329
310
        target_branch.lock_write()
330
311
        try:
331
312
            try:
332
 
                revid_map = source_branch.lossy_push(target_branch)
 
313
                push_result = source_branch.lossy_push(target_branch)
333
314
            except errors.LossyPushToSameVCS:
334
 
                raise BzrCommandError("%r is not a foreign branch, use regular "
335
 
                                      "push." % target_branch)
 
315
                raise BzrCommandError("%r and %r are in the same VCS, lossy "
 
316
                    "push not necessary. Please use regular push." %
 
317
                    (source_branch, target_branch))
336
318
            # We successfully created the target, remember it
337
319
            if source_branch.get_push_location() is None or remember:
338
320
                source_branch.set_push_location(target_branch.base)
348
330
                        update_workingtree_fileids(source_wt, target)
349
331
                    finally:
350
332
                        source_wt.unlock()
 
333
            push_result.report(self.outf)
351
334
        finally:
352
335
            target_branch.unlock()
353
336
 
364
347
 
365
348
        :param target: Target branch
366
349
        :param stop_revision: Revision to push, defaults to last revision.
367
 
        :return: Dictionary mapping revision ids from the target branch 
 
350
        :return: BranchPushResult with an extra member revidmap: 
 
351
            A dictionary mapping revision ids from the target branch 
368
352
            to new revision ids in the target branch, for each 
369
353
            revision that was pushed.
370
354
        """