~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
    count_copied -- number of revisions copied
79
79
    count_weaves -- number of file weaves copied
80
80
    """
81
 
    def __init__(self, to_repository, from_repository, last_revision=NULL_REVISION, pb=None):
 
81
    def __init__(self, to_repository, from_repository, last_revision=None, pb=None):
82
82
        if to_repository.bzrdir.transport.base == from_repository.bzrdir.transport.base:
83
83
            raise Exception("can't fetch from a repository to itself %s, %s" % 
84
84
                            (from_repository.bzrdir.transport.base,
130
130
 
131
131
    def _revids_to_fetch(self):
132
132
        mutter('fetch up to rev {%s}', self._last_revision)
133
 
        if self._last_revision is None:
134
 
            # explicit limit of None
 
133
        if self._last_revision is NULL_REVISION:
 
134
            # explicit limit of no revisions needed
135
135
            return None
136
 
        if (self._last_revision != NULL_REVISION and
 
136
        if (self._last_revision != None and
137
137
            self.to_repository.has_revision(self._last_revision)):
138
138
            return None
139
139
            
140
140
        try:
141
 
            if self._last_revision is NULL_REVISION:
142
 
                branch_from_revs = set(self.from_repository.all_revision_ids() +
143
 
                                       [None])
144
 
            else:
145
 
                branch_from_revs = set(
146
 
                    self.from_repository.get_ancestry(self._last_revision))
 
141
            return self.to_repository.missing_revision_ids(self.from_repository,
 
142
                                                           self._last_revision)
147
143
        except errors.NoSuchRevision:
148
144
            raise InstallFailed([self._last_revision])
149
145
 
150
 
        branch_to_revs = set(self.to_repository.all_revision_ids() + [None])
151
 
        return branch_from_revs.difference(branch_to_revs)
152
 
 
153
146
    def _fetch_revision_texts(self, revs):
154
147
        self.to_repository.revision_store.copy_multi(
155
148
            self.from_repository.revision_store,
276
269
            self._last_revision = from_history[-1]
277
270
        else:
278
271
            # no history in the source branch
279
 
            self._last_revision = None
 
272
            self._last_revision = NULL_REVISION
280
273
 
281
274
fetch = Fetcher