/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.910 by Jelmer Vernooij
update copyright years
1
# Copyright (C) 2009-2010 Jelmer Vernooij <jelmer@samba.org>
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Push implementation that simply prints message saying push is not supported."""
18
0.200.1347 by Jelmer Vernooij
Provide search_missing_revisions.
19
from dulwich.objects import ZERO_SHA
20
from dulwich.walk import Walker
21
0.200.357 by Jelmer Vernooij
Move push code to push.py.
22
from bzrlib import (
0.200.598 by Jelmer Vernooij
Cope with ghosts.
23
    errors,
0.200.357 by Jelmer Vernooij
Move push code to push.py.
24
    ui,
25
    )
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
26
from bzrlib.repository import (
27
    InterRepository,
28
    )
0.200.371 by Jelmer Vernooij
Add progress bar when determining revisions to dpush
29
from bzrlib.revision import (
30
    NULL_REVISION,
31
    )
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
32
33
from bzrlib.plugins.git.errors import (
34
    NoPushSupport,
35
    )
0.200.456 by Jelmer Vernooij
Fix git -> git fetching.
36
from bzrlib.plugins.git.object_store import (
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
37
    get_object_store,
0.200.456 by Jelmer Vernooij
Fix git -> git fetching.
38
    )
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
39
from bzrlib.plugins.git.repository import (
40
    GitRepository,
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
41
    LocalGitRepository,
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
42
    GitRepositoryFormat,
43
    )
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
44
from bzrlib.plugins.git.remote import (
45
    RemoteGitRepository,
46
    )
0.200.1292 by Jelmer Vernooij
Fix repeeling objects when determining what to send.
47
from bzrlib.plugins.git.unpeel_map import (
0.200.1065 by Jelmer Vernooij
Don't peel tags automatically when pushing back.
48
    UnpeelMap,
0.200.1061 by Jelmer Vernooij
Add support for using unpeel map.
49
    )
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
50
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
51
52
class MissingObjectsIterator(object):
53
    """Iterate over git objects that are missing from a target repository.
54
55
    """
56
0.200.525 by Jelmer Vernooij
Simplify push a bit further, make dpush without rebase faster.
57
    def __init__(self, store, source, pb=None):
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
58
        """Create a new missing objects iterator.
59
60
        """
61
        self.source = source
0.200.525 by Jelmer Vernooij
Simplify push a bit further, make dpush without rebase faster.
62
        self._object_store = store
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
63
        self._pending = []
0.200.369 by Jelmer Vernooij
Report on pack objects progress.
64
        self.pb = pb
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
65
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
66
    def import_revisions(self, revids, lossy):
0.200.947 by Jelmer Vernooij
Add convenience method for getting missing objects iterator.
67
        """Import a set of revisions into this git repository.
68
69
        :param revids: Revision ids of revisions to import
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
70
        :param lossy: Whether to not roundtrip bzr metadata
0.200.947 by Jelmer Vernooij
Add convenience method for getting missing objects iterator.
71
        """
0.200.369 by Jelmer Vernooij
Report on pack objects progress.
72
        for i, revid in enumerate(revids):
73
            if self.pb:
74
                self.pb.update("pushing revisions", i, len(revids))
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
75
            git_commit = self.import_revision(revid, lossy)
0.252.6 by Jelmer Vernooij
Roundtripping support for revision ids works.
76
            yield (revid, git_commit)
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
77
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
78
    def import_revision(self, revid, lossy):
0.200.947 by Jelmer Vernooij
Add convenience method for getting missing objects iterator.
79
        """Import a revision into this Git repository.
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
80
0.200.947 by Jelmer Vernooij
Add convenience method for getting missing objects iterator.
81
        :param revid: Revision id of the revision
82
        :param roundtrip: Whether to roundtrip bzr metadata
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
83
        """
0.200.852 by Jelmer Vernooij
Cache trees rather than inventories.
84
        tree = self._object_store.tree_cache.revision_tree(revid)
0.200.548 by Jelmer Vernooij
Extract unusual file modes from revision when reconstructing Trees.
85
        rev = self.source.get_revision(revid)
0.200.784 by Jelmer Vernooij
Use common object generation code in push.
86
        commit = None
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
87
        for path, obj, ie in self._object_store._revision_to_objects(rev, tree, lossy):
0.200.829 by Jelmer Vernooij
Cope with the fact that _type is gone in upstream dulwich.
88
            if obj.type_name == "commit":
0.200.784 by Jelmer Vernooij
Use common object generation code in push.
89
                commit = obj
0.200.786 by Jelmer Vernooij
Simplify push code.
90
            self._pending.append((obj, path))
0.200.1482 by Jelmer Vernooij
Add extra assertion.
91
        if commit is None:
92
            raise AssertionError("no commit object generated for revision %s" %
93
                revid)
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
94
        return commit.id
95
96
    def __len__(self):
97
        return len(self._pending)
98
99
    def __iter__(self):
0.200.786 by Jelmer Vernooij
Simplify push code.
100
        return iter(self._pending)
0.200.364 by Jelmer Vernooij
Reimplement dpush, but more efficient and only writing a single pack file rather than one per revision.
101
102
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
103
class InterToGitRepository(InterRepository):
104
    """InterRepository that copies into a Git repository."""
105
106
    _matching_repo_format = GitRepositoryFormat()
107
0.200.435 by Jelmer Vernooij
Remember mapping per InterRepository.
108
    def __init__(self, source, target):
109
        super(InterToGitRepository, self).__init__(source, target)
110
        self.mapping = self.target.get_mapping()
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
111
        self.source_store = get_object_store(self.source, self.mapping)
0.200.435 by Jelmer Vernooij
Remember mapping per InterRepository.
112
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
113
    @staticmethod
114
    def _get_repo_format_to_test():
115
        return None
116
117
    def copy_content(self, revision_id=None, pb=None):
118
        """See InterRepository.copy_content."""
119
        self.fetch(revision_id, pb, find_ghosts=False)
120
0.200.1323 by Jelmer Vernooij
Simplify push handling.
121
    def fetch_refs(self, update_refs, lossy):
122
        """Fetch possibly roundtripped revisions into the target repository
123
        and update refs.
0.200.943 by Jelmer Vernooij
Add stubs.
124
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
125
        :param update_refs: Generate refs to fetch. Receives dictionary
126
            with old refs (git shas), returns dictionary of new names to
0.200.943 by Jelmer Vernooij
Add stubs.
127
            git shas.
0.200.1323 by Jelmer Vernooij
Simplify push handling.
128
        :param lossy: Whether to roundtrip
0.200.943 by Jelmer Vernooij
Add stubs.
129
        :return: old refs, new refs
130
        """
131
        raise NotImplementedError(self.fetch_refs)
132
0.200.1347 by Jelmer Vernooij
Provide search_missing_revisions.
133
    def search_missing_revision_ids(self,
134
            find_ghosts=True, revision_ids=None, if_present_ids=None,
135
            limit=None):
136
        git_shas = []
137
        todo = []
138
        if revision_ids:
139
            todo.extend(revision_ids)
140
        if if_present_ids:
141
            todo.extend(revision_ids)
142
        self.source_store.lock_read()
143
        try:
144
            for revid in revision_ids:
145
                if revid == NULL_REVISION:
146
                    continue
147
                git_sha = self.source_store._lookup_revision_sha1(revid)
148
                git_shas.append(git_sha)
149
            walker = Walker(self.source_store,
0.200.1493 by Jelmer Vernooij
Test fixes.
150
                include=git_shas, exclude=[sha for sha in self.target.bzrdir.get_refs_container().as_dict().values() if sha != ZERO_SHA])
0.200.1347 by Jelmer Vernooij
Provide search_missing_revisions.
151
            missing_revids = set()
152
            for entry in walker:
0.200.1354 by Jelmer Vernooij
Fix re-looking up of revision ids.
153
                for (kind, type_data) in self.source_store.lookup_git_sha(entry.commit.id):
154
                    if kind == "commit":
155
                        missing_revids.add(type_data[0])
0.200.1347 by Jelmer Vernooij
Provide search_missing_revisions.
156
        finally:
157
            self.source_store.unlock()
158
        return self.source.revision_ids_to_search_result(missing_revids)
159
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
160
161
class InterToLocalGitRepository(InterToGitRepository):
0.200.966 by Jelmer Vernooij
Some more docstrings.
162
    """InterBranch implementation between a Bazaar and a Git repository."""
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
163
0.252.3 by Jelmer Vernooij
Refactor revision finding code.
164
    def __init__(self, source, target):
165
        super(InterToLocalGitRepository, self).__init__(source, target)
0.200.1434 by Jelmer Vernooij
Move refs access to control dir.
166
        self.target_store = self.target.bzrdir._git.object_store
167
        self.target_refs = self.target.bzrdir._git.refs
0.252.3 by Jelmer Vernooij
Refactor revision finding code.
168
0.200.1424 by Jelmer Vernooij
Fix determining revisions to fetch when fetching to git repo.
169
    def _commit_needs_fetching(self, sha_id):
170
        try:
171
            return (sha_id not in self.target_store)
172
        except errors.NoSuchRevision:
173
            # Ghost, can't push
174
            return False
175
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
176
    def _revision_needs_fetching(self, sha_id, revid):
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
177
        if revid == NULL_REVISION:
178
            return False
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
179
        if sha_id is None:
180
            try:
181
                sha_id = self.source_store._lookup_revision_sha1(revid)
182
            except KeyError:
183
                return False
0.200.1424 by Jelmer Vernooij
Fix determining revisions to fetch when fetching to git repo.
184
        return self._commit_needs_fetching(sha_id)
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
185
186
    def missing_revisions(self, stop_revisions):
0.200.966 by Jelmer Vernooij
Some more docstrings.
187
        """Find the revisions that are missing from the target repository.
188
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
189
        :param stop_revisions: Revisions to check for (tuples with
0.200.1030 by Jelmer Vernooij
More work on supporting roundtripping push.
190
            Git SHA1, bzr revid)
0.200.966 by Jelmer Vernooij
Some more docstrings.
191
        :return: sequence of missing revisions, in topological order
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
192
        :raise: NoSuchRevision if the stop_revisions are not present in
193
            the source
0.200.966 by Jelmer Vernooij
Some more docstrings.
194
        """
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
195
        revid_sha_map = {}
196
        stop_revids = []
197
        for (sha1, revid) in stop_revisions:
198
            if sha1 is not None and revid is not None:
199
                revid_sha_map[revid] = sha1
0.200.1424 by Jelmer Vernooij
Fix determining revisions to fetch when fetching to git repo.
200
                stop_revids.append(revid)
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
201
            elif sha1 is not None:
0.200.1424 by Jelmer Vernooij
Fix determining revisions to fetch when fetching to git repo.
202
                if self._commit_needs_fetching(sha1):
203
                    for (kind, (revid, tree_sha, verifiers)) in self.source_store.lookup_git_sha(sha1):
204
                        revid_sha_map[revid] = sha1
205
                        stop_revids.append(revid)
0.200.1036 by Jelmer Vernooij
More work on roundtrip push support.
206
            else:
207
                assert revid is not None
208
                stop_revids.append(revid)
0.200.1474 by Jelmer Vernooij
Cope with refs when pushing.
209
        missing = set()
0.252.43 by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas.
210
        graph = self.source.get_graph()
0.200.371 by Jelmer Vernooij
Add progress bar when determining revisions to dpush
211
        pb = ui.ui_factory.nested_progress_bar()
212
        try:
0.200.1474 by Jelmer Vernooij
Cope with refs when pushing.
213
            while stop_revids:
214
                new_stop_revids = []
215
                for revid in stop_revids:
216
                    sha1 = revid_sha_map.get(revid)
217
                    if (not revid in missing and
218
                        self._revision_needs_fetching(sha1, revid)):
219
                        missing.add(revid)
220
                        new_stop_revids.append(revid)
221
                stop_revids = set()
222
                parent_map = graph.get_parent_map(new_stop_revids)
223
                for parent_revids in parent_map.itervalues():
224
                    stop_revids.update(parent_revids)
0.200.371 by Jelmer Vernooij
Add progress bar when determining revisions to dpush
225
                pb.update("determining revisions to fetch", len(missing))
226
        finally:
227
            pb.finished()
0.252.43 by Jelmer Vernooij
Some refactoring, support proper file ids in revision deltas.
228
        return graph.iter_topo_order(missing)
0.200.357 by Jelmer Vernooij
Move push code to push.py.
229
0.200.969 by Jelmer Vernooij
Use tuples with bzr revid and git sha to avoid lookups.
230
    def _get_target_bzr_refs(self):
231
        """Return a dictionary with references.
232
233
        :return: Dictionary with reference names as keys and tuples
234
            with Git SHA, Bazaar revid as values.
235
        """
236
        bzr_refs = {}
0.263.1 by Jelmer Vernooij
Fix dpush for certain branches.
237
        refs = {}
238
        for k in self.target._git.refs.allkeys():
239
            v = self.target._git.refs.read_ref(k)
0.200.1180 by Jelmer Vernooij
Some dpush fixes.
240
            try:
241
                for (kind, type_data) in self.source_store.lookup_git_sha(v):
0.200.1181 by Jelmer Vernooij
Simplify dfetch_refs for local git repositories.
242
                    if kind == "commit" and self.source.has_revision(type_data[0]):
0.200.1180 by Jelmer Vernooij
Some dpush fixes.
243
                        revid = type_data[0]
0.200.1181 by Jelmer Vernooij
Simplify dfetch_refs for local git repositories.
244
                        break
245
                else:
246
                    revid = None
0.200.1180 by Jelmer Vernooij
Some dpush fixes.
247
            except KeyError:
248
                revid = None
0.200.969 by Jelmer Vernooij
Use tuples with bzr revid and git sha to avoid lookups.
249
            bzr_refs[k] = (v, revid)
250
        return bzr_refs
251
0.200.1323 by Jelmer Vernooij
Simplify push handling.
252
    def fetch_refs(self, update_refs, lossy):
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
253
        if not lossy and not self.mapping.roundtripping:
254
            raise NoPushSupport()
0.200.1323 by Jelmer Vernooij
Simplify push handling.
255
        self.source_store.lock_read()
256
        try:
257
            old_refs = self._get_target_bzr_refs()
258
            new_refs = update_refs(old_refs)
0.200.1422 by Jelmer Vernooij
Remove unused dfetch method.
259
            revidmap = self.fetch_objects(
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
260
                [(git_sha, bzr_revid) for (git_sha, bzr_revid) in new_refs.values() if git_sha is None or not git_sha.startswith('ref:')], lossy=lossy)
0.200.969 by Jelmer Vernooij
Use tuples with bzr revid and git sha to avoid lookups.
261
            for name, (gitid, revid) in new_refs.iteritems():
0.200.1182 by Jelmer Vernooij
Fix local dpush.
262
                if gitid is None:
263
                    try:
0.200.1323 by Jelmer Vernooij
Simplify push handling.
264
                        gitid = revidmap[revid][0]
0.200.1182 by Jelmer Vernooij
Fix local dpush.
265
                    except KeyError:
266
                        gitid = self.source_store._lookup_revision_sha1(revid)
0.200.1400 by Jelmer Vernooij
Cope with ref: refs.
267
                assert len(gitid) == 40 or gitid.startswith('ref: ')
0.200.1182 by Jelmer Vernooij
Fix local dpush.
268
                self.target_refs[name] = gitid
0.200.969 by Jelmer Vernooij
Use tuples with bzr revid and git sha to avoid lookups.
269
        finally:
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
270
            self.source_store.unlock()
0.200.822 by Jelmer Vernooij
Fix indication of number of revisions pushed in dpush.
271
        return revidmap, old_refs, new_refs
0.200.428 by Jelmer Vernooij
use dfetch_refs, to prepare for dpush to remote repositories.
272
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
273
    def fetch_objects(self, revs, lossy):
274
        if not lossy and not self.mapping.roundtripping:
275
            raise NoPushSupport()
0.200.1493 by Jelmer Vernooij
Test fixes.
276
        self.source_store.lock_read()
0.200.1323 by Jelmer Vernooij
Simplify push handling.
277
        try:
0.200.1493 by Jelmer Vernooij
Test fixes.
278
            todo = list(self.missing_revisions(revs))
279
            revidmap = {}
280
            pb = ui.ui_factory.nested_progress_bar()
281
            try:
282
                object_generator = MissingObjectsIterator(
283
                    self.source_store, self.source, pb)
284
                for (old_revid, git_sha) in object_generator.import_revisions(
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
285
                    todo, lossy=lossy):
286
                    if lossy:
0.200.1493 by Jelmer Vernooij
Test fixes.
287
                        new_revid = self.mapping.revision_id_foreign_to_bzr(git_sha)
288
                    else:
289
                        new_revid = old_revid
0.275.1 by Jelmer Vernooij
Use root_inventory.
290
                        try:
291
                            self.mapping.revision_id_bzr_to_foreign(old_revid)
292
                        except errors.InvalidRevisionId:
293
                            refname = self.mapping.revid_as_refname(old_revid)
294
                            self.target_refs[refname] = git_sha
0.200.1493 by Jelmer Vernooij
Test fixes.
295
                    revidmap[old_revid] = (git_sha, new_revid)
296
                self.target_store.add_objects(object_generator)
297
                return revidmap
298
            finally:
299
                pb.finished()
0.200.1323 by Jelmer Vernooij
Simplify push handling.
300
        finally:
0.200.1493 by Jelmer Vernooij
Test fixes.
301
            self.source_store.unlock()
0.200.1323 by Jelmer Vernooij
Simplify push handling.
302
0.252.4 by Jelmer Vernooij
More work on roundtripping.
303
    def fetch(self, revision_id=None, pb=None, find_ghosts=False,
0.200.1030 by Jelmer Vernooij
More work on supporting roundtripping push.
304
            fetch_spec=None, mapped_refs=None):
0.200.1156 by Jelmer Vernooij
Disable push.
305
        if not self.mapping.roundtripping:
306
            raise NoPushSupport()
0.200.1493 by Jelmer Vernooij
Test fixes.
307
        if mapped_refs is not None:
308
            stop_revisions = mapped_refs
309
        elif revision_id is not None:
310
            stop_revisions = [(None, revision_id)]
311
        elif fetch_spec is not None:
312
            recipe = fetch_spec.get_recipe()
313
            if recipe[0] in ("search", "proxy-search"):
314
                stop_revisions = [(None, revid) for revid in recipe[1]]
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
315
            else:
0.200.1493 by Jelmer Vernooij
Test fixes.
316
                raise AssertionError("Unsupported search result type %s" % recipe[0])
317
        else:
318
            stop_revisions = [(None, revid) for revid in self.source.all_revision_ids()]
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
319
        self.fetch_objects(stop_revisions, lossy=False)
0.252.4 by Jelmer Vernooij
More work on roundtripping.
320
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
321
    @staticmethod
322
    def is_compatible(source, target):
323
        """Be compatible with GitRepository."""
0.200.695 by Jelmer Vernooij
Clean up trailing whitespace.
324
        return (not isinstance(source, GitRepository) and
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
325
                isinstance(target, LocalGitRepository))
326
327
328
class InterToRemoteGitRepository(InterToGitRepository):
329
0.200.1323 by Jelmer Vernooij
Simplify push handling.
330
    def fetch_refs(self, update_refs, lossy):
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
331
        """Import the gist of the ancestry of a particular revision."""
0.200.1509 by Jelmer Vernooij
Properly raise exception when pulling from git into bzr without experimental mappings.
332
        if not lossy and not self.mapping.roundtripping:
0.200.1323 by Jelmer Vernooij
Simplify push handling.
333
            raise NoPushSupport()
0.200.1065 by Jelmer Vernooij
Don't peel tags automatically when pushing back.
334
        unpeel_map = UnpeelMap.from_repository(self.source)
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
335
        revidmap = {}
0.200.942 by Jelmer Vernooij
pass update_refs to dfetch_refs.
336
        def determine_wants(old_refs):
0.200.429 by Jelmer Vernooij
get remote dpush to a point where we now what to send.
337
            ret = {}
0.200.1052 by Jelmer Vernooij
Fix too many values to unpack error.
338
            self.old_refs = dict([(k, (v, None)) for (k, v) in old_refs.iteritems()])
0.200.942 by Jelmer Vernooij
pass update_refs to dfetch_refs.
339
            self.new_refs = update_refs(self.old_refs)
0.200.970 by Jelmer Vernooij
Fix dpush to remote locations.
340
            for name, (gitid, revid) in self.new_refs.iteritems():
341
                if gitid is None:
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
342
                    git_sha = self.source_store._lookup_revision_sha1(revid)
343
                    ret[name] = unpeel_map.re_unpeel_tag(git_sha, old_refs.get(name))
0.200.970 by Jelmer Vernooij
Fix dpush to remote locations.
344
                else:
345
                    ret[name] = gitid
0.200.429 by Jelmer Vernooij
get remote dpush to a point where we now what to send.
346
            return ret
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
347
        self.source_store.lock_read()
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
348
        try:
0.200.460 by Jelmer Vernooij
Somewhat fix commit in git working trees.
349
            new_refs = self.target.send_pack(determine_wants,
0.252.37 by Jelmer Vernooij
Factor out some common code for finding refs to send.
350
                    self.source_store.generate_lossy_pack_contents)
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
351
        finally:
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
352
            self.source_store.unlock()
0.200.1323 by Jelmer Vernooij
Simplify push handling.
353
        # FIXME: revidmap?
0.200.942 by Jelmer Vernooij
pass update_refs to dfetch_refs.
354
        return revidmap, self.old_refs, self.new_refs
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
355
356
    @staticmethod
357
    def is_compatible(source, target):
358
        """Be compatible with GitRepository."""
0.200.695 by Jelmer Vernooij
Clean up trailing whitespace.
359
        return (not isinstance(source, GitRepository) and
0.200.425 by Jelmer Vernooij
Split out push to remote git repositories.
360
                isinstance(target, RemoteGitRepository))