13
14
# You should have received a copy of the GNU General Public License
14
15
# 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
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18
"""An adapter between a Git Repository and a Bazaar Branch"""
20
from __future__ import absolute_import
35
from bzrlib.foreign import (
38
from bzrlib.trace import mutter
39
from bzrlib.transport import get_transport
41
from bzrlib.plugins.git.foreign import (
44
from bzrlib.plugins.git.mapping import default_mapping
46
from bzrlib.plugins.git import git
49
class GitTags(object):
51
def __init__(self, tags):
55
return iter(self._tags)
28
revision as _mod_revision,
33
from ..decorators import only_raises
34
from ..foreign import (
37
from ..sixish import (
45
from .filegraph import (
46
GitFileLastChangeScanner,
47
GitFileParentProvider,
49
from .mapping import (
59
from dulwich.errors import (
62
from dulwich.objects import (
66
from dulwich.object_store import (
71
class RepoReconciler(object):
72
"""Reconciler that reconciles a repository.
76
def __init__(self, repo, other=None, thorough=False):
77
"""Construct a RepoReconciler.
79
:param thorough: perform a thorough check which may take longer but
80
will correct non-data loss issues such as incorrect
86
"""Perform reconciliation.
88
After reconciliation the following attributes document found issues:
89
inconsistent_parents: The number of revisions in the repository whose
90
ancestry was being reported incorrectly.
91
garbage_inventories: The number of inventory objects without revisions
92
that were garbage collected.
96
class GitCheck(check.Check):
98
def __init__(self, repository, check_repo=True):
99
self.repository = repository
100
self.check_repo = check_repo
101
self.checked_rev_cnt = 0
102
self.object_count = None
105
def check(self, callback_refs=None, check_repo=True):
106
if callback_refs is None:
108
with self.repository.lock_read(), \
109
ui.ui_factory.nested_progress_bar() as self.progress:
110
shas = set(self.repository._git.object_store)
111
self.object_count = len(shas)
112
# TODO(jelmer): Check more things
113
for i, sha in enumerate(shas):
114
self.progress.update('checking objects', i, self.object_count)
115
o = self.repository._git.object_store[sha]
118
except Exception as e:
119
self.problems.append((sha, e))
121
def _report_repo_results(self, verbose):
122
trace.note('checked repository {0} format {1}'.format(
123
self.repository.user_url,
124
self.repository._format))
125
trace.note('%6d objects', self.object_count)
126
for sha, problem in self.problems:
127
trace.note('%s: %s', sha, problem)
129
def report_results(self, verbose):
131
self._report_repo_results(verbose)
134
_optimisers_loaded = False
137
def lazy_load_optimisers():
138
global _optimisers_loaded
139
if _optimisers_loaded:
141
from . import interrepo
142
for optimiser in [interrepo.InterRemoteGitNonGitRepository,
143
interrepo.InterLocalGitNonGitRepository,
144
interrepo.InterLocalGitLocalGitRepository,
145
interrepo.InterRemoteGitLocalGitRepository,
146
interrepo.InterToLocalGitRepository,
147
interrepo.InterToRemoteGitRepository,
149
repository.InterRepository.register_optimiser(optimiser)
150
_optimisers_loaded = True
58
153
class GitRepository(ForeignRepository):
59
154
"""An adapter to git repositories for bzr."""
61
156
_serializer = None
63
def __init__(self, gitdir, lockfiles):
64
ForeignRepository.__init__(self, GitFormat(), gitdir, lockfiles)
65
from bzrlib.plugins.git import fetch
66
repository.InterRepository.register_optimiser(fetch.InterGitRepository)
157
vcs = foreign_vcs_git
160
def __init__(self, gitdir):
161
self._transport = gitdir.root_transport
162
super(GitRepository, self).__init__(GitRepositoryFormat(),
163
gitdir, control_files=None)
164
self.base = gitdir.root_transport.base
165
lazy_load_optimisers()
166
self._lock_mode = None
169
def add_fallback_repository(self, basis_url):
170
raise errors.UnstackableRepositoryFormat(self._format,
171
self.control_transport.base)
68
173
def is_shared(self):
176
def get_physical_lock_status(self):
179
def lock_write(self):
180
"""See Branch.lock_write()."""
182
if self._lock_mode != 'w':
183
raise errors.ReadOnlyError(self)
184
self._lock_count += 1
186
self._lock_mode = 'w'
188
self._transaction = transactions.WriteTransaction()
189
return repository.RepositoryWriteLockResult(self.unlock, None)
191
def break_lock(self):
192
raise NotImplementedError(self.break_lock)
194
def dont_leave_lock_in_place(self):
195
raise NotImplementedError(self.dont_leave_lock_in_place)
197
def leave_lock_in_place(self):
198
raise NotImplementedError(self.leave_lock_in_place)
202
if self._lock_mode not in ('r', 'w'):
204
self._lock_count += 1
206
self._lock_mode = 'r'
208
self._transaction = transactions.ReadOnlyTransaction()
209
return lock.LogicalLockResult(self.unlock)
211
@only_raises(errors.LockNotHeld, errors.LockBroken)
213
if self._lock_count == 0:
214
raise errors.LockNotHeld(self)
215
if self._lock_count == 1 and self._lock_mode == 'w':
216
if self._write_group is not None:
217
self.abort_write_group()
218
self._lock_count -= 1
219
self._lock_mode = None
220
raise errors.BzrError(
221
'Must end write groups before releasing write locks.')
222
self._lock_count -= 1
223
if self._lock_count == 0:
224
self._lock_mode = None
225
transaction = self._transaction
226
self._transaction = None
229
def is_write_locked(self):
230
return (self._lock_mode == 'w')
233
return (self._lock_mode is not None)
235
def get_transaction(self):
236
"""See Repository.get_transaction()."""
237
if self._transaction is None:
238
return transactions.PassThroughTransaction()
240
return self._transaction
242
def reconcile(self, other=None, thorough=False):
243
"""Reconcile this repository."""
244
reconciler = RepoReconciler(self, thorough=thorough)
245
reconciler.reconcile()
71
248
def supports_rich_root(self):
74
def _warn_if_deprecated(self):
75
# This class isn't deprecated
78
251
def get_mapping(self):
79
252
return default_mapping
81
254
def make_working_trees(self):
255
return not self._git.get_config().get_boolean(("core", ), "bare")
257
def revision_graph_can_have_wrong_parents(self):
260
def add_signature_text(self, revid, signature):
261
raise errors.UnsupportedOperation(self.add_signature_text, self)
263
def sign_revision(self, revision_id, gpg_strategy):
264
raise errors.UnsupportedOperation(self.add_signature_text, self)
85
267
class LocalGitRepository(GitRepository):
268
"""Git repository on the file system."""
87
def __init__(self, gitdir, lockfiles):
88
# FIXME: This also caches negatives. Need to be more careful
89
# about this once we start writing to git
90
self._parents_provider = graph.CachingParentsProvider(self)
91
GitRepository.__init__(self, gitdir, lockfiles)
92
self.base = gitdir.root_transport.base
270
def __init__(self, gitdir):
271
GitRepository.__init__(self, gitdir)
93
272
self._git = gitdir._git
95
self.signatures = versionedfiles.VirtualSignatureTexts(self)
96
self.revisions = versionedfiles.VirtualRevisionTexts(self)
97
self.tags = GitTags(self._git.get_tags())
273
self._file_change_scanner = GitFileLastChangeScanner(self)
274
self._transaction = None
276
def get_commit_builder(self, branch, parents, config, timestamp=None,
277
timezone=None, committer=None, revprops=None,
278
revision_id=None, lossy=False):
279
"""Obtain a CommitBuilder for this repository.
281
:param branch: Branch to commit to.
282
:param parents: Revision ids of the parents of the new revision.
283
:param config: Configuration to use.
284
:param timestamp: Optional timestamp recorded for commit.
285
:param timezone: Optional timezone for timestamp.
286
:param committer: Optional committer to set for commit.
287
:param revprops: Optional dictionary of revision properties.
288
:param revision_id: Optional revision id.
289
:param lossy: Whether to discard data that can not be natively
290
represented, when pushing to a foreign VCS
292
builder = GitCommitBuilder(
293
self, parents, config, timestamp, timezone, committer, revprops,
295
self.start_write_group()
298
def get_file_graph(self):
299
return _mod_graph.Graph(GitFileParentProvider(
300
self._file_change_scanner))
302
def iter_files_bytes(self, desired_files):
303
"""Iterate through file versions.
305
Files will not necessarily be returned in the order they occur in
306
desired_files. No specific order is guaranteed.
308
Yields pairs of identifier, bytes_iterator. identifier is an opaque
309
value supplied by the caller as part of desired_files. It should
310
uniquely identify the file version in the caller's context. (Examples:
311
an index number or a TreeTransform trans_id.)
313
bytes_iterator is an iterable of bytestrings for the file. The
314
kind of iterable and length of the bytestrings are unspecified, but for
315
this implementation, it is a list of bytes produced by
316
VersionedFile.get_record_stream().
318
:param desired_files: a list of (file_id, revision_id, identifier)
322
for (file_id, revision_id, identifier) in desired_files:
323
per_revision.setdefault(revision_id, []).append(
324
(file_id, identifier))
325
for revid, files in viewitems(per_revision):
327
(commit_id, mapping) = self.lookup_bzr_revision_id(revid)
328
except errors.NoSuchRevision:
329
raise errors.RevisionNotPresent(revid, self)
331
commit = self._git.object_store[commit_id]
333
raise errors.RevisionNotPresent(revid, self)
334
root_tree = commit.tree
335
for fileid, identifier in files:
337
path = mapping.parse_file_id(fileid)
339
raise errors.RevisionNotPresent((fileid, revid), self)
341
obj = tree_lookup_path(
342
self._git.object_store.__getitem__, root_tree,
343
path.encode('utf-8'))
344
if isinstance(obj, tuple):
345
(mode, item_id) = obj
346
obj = self._git.object_store[item_id]
348
raise errors.RevisionNotPresent((fileid, revid), self)
350
if obj.type_name == b"tree":
351
yield (identifier, [])
352
elif obj.type_name == b"blob":
353
yield (identifier, obj.chunked)
355
raise AssertionError("file text resolved to %r" % obj)
357
def gather_stats(self, revid=None, committers=None):
358
"""See Repository.gather_stats()."""
359
result = super(LocalGitRepository, self).gather_stats(
362
for sha in self._git.object_store:
363
o = self._git.object_store[sha]
364
if o.type_name == b"commit":
366
result['revisions'] = len(revs)
369
def _iter_revision_ids(self):
370
mapping = self.get_mapping()
371
for sha in self._git.object_store:
372
o = self._git.object_store[sha]
373
if not isinstance(o, Commit):
375
rev, roundtrip_revid, verifiers = mapping.import_commit(
376
o, mapping.revision_id_foreign_to_bzr)
377
yield o.id, rev.revision_id, roundtrip_revid
99
379
def all_revision_ids(self):
100
ret = set([revision.NULL_REVISION])
101
if self._git.heads() == []:
103
bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in self._git.heads()]
105
graph = self.get_graph()
106
for rev, parents in graph.iter_ancestry(bzr_heads):
381
for git_sha, revid, roundtrip_revid in self._iter_revision_ids():
383
ret.add(roundtrip_revid)
388
def _get_parents(self, revid, no_alternates=False):
389
if type(revid) != bytes:
392
(hexsha, mapping) = self.lookup_bzr_revision_id(revid)
393
except errors.NoSuchRevision:
395
# FIXME: Honor no_alternates setting
397
commit = self._git.object_store[hexsha]
401
for p in commit.parents:
403
ret.append(self.lookup_foreign_revision_id(p, mapping))
405
ret.append(mapping.revision_id_foreign_to_bzr(p))
110
#def get_revision_delta(self, revision_id):
111
# parent_revid = self.get_revision(revision_id).parent_ids[0]
112
# diff = self._git.diff(ids.convert_revision_id_bzr_to_git(parent_revid),
113
# ids.convert_revision_id_bzr_to_git(revision_id))
115
def _make_parents_provider(self):
116
"""See Repository._make_parents_provider()."""
117
return self._parents_provider
119
def get_parent_map(self, revids):
408
def _get_parent_map_no_fallbacks(self, revids):
409
return self.get_parent_map(revids, no_alternates=True)
411
def get_parent_map(self, revids, no_alternates=False):
121
mutter("get_parent_map(%r)", revids)
122
413
for revision_id in revids:
123
assert isinstance(revision_id, str)
124
if revision_id == revision.NULL_REVISION:
414
parents = self._get_parents(
415
revision_id, no_alternates=no_alternates)
416
if revision_id == _mod_revision.NULL_REVISION:
125
417
parent_map[revision_id] = ()
127
hexsha = self.lookup_git_revid(revision_id, self.get_mapping())
128
commit = self._git.commit(hexsha)
132
parent_map[revision_id] = [self.get_mapping().revision_id_foreign_to_bzr(p) for p in commit.parents]
421
if len(parents) == 0:
422
parents = [_mod_revision.NULL_REVISION]
423
parent_map[revision_id] = tuple(parents)
133
424
return parent_map
135
def get_ancestry(self, revision_id, topo_sorted=True):
136
"""See Repository.get_ancestry().
426
def get_known_graph_ancestry(self, revision_ids):
427
"""Return the known graph for a set of revision ids and their ancestors.
138
if revision_id is None:
139
return self._all_revision_ids()
140
assert isinstance(revision_id, str)
142
graph = self.get_graph()
143
for rev, parents in graph.iter_ancestry([revision_id]):
144
if rev == revision.NULL_REVISION:
429
pending = set(revision_ids)
433
for revid in pending:
434
if revid == _mod_revision.NULL_REVISION:
436
parents = self._get_parents(revid)
437
if parents is not None:
438
this_parent_map[revid] = parents
439
parent_map.update(this_parent_map)
441
for values in viewvalues(this_parent_map):
442
pending.update(values)
443
pending = pending.difference(parent_map)
444
return _mod_graph.KnownGraph(parent_map)
150
446
def get_signature_text(self, revision_id):
151
raise errors.NoSuchRevision(self, revision_id)
153
def lookup_revision_id(self, revid):
447
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
449
commit = self._git.object_store[git_commit_id]
451
raise errors.NoSuchRevision(self, revision_id)
452
if commit.gpgsig is None:
453
raise errors.NoSuchRevision(self, revision_id)
456
def check(self, revision_ids=None, callback_refs=None, check_repo=True):
457
result = GitCheck(self, check_repo=check_repo)
458
result.check(callback_refs)
461
def pack(self, hint=None, clean_obsolete_packs=False):
462
self._git.object_store.pack_loose_objects()
464
def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
154
465
"""Lookup a revision id.
156
:param revid: Bazaar revision id.
157
:return: Tuple with git revisionid and mapping.
467
:param foreign_revid: Foreign revision id to look up
468
:param mapping: Mapping to use (use default mapping if not specified)
469
:raise KeyError: If foreign revision was not found
470
:return: bzr revision id
159
# Yes, this doesn't really work, but good enough as a stub
160
return osutils.sha(rev_id).hexdigest(), self.get_mapping()
472
if not isinstance(foreign_revid, bytes):
473
raise TypeError(foreign_revid)
475
mapping = self.get_mapping()
476
if foreign_revid == ZERO_SHA:
477
return _mod_revision.NULL_REVISION
478
commit = self._git.object_store.peel_sha(foreign_revid)
479
if not isinstance(commit, Commit):
480
raise NotCommitError(commit.id)
481
rev, roundtrip_revid, verifiers = mapping.import_commit(
482
commit, mapping.revision_id_foreign_to_bzr)
483
# FIXME: check testament before doing this?
485
return roundtrip_revid
487
return rev.revision_id
162
489
def has_signature_for_revision_id(self, revision_id):
165
def lookup_git_revid(self, bzr_revid, mapping):
167
return mapping.revision_id_bzr_to_foreign(bzr_revid)
490
"""Check whether a GPG signature is present for this revision.
492
This is never the case for Git repositories.
495
self.get_signature_text(revision_id)
496
except errors.NoSuchRevision:
501
def verify_revision_signature(self, revision_id, gpg_strategy):
502
"""Verify the signature on a revision.
504
:param revision_id: the revision to verify
505
:gpg_strategy: the GPGStrategy object to used
507
:return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
509
from breezy import gpg
510
with self.lock_read():
511
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
513
commit = self._git.object_store[git_commit_id]
515
raise errors.NoSuchRevision(self, revision_id)
517
if commit.gpgsig is None:
518
return gpg.SIGNATURE_NOT_SIGNED, None
520
without_sig = Commit.from_string(commit.as_raw_string())
521
without_sig.gpgsig = None
523
(result, key, plain_text) = gpg_strategy.verify(
524
without_sig.as_raw_string(), commit.gpgsig)
527
def lookup_bzr_revision_id(self, bzr_revid, mapping=None):
528
"""Lookup a bzr revision id in a Git repository.
530
:param bzr_revid: Bazaar revision id
531
:param mapping: Optional mapping to use
532
:return: Tuple with git commit id, mapping that was used and supplement
536
(git_sha, mapping) = mapping_registry.revision_id_bzr_to_foreign(
168
538
except errors.InvalidRevisionId:
169
raise errors.NoSuchRevision(self, bzr_revid)
540
mapping = self.get_mapping()
542
return (self._git.refs[mapping.revid_as_refname(bzr_revid)],
545
# Update refs from Git commit objects
546
# FIXME: Hitting this a lot will be very inefficient...
547
pb = ui.ui_factory.nested_progress_bar()
549
for i, (git_sha, revid, roundtrip_revid) in enumerate(
550
self._iter_revision_ids()):
551
if not roundtrip_revid:
553
pb.update("resolving revision id", i)
554
refname = mapping.revid_as_refname(roundtrip_revid)
555
self._git.refs[refname] = git_sha
556
if roundtrip_revid == bzr_revid:
557
return git_sha, mapping
560
raise errors.NoSuchRevision(self, bzr_revid)
562
return (git_sha, mapping)
171
564
def get_revision(self, revision_id):
172
git_commit_id = self.lookup_git_revid(revision_id, self.get_mapping())
565
if not isinstance(revision_id, bytes):
566
raise errors.InvalidRevisionId(revision_id, self)
567
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
174
commit = self._git.commit(git_commit_id)
569
commit = self._git.object_store[git_commit_id]
176
571
raise errors.NoSuchRevision(self, revision_id)
177
# print "fetched revision:", git_commit_id
178
revision = self.get_mapping().import_commit(commit)
179
assert revision is not None
572
revision, roundtrip_revid, verifiers = mapping.import_commit(
573
commit, self.lookup_foreign_revision_id)
576
# FIXME: check verifiers ?
578
revision.revision_id = roundtrip_revid
182
581
def has_revision(self, revision_id):
582
"""See Repository.has_revision."""
583
if revision_id == _mod_revision.NULL_REVISION:
184
self.get_revision(revision_id)
586
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id)
185
587
except errors.NoSuchRevision:
190
def get_revisions(self, revids):
191
return [self.get_revision(r) for r in revids]
589
return (git_commit_id in self._git)
591
def has_revisions(self, revision_ids):
592
"""See Repository.has_revisions."""
593
return set(filter(self.has_revision, revision_ids))
595
def iter_revisions(self, revision_ids):
596
"""See Repository.get_revisions."""
597
for revid in revision_ids:
599
rev = self.get_revision(revid)
600
except errors.NoSuchRevision:
193
604
def revision_trees(self, revids):
605
"""See Repository.revision_trees."""
194
606
for revid in revids:
195
607
yield self.revision_tree(revid)
197
609
def revision_tree(self, revision_id):
198
revision_id = revision.ensure_null(revision_id)
200
if revision_id == revision.NULL_REVISION:
201
inv = inventory.Inventory(root_id=None)
202
inv.revision_id = revision_id
203
return revisiontree.RevisionTree(self, inv, revision_id)
205
return GitRevisionTree(self, self.get_mapping(), revision_id)
207
def get_inventory(self, revision_id):
208
assert revision_id != None
209
return self.revision_tree(revision_id).inventory
610
"""See Repository.revision_tree."""
611
if revision_id is None:
612
raise ValueError('invalid revision id %s' % revision_id)
613
return GitRevisionTree(self, revision_id)
615
def get_deltas_for_revisions(self, revisions, specific_fileids=None):
616
"""Produce a generator of revision deltas.
618
Note that the input is a sequence of REVISIONS, not revision_ids.
619
Trees will be held in memory until the generator exits.
620
Each delta is relative to the revision's lefthand predecessor.
622
:param specific_fileids: if not None, the result is filtered
623
so that only those file-ids, their parents and their
624
children are included.
626
# Get the revision-ids of interest
627
required_trees = set()
628
for revision in revisions:
629
required_trees.add(revision.revision_id)
630
required_trees.update(revision.parent_ids[:1])
632
trees = dict((t.get_revision_id(), t) for
633
t in self.revision_trees(required_trees))
635
# Calculate the deltas
636
for revision in revisions:
637
if not revision.parent_ids:
638
old_tree = self.revision_tree(_mod_revision.NULL_REVISION)
640
old_tree = trees[revision.parent_ids[0]]
641
new_tree = trees[revision.revision_id]
642
if specific_fileids is not None:
643
specific_files = [new_tree.id2path(
644
fid) for fid in specific_fileids]
646
specific_files = None
647
yield new_tree.changes_from(
648
old_tree, specific_files=specific_files)
211
650
def set_make_working_trees(self, trees):
214
def fetch_objects(self, determine_wants, graph_walker, progress=None):
215
return self._git.fetch_objects(determine_wants, graph_walker, progress)
218
class GitRevisionTree(revisiontree.RevisionTree):
220
def __init__(self, repository, mapping, revision_id):
221
self._repository = repository
222
self.revision_id = revision_id
223
assert isinstance(revision_id, str)
224
self.mapping = mapping
225
git_id = repository.lookup_git_revid(revision_id, self.mapping)
227
commit = repository._git.commit(git_id)
229
raise errors.NoSuchRevision(repository, revision_id)
230
self.tree = commit.tree
231
self._inventory = inventory.Inventory(revision_id=revision_id)
232
self._inventory.root.revision = revision_id
233
self._build_inventory(self.tree, self._inventory.root, "")
235
def get_revision_id(self):
236
return self.revision_id
238
def get_file_text(self, file_id):
239
entry = self._inventory[file_id]
240
if entry.kind == 'directory': return ""
241
return self._repository._git.get_blob(entry.text_id).data
243
def _build_inventory(self, tree_id, ie, path):
244
assert isinstance(path, str)
245
tree = self._repository._git.tree(tree_id)
246
for mode, name, hexsha in tree.entries():
247
basename = name.decode("utf-8")
251
child_path = urlutils.join(path, name)
252
file_id = self.mapping.generate_file_id(child_path)
253
entry_kind = (mode & 0700000) / 0100000
255
child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
256
elif entry_kind == 1:
257
file_kind = (mode & 070000) / 010000
258
b = self._repository._git.get_blob(hexsha)
260
child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
261
child_ie.text_sha1 = osutils.sha_string(b.data)
263
child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
264
child_ie.text_sha1 = osutils.sha_string("")
266
raise AssertionError(
267
"Unknown file kind, perms=%o." % (mode,))
268
child_ie.text_id = b.id
269
child_ie.text_size = len(b.data)
271
raise AssertionError(
272
"Unknown blob kind, perms=%r." % (mode,))
273
fs_mode = mode & 0777
274
child_ie.executable = bool(fs_mode & 0111)
275
child_ie.revision = self.revision_id
276
self._inventory.add(child_ie)
278
self._build_inventory(hexsha, child_ie, child_path)
281
class GitFormat(object):
283
supports_tree_reference = False
651
raise errors.UnsupportedOperation(self.set_make_working_trees, self)
653
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
654
progress=None, limit=None):
655
return self._git.fetch_objects(determine_wants, graph_walker, progress,
659
class GitRepositoryFormat(repository.RepositoryFormat):
660
"""Git repository format."""
662
supports_versioned_directories = False
663
supports_tree_reference = True
284
664
rich_root_data = True
665
supports_leaving_lock = False
667
supports_funky_characters = True
668
supports_external_lookups = False
669
supports_full_versioned_files = False
670
supports_revision_signatures = False
671
supports_nesting_repositories = False
672
revision_graph_can_have_wrong_parents = False
673
supports_unreferenced_revisions = True
674
supports_setting_revision_ids = False
675
supports_storing_branch_nick = False
676
supports_overriding_transport = False
677
supports_custom_revision_properties = False
678
records_per_file_revision = False
681
def _matchingcontroldir(self):
682
from .dir import LocalGitControlDirFormat
683
return LocalGitControlDirFormat()
286
685
def get_format_description(self):
287
686
return "Git Repository"
289
def initialize(self, url, shared=False, _internal=False):
290
raise bzr_errors.UninitializableFormat(self)
688
def initialize(self, controldir, shared=False, _internal=False):
689
from .dir import GitDir
690
if not isinstance(controldir, GitDir):
691
raise errors.UninitializableFormat(self)
692
return controldir.open_repository()
292
694
def check_conversion_target(self, target_repo_format):
293
695
return target_repo_format.rich_root_data
697
def get_foreign_tests_repository_factory(self):
698
from .tests.test_repository import (
699
ForeignTestsRepositoryFactory,
701
return ForeignTestsRepositoryFactory()
703
def network_name(self):
707
def get_extra_interrepo_test_combinations():
708
from ..bzr.groupcompress_repo import RepositoryFormat2a
709
from . import interrepo
711
(interrepo.InterLocalGitNonGitRepository,
712
GitRepositoryFormat(), RepositoryFormat2a()),
713
(interrepo.InterLocalGitLocalGitRepository,
714
GitRepositoryFormat(), GitRepositoryFormat()),
715
(interrepo.InterToLocalGitRepository,
716
RepositoryFormat2a(), GitRepositoryFormat()),