1
# Copyright (C) 2009-2018 Jelmer Vernooij <jelmer@jelmer.uk>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
from __future__ import absolute_import
22
from collections import deque
24
from io import BytesIO
27
from dulwich.config import (
29
ConfigFile as GitConfigFile,
31
from dulwich.diff_tree import tree_changes
32
from dulwich.errors import NotTreeError
33
from dulwich.index import (
34
blob_from_path_and_stat,
37
index_entry_from_stat,
40
from dulwich.object_store import (
44
from dulwich.objects import (
55
controldir as _mod_controldir,
65
from ..revision import (
69
from ..sixish import (
74
from .mapping import (
79
from .transportgit import (
85
class GitTreeDirectory(_mod_tree.TreeDirectory):
87
__slots__ = ['file_id', 'name', 'parent_id', 'children']
89
def __init__(self, file_id, name, parent_id):
90
self.file_id = file_id
92
self.parent_id = parent_id
101
def executable(self):
105
return self.__class__(
106
self.file_id, self.name, self.parent_id)
109
return "%s(file_id=%r, name=%r, parent_id=%r)" % (
110
self.__class__.__name__, self.file_id, self.name,
113
def __eq__(self, other):
114
return (self.kind == other.kind and
115
self.file_id == other.file_id and
116
self.name == other.name and
117
self.parent_id == other.parent_id)
120
class GitTreeFile(_mod_tree.TreeFile):
122
__slots__ = ['file_id', 'name', 'parent_id', 'text_size', 'text_sha1',
125
def __init__(self, file_id, name, parent_id, text_size=None,
126
text_sha1=None, executable=None):
127
self.file_id = file_id
129
self.parent_id = parent_id
130
self.text_size = text_size
131
self.text_sha1 = text_sha1
132
self.executable = executable
138
def __eq__(self, other):
139
return (self.kind == other.kind and
140
self.file_id == other.file_id and
141
self.name == other.name and
142
self.parent_id == other.parent_id and
143
self.text_sha1 == other.text_sha1 and
144
self.text_size == other.text_size and
145
self.executable == other.executable)
148
return ("%s(file_id=%r, name=%r, parent_id=%r, text_size=%r, "
149
"text_sha1=%r, executable=%r)") % (
150
type(self).__name__, self.file_id, self.name, self.parent_id,
151
self.text_size, self.text_sha1, self.executable)
154
ret = self.__class__(
155
self.file_id, self.name, self.parent_id)
156
ret.text_sha1 = self.text_sha1
157
ret.text_size = self.text_size
158
ret.executable = self.executable
162
class GitTreeSymlink(_mod_tree.TreeLink):
164
__slots__ = ['file_id', 'name', 'parent_id', 'symlink_target']
166
def __init__(self, file_id, name, parent_id,
167
symlink_target=None):
168
self.file_id = file_id
170
self.parent_id = parent_id
171
self.symlink_target = symlink_target
178
def executable(self):
186
return "%s(file_id=%r, name=%r, parent_id=%r, symlink_target=%r)" % (
187
type(self).__name__, self.file_id, self.name, self.parent_id,
190
def __eq__(self, other):
191
return (self.kind == other.kind and
192
self.file_id == other.file_id and
193
self.name == other.name and
194
self.parent_id == other.parent_id and
195
self.symlink_target == other.symlink_target)
198
return self.__class__(
199
self.file_id, self.name, self.parent_id,
203
class GitTreeSubmodule(_mod_tree.TreeReference):
205
__slots__ = ['file_id', 'name', 'parent_id', 'reference_revision']
207
def __init__(self, file_id, name, parent_id, reference_revision=None):
208
self.file_id = file_id
210
self.parent_id = parent_id
211
self.reference_revision = reference_revision
214
def executable(self):
219
return 'tree-reference'
222
return ("%s(file_id=%r, name=%r, parent_id=%r, "
223
"reference_revision=%r)") % (
224
type(self).__name__, self.file_id, self.name, self.parent_id,
225
self.reference_revision)
227
def __eq__(self, other):
228
return (self.kind == other.kind and
229
self.file_id == other.file_id and
230
self.name == other.name and
231
self.parent_id == other.parent_id and
232
self.reference_revision == other.reference_revision)
235
return self.__class__(
236
self.file_id, self.name, self.parent_id,
237
self.reference_revision)
241
'directory': GitTreeDirectory,
243
'symlink': GitTreeSymlink,
244
'tree-reference': GitTreeSubmodule,
248
def ensure_normalized_path(path):
249
"""Check whether path is normalized.
251
:raises InvalidNormalization: When path is not normalized, and cannot be
252
accessed on this platform by the normalized path.
253
:return: The NFC normalised version of path.
255
norm_path, can_access = osutils.normalized_filename(path)
256
if norm_path != path:
260
raise errors.InvalidNormalization(path)
264
class GitRevisionTree(revisiontree.RevisionTree):
265
"""Revision tree implementation based on Git objects."""
267
def __init__(self, repository, revision_id):
268
self._revision_id = revision_id
269
self._repository = repository
270
self._submodules = None
271
self.store = repository._git.object_store
272
if not isinstance(revision_id, bytes):
273
raise TypeError(revision_id)
274
self.commit_id, self.mapping = repository.lookup_bzr_revision_id(
276
if revision_id == NULL_REVISION:
278
self.mapping = default_mapping
281
commit = self.store[self.commit_id]
283
raise errors.NoSuchRevision(repository, revision_id)
284
self.tree = commit.tree
286
def _submodule_info(self):
287
if self._submodules is None:
289
with self.get_file('.gitmodules') as f:
290
config = GitConfigFile.from_file(f)
293
for path, url, section in parse_submodules(config)}
294
except errors.NoSuchFile:
295
self._submodules = {}
296
return self._submodules
298
def _get_submodule_repository(self, relpath):
299
if not isinstance(relpath, bytes):
300
raise TypeError(relpath)
302
info = self._submodule_info()[relpath]
304
nested_repo_transport = self._repository.controldir.user_transport.clone(
305
relpath.decode('utf-8'))
307
nested_repo_transport = self._repository.controldir.control_transport.clone(
308
posixpath.join('modules', info[1].decode('utf-8')))
309
nested_controldir = _mod_controldir.ControlDir.open_from_transport(
310
nested_repo_transport)
311
return nested_controldir.find_repository()
313
def _get_submodule_store(self, relpath):
314
return self._get_submodule_repository(relpath)._git.object_store
316
def get_nested_tree(self, path):
317
encoded_path = path.encode('utf-8')
318
nested_repo = self._get_submodule_repository(encoded_path)
319
ref_rev = self.get_reference_revision(path)
320
return nested_repo.revision_tree(ref_rev)
322
def supports_rename_tracking(self):
325
def get_file_revision(self, path):
326
change_scanner = self._repository._file_change_scanner
327
if self.commit_id == ZERO_SHA:
329
(unused_path, commit_id) = change_scanner.find_last_change_revision(
330
path.encode('utf-8'), self.commit_id)
331
return self._repository.lookup_foreign_revision_id(
332
commit_id, self.mapping)
334
def get_file_mtime(self, path):
336
revid = self.get_file_revision(path)
338
raise errors.NoSuchFile(path)
340
rev = self._repository.get_revision(revid)
341
except errors.NoSuchRevision:
342
raise _mod_tree.FileTimestampUnavailable(path)
345
def id2path(self, file_id, recurse='down'):
347
path = self.mapping.parse_file_id(file_id)
349
raise errors.NoSuchId(self, file_id)
350
if self.is_versioned(path):
352
raise errors.NoSuchId(self, file_id)
354
def is_versioned(self, path):
355
return self.has_filename(path)
357
def path2id(self, path):
358
if self.mapping.is_special_file(path):
360
if not self.is_versioned(path):
362
return self.mapping.generate_file_id(osutils.safe_unicode(path))
364
def all_file_ids(self):
365
raise errors.UnsupportedOperation(self.all_file_ids, self)
367
def all_versioned_paths(self):
369
todo = [(self.store, b'', self.tree)]
371
(store, path, tree_id) = todo.pop()
374
tree = store[tree_id]
375
for name, mode, hexsha in tree.items():
376
subpath = posixpath.join(path, name)
377
ret.add(subpath.decode('utf-8'))
378
if stat.S_ISDIR(mode):
379
todo.append((store, subpath, hexsha))
382
def _lookup_path(self, path):
383
if self.tree is None:
384
raise errors.NoSuchFile(path)
386
encoded_path = path.encode('utf-8')
387
parts = encoded_path.split(b'/')
391
for i, p in enumerate(parts):
395
if not isinstance(obj, Tree):
396
raise NotTreeError(hexsha)
398
mode, hexsha = obj[p]
400
raise errors.NoSuchFile(path)
401
if S_ISGITLINK(mode) and i != len(parts) - 1:
402
store = self._get_submodule_store(b'/'.join(parts[:i + 1]))
403
hexsha = store[hexsha].tree
404
return (store, mode, hexsha)
406
def is_executable(self, path):
407
(store, mode, hexsha) = self._lookup_path(path)
409
# the tree root is a directory
411
return mode_is_executable(mode)
413
def kind(self, path):
414
(store, mode, hexsha) = self._lookup_path(path)
416
# the tree root is a directory
418
return mode_kind(mode)
420
def has_filename(self, path):
422
self._lookup_path(path)
423
except errors.NoSuchFile:
428
def _submodule_info(self):
429
if self._submodules is None:
431
with self.get_file('.gitmodules') as f:
432
config = GitConfigFile.from_file(f)
435
for path, url, section in parse_submodules(config)}
436
except errors.NoSuchFile:
437
self._submodules = {}
438
return self._submodules
440
def list_files(self, include_root=False, from_dir=None, recursive=True,
441
recurse_nested=False):
442
if self.tree is None:
444
if from_dir is None or from_dir == '.':
446
(store, mode, hexsha) = self._lookup_path(from_dir)
447
if mode is None: # Root
448
root_ie = self._get_dir_ie(b"", None)
450
parent_path = posixpath.dirname(from_dir)
451
parent_id = self.mapping.generate_file_id(parent_path)
452
if mode_kind(mode) == 'directory':
453
root_ie = self._get_dir_ie(from_dir.encode("utf-8"), parent_id)
455
root_ie = self._get_file_ie(
456
store, from_dir.encode("utf-8"),
457
posixpath.basename(from_dir), mode, hexsha)
459
yield (from_dir, "V", root_ie.kind, root_ie)
461
if root_ie.kind == 'directory':
462
todo.append((store, from_dir.encode("utf-8"),
463
b"", hexsha, root_ie.file_id))
465
(store, path, relpath, hexsha, parent_id) = todo.pop()
467
for name, mode, hexsha in tree.iteritems():
468
if self.mapping.is_special_file(name):
470
child_path = posixpath.join(path, name)
471
child_relpath = posixpath.join(relpath, name)
472
if S_ISGITLINK(mode) and recurse_nested:
474
store = self._get_submodule_store(child_relpath)
475
hexsha = store[hexsha].tree
476
if stat.S_ISDIR(mode):
477
ie = self._get_dir_ie(child_path, parent_id)
480
(store, child_path, child_relpath, hexsha,
483
ie = self._get_file_ie(
484
store, child_path, name, mode, hexsha, parent_id)
485
yield (child_relpath.decode('utf-8'), "V", ie.kind, ie)
487
def _get_file_ie(self, store, path, name, mode, hexsha, parent_id):
488
if not isinstance(path, bytes):
489
raise TypeError(path)
490
if not isinstance(name, bytes):
491
raise TypeError(name)
492
kind = mode_kind(mode)
493
path = path.decode('utf-8')
494
name = name.decode("utf-8")
495
file_id = self.mapping.generate_file_id(path)
496
ie = entry_factory[kind](file_id, name, parent_id)
497
if kind == 'symlink':
498
ie.symlink_target = store[hexsha].data.decode('utf-8')
499
elif kind == 'tree-reference':
500
ie.reference_revision = self.mapping.revision_id_foreign_to_bzr(
503
data = store[hexsha].data
504
ie.text_sha1 = osutils.sha_string(data)
505
ie.text_size = len(data)
506
ie.executable = mode_is_executable(mode)
509
def _get_dir_ie(self, path, parent_id):
510
path = path.decode('utf-8')
511
file_id = self.mapping.generate_file_id(path)
512
return GitTreeDirectory(file_id, posixpath.basename(path), parent_id)
514
def iter_child_entries(self, path):
515
(store, mode, tree_sha) = self._lookup_path(path)
517
if mode is not None and not stat.S_ISDIR(mode):
520
encoded_path = path.encode('utf-8')
521
file_id = self.path2id(path)
522
tree = store[tree_sha]
523
for name, mode, hexsha in tree.iteritems():
524
if self.mapping.is_special_file(name):
526
child_path = posixpath.join(encoded_path, name)
527
if stat.S_ISDIR(mode):
528
yield self._get_dir_ie(child_path, file_id)
530
yield self._get_file_ie(store, child_path, name, mode, hexsha,
533
def iter_entries_by_dir(self, specific_files=None,
534
recurse_nested=False):
535
if self.tree is None:
537
if specific_files is not None:
538
if specific_files in ([""], []):
539
specific_files = None
541
specific_files = set([p.encode('utf-8')
542
for p in specific_files])
543
todo = deque([(self.store, b"", self.tree, self.path2id(''))])
544
if specific_files is None or u"" in specific_files:
545
yield u"", self._get_dir_ie(b"", None)
547
store, path, tree_sha, parent_id = todo.popleft()
548
tree = store[tree_sha]
550
for name, mode, hexsha in tree.iteritems():
551
if self.mapping.is_special_file(name):
553
child_path = posixpath.join(path, name)
554
child_path_decoded = child_path.decode('utf-8')
555
if recurse_nested and S_ISGITLINK(mode):
557
store = self._get_submodule_store(child_path)
558
hexsha = store[hexsha].tree
559
if stat.S_ISDIR(mode):
560
if (specific_files is None or
561
any([p for p in specific_files if p.startswith(
564
(store, child_path, hexsha,
565
self.path2id(child_path_decoded)))
566
if specific_files is None or child_path in specific_files:
567
if stat.S_ISDIR(mode):
568
yield (child_path_decoded,
569
self._get_dir_ie(child_path, parent_id))
571
yield (child_path_decoded,
572
self._get_file_ie(store, child_path, name, mode,
574
todo.extendleft(reversed(extradirs))
576
def iter_references(self):
577
if self.supports_tree_reference():
578
for path, entry in self.iter_entries_by_dir():
579
if entry.kind == 'tree-reference':
582
def get_revision_id(self):
583
"""See RevisionTree.get_revision_id."""
584
return self._revision_id
586
def get_file_sha1(self, path, stat_value=None):
587
if self.tree is None:
588
raise errors.NoSuchFile(path)
589
return osutils.sha_string(self.get_file_text(path))
591
def get_file_verifier(self, path, stat_value=None):
592
(store, mode, hexsha) = self._lookup_path(path)
593
return ("GIT", hexsha)
595
def get_file_size(self, path):
596
(store, mode, hexsha) = self._lookup_path(path)
597
if stat.S_ISREG(mode):
598
return len(store[hexsha].data)
601
def get_file_text(self, path):
602
"""See RevisionTree.get_file_text."""
603
(store, mode, hexsha) = self._lookup_path(path)
604
if stat.S_ISREG(mode):
605
return store[hexsha].data
609
def get_symlink_target(self, path):
610
"""See RevisionTree.get_symlink_target."""
611
(store, mode, hexsha) = self._lookup_path(path)
612
if stat.S_ISLNK(mode):
613
return store[hexsha].data.decode('utf-8')
617
def get_reference_revision(self, path):
618
"""See RevisionTree.get_symlink_target."""
619
(store, mode, hexsha) = self._lookup_path(path)
620
if S_ISGITLINK(mode):
622
nested_repo = self._get_submodule_repository(path.encode('utf-8'))
623
except errors.NotBranchError:
624
return self.mapping.revision_id_foreign_to_bzr(hexsha)
626
return nested_repo.lookup_foreign_revision_id(hexsha)
630
def _comparison_data(self, entry, path):
632
return None, False, None
633
return entry.kind, entry.executable, None
635
def path_content_summary(self, path):
636
"""See Tree.path_content_summary."""
638
(store, mode, hexsha) = self._lookup_path(path)
639
except errors.NoSuchFile:
640
return ('missing', None, None, None)
641
kind = mode_kind(mode)
643
executable = mode_is_executable(mode)
644
contents = store[hexsha].data
645
return (kind, len(contents), executable,
646
osutils.sha_string(contents))
647
elif kind == 'symlink':
648
return (kind, None, None, store[hexsha].data.decode('utf-8'))
649
elif kind == 'tree-reference':
650
nested_repo = self._get_submodule_repository(path.encode('utf-8'))
651
return (kind, None, None,
652
nested_repo.lookup_foreign_revision_id(hexsha))
654
return (kind, None, None, None)
656
def find_related_paths_across_trees(self, paths, trees=[],
657
require_versioned=True):
660
if require_versioned:
661
trees = [self] + (trees if trees is not None else [])
665
if t.is_versioned(p):
670
raise errors.PathsNotVersionedError(unversioned)
671
return filter(self.is_versioned, paths)
673
def _iter_tree_contents(self, include_trees=False):
674
if self.tree is None:
676
return self.store.iter_tree_contents(
677
self.tree, include_trees=include_trees)
679
def annotate_iter(self, path, default_revision=CURRENT_REVISION):
680
"""Return an iterator of revision_id, line tuples.
682
For working trees (and mutable trees in general), the special
683
revision_id 'current:' will be used for lines that are new in this
684
tree, e.g. uncommitted changes.
685
:param default_revision: For lines that don't match a basis, mark them
686
with this revision id. Not all implementations will make use of
689
with self.lock_read():
690
# Now we have the parents of this content
691
from breezy.annotate import Annotator
692
from .annotate import AnnotateProvider
693
annotator = Annotator(AnnotateProvider(
694
self._repository._file_change_scanner))
695
this_key = (path, self.get_file_revision(path))
696
annotations = [(key[-1], line)
697
for key, line in annotator.annotate_flat(this_key)]
700
def _get_rules_searcher(self, default_searcher):
701
return default_searcher
703
def walkdirs(self, prefix=u""):
704
(store, mode, hexsha) = self._lookup_path(prefix)
706
[(store, prefix.encode('utf-8'), hexsha, self.path2id(prefix))])
708
store, path, tree_sha, parent_id = todo.popleft()
709
path_decoded = path.decode('utf-8')
710
tree = store[tree_sha]
712
for name, mode, hexsha in tree.iteritems():
713
if self.mapping.is_special_file(name):
715
child_path = posixpath.join(path, name)
716
file_id = self.path2id(child_path.decode('utf-8'))
717
if stat.S_ISDIR(mode):
718
todo.append((store, child_path, hexsha, file_id))
720
(child_path.decode('utf-8'), name.decode('utf-8'),
721
mode_kind(mode), None,
722
file_id, mode_kind(mode)))
723
yield (path_decoded, parent_id), children
726
def tree_delta_from_git_changes(changes, mappings,
728
require_versioned=False, include_root=False,
730
"""Create a TreeDelta from two git trees.
732
source and target are iterators over tuples with:
733
(filename, sha, mode)
735
(old_mapping, new_mapping) = mappings
736
if target_extras is None:
737
target_extras = set()
738
ret = delta.TreeDelta()
740
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
741
if newpath == b'' and not include_root:
743
if oldpath is not None:
744
oldpath_decoded = oldpath.decode('utf-8')
746
oldpath_decoded = None
747
if newpath is not None:
748
newpath_decoded = newpath.decode('utf-8')
750
newpath_decoded = None
751
if not (specific_files is None or
752
(oldpath is not None and
753
osutils.is_inside_or_parent_of_any(
754
specific_files, oldpath_decoded)) or
755
(newpath is not None and
756
osutils.is_inside_or_parent_of_any(
757
specific_files, newpath_decoded))):
760
if oldpath_decoded is None:
761
fileid = new_mapping.generate_file_id(newpath_decoded)
770
oldexe = mode_is_executable(oldmode)
771
oldkind = mode_kind(oldmode)
775
if oldpath_decoded == u'':
779
(oldparentpath, oldname) = osutils.split(oldpath_decoded)
780
oldparent = old_mapping.generate_file_id(oldparentpath)
781
fileid = old_mapping.generate_file_id(oldpath_decoded)
782
if newpath_decoded is None:
789
newversioned = (newpath_decoded not in target_extras)
791
newexe = mode_is_executable(newmode)
792
newkind = mode_kind(newmode)
796
if newpath_decoded == u'':
800
newparentpath, newname = osutils.split(newpath_decoded)
801
newparent = new_mapping.generate_file_id(newparentpath)
802
if old_mapping.is_special_file(oldpath):
804
if new_mapping.is_special_file(newpath):
806
if oldpath is None and newpath is None:
808
change = _mod_tree.TreeChange(
809
fileid, (oldpath_decoded, newpath_decoded), (oldsha != newsha),
810
(oldversioned, newversioned),
811
(oldparent, newparent), (oldname, newname),
812
(oldkind, newkind), (oldexe, newexe))
814
added.append((newpath, newkind))
815
elif newpath is None or newmode == 0:
816
ret.removed.append(change)
817
elif oldpath != newpath:
818
ret.renamed.append(change)
819
elif mode_kind(oldmode) != mode_kind(newmode):
820
ret.kind_changed.append(change)
821
elif oldsha != newsha or oldmode != newmode:
822
if stat.S_ISDIR(oldmode) and stat.S_ISDIR(newmode):
824
ret.modified.append(change)
826
ret.unchanged.append(change)
828
implicit_dirs = {b''}
829
for path, kind in added:
830
if kind == 'directory' or path in target_extras:
832
implicit_dirs.update(osutils.parent_directories(path))
834
for path, kind in added:
835
if kind == 'directory' and path not in implicit_dirs:
837
path_decoded = osutils.normalized_filename(path)[0]
838
parent_path, basename = osutils.split(path_decoded)
839
parent_id = new_mapping.generate_file_id(parent_path)
840
if path in target_extras:
841
ret.unversioned.append(_mod_tree.TreeChange(
842
None, (None, path_decoded),
843
True, (False, False), (None, parent_id),
844
(None, basename), (None, kind), (None, False)))
846
file_id = new_mapping.generate_file_id(path_decoded)
848
_mod_tree.TreeChange(
849
file_id, (None, path_decoded), True,
852
(None, basename), (None, kind), (None, False)))
857
def changes_from_git_changes(changes, mapping, specific_files=None,
858
include_unchanged=False, target_extras=None):
859
"""Create a iter_changes-like generator from a git stream.
861
source and target are iterators over tuples with:
862
(filename, sha, mode)
864
if target_extras is None:
865
target_extras = set()
866
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
867
if oldpath is not None:
868
oldpath_decoded = oldpath.decode('utf-8')
870
oldpath_decoded = None
871
if newpath is not None:
872
newpath_decoded = newpath.decode('utf-8')
874
newpath_decoded = None
875
if not (specific_files is None or
876
(oldpath_decoded is not None and
877
osutils.is_inside_or_parent_of_any(
878
specific_files, oldpath_decoded)) or
879
(newpath_decoded is not None and
880
osutils.is_inside_or_parent_of_any(
881
specific_files, newpath_decoded))):
883
if oldpath is not None and mapping.is_special_file(oldpath):
885
if newpath is not None and mapping.is_special_file(newpath):
887
if oldpath_decoded is None:
888
fileid = mapping.generate_file_id(newpath_decoded)
897
oldexe = mode_is_executable(oldmode)
898
oldkind = mode_kind(oldmode)
902
if oldpath_decoded == u'':
906
(oldparentpath, oldname) = osutils.split(oldpath_decoded)
907
oldparent = mapping.generate_file_id(oldparentpath)
908
fileid = mapping.generate_file_id(oldpath_decoded)
909
if newpath_decoded is None:
916
newversioned = (newpath_decoded not in target_extras)
918
newexe = mode_is_executable(newmode)
919
newkind = mode_kind(newmode)
923
if newpath_decoded == u'':
927
newparentpath, newname = osutils.split(newpath_decoded)
928
newparent = mapping.generate_file_id(newparentpath)
929
if (not include_unchanged and
930
oldkind == 'directory' and newkind == 'directory' and
931
oldpath_decoded == newpath_decoded):
933
yield _mod_tree.TreeChange(
934
fileid, (oldpath_decoded, newpath_decoded), (oldsha != newsha),
935
(oldversioned, newversioned),
936
(oldparent, newparent), (oldname, newname),
937
(oldkind, newkind), (oldexe, newexe))
940
class InterGitTrees(_mod_tree.InterTree):
941
"""InterTree that works between two git trees."""
943
_matching_from_tree_format = None
944
_matching_to_tree_format = None
945
_test_mutable_trees_to_test_trees = None
948
def is_compatible(cls, source, target):
949
return (isinstance(source, GitRevisionTree) and
950
isinstance(target, GitRevisionTree))
952
def compare(self, want_unchanged=False, specific_files=None,
953
extra_trees=None, require_versioned=False, include_root=False,
954
want_unversioned=False):
955
with self.lock_read():
956
changes, target_extras = self._iter_git_changes(
957
want_unchanged=want_unchanged,
958
require_versioned=require_versioned,
959
specific_files=specific_files,
960
extra_trees=extra_trees,
961
want_unversioned=want_unversioned)
962
return tree_delta_from_git_changes(
963
changes, (self.source.mapping, self.target.mapping),
964
specific_files=specific_files,
965
include_root=include_root, target_extras=target_extras)
967
def iter_changes(self, include_unchanged=False, specific_files=None,
968
pb=None, extra_trees=[], require_versioned=True,
969
want_unversioned=False):
970
with self.lock_read():
971
changes, target_extras = self._iter_git_changes(
972
want_unchanged=include_unchanged,
973
require_versioned=require_versioned,
974
specific_files=specific_files,
975
extra_trees=extra_trees,
976
want_unversioned=want_unversioned)
977
return changes_from_git_changes(
978
changes, self.target.mapping,
979
specific_files=specific_files,
980
include_unchanged=include_unchanged,
981
target_extras=target_extras)
983
def _iter_git_changes(self, want_unchanged=False, specific_files=None,
984
require_versioned=False, extra_trees=None,
985
want_unversioned=False):
986
raise NotImplementedError(self._iter_git_changes)
988
def find_target_path(self, path, recurse='none'):
989
ret = self.find_target_paths([path], recurse=recurse)
992
def find_source_path(self, path, recurse='none'):
993
ret = self.find_source_paths([path], recurse=recurse)
996
def find_target_paths(self, paths, recurse='none'):
999
changes = self._iter_git_changes(specific_files=paths)[0]
1000
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
1001
if oldpath in paths:
1002
ret[oldpath] = newpath
1005
if self.source.has_filename(path):
1006
if self.target.has_filename(path):
1011
raise errors.NoSuchFile(path)
1014
def find_source_paths(self, paths, recurse='none'):
1017
changes = self._iter_git_changes(specific_files=paths)[0]
1018
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
1019
if newpath in paths:
1020
ret[newpath] = oldpath
1023
if self.target.has_filename(path):
1024
if self.source.has_filename(path):
1029
raise errors.NoSuchFile(path)
1033
class InterGitRevisionTrees(InterGitTrees):
1034
"""InterTree that works between two git revision trees."""
1036
_matching_from_tree_format = None
1037
_matching_to_tree_format = None
1038
_test_mutable_trees_to_test_trees = None
1041
def is_compatible(cls, source, target):
1042
return (isinstance(source, GitRevisionTree) and
1043
isinstance(target, GitRevisionTree))
1045
def _iter_git_changes(self, want_unchanged=False, specific_files=None,
1046
require_versioned=True, extra_trees=None,
1047
want_unversioned=False):
1048
trees = [self.source]
1049
if extra_trees is not None:
1050
trees.extend(extra_trees)
1051
if specific_files is not None:
1052
specific_files = self.target.find_related_paths_across_trees(
1053
specific_files, trees,
1054
require_versioned=require_versioned)
1056
if (self.source._repository._git.object_store !=
1057
self.target._repository._git.object_store):
1058
store = OverlayObjectStore(
1059
[self.source._repository._git.object_store,
1060
self.target._repository._git.object_store])
1062
store = self.source._repository._git.object_store
1063
return store.tree_changes(
1064
self.source.tree, self.target.tree, want_unchanged=want_unchanged,
1065
include_trees=True, change_type_same=True), set()
1068
_mod_tree.InterTree.register_optimiser(InterGitRevisionTrees)
1071
class MutableGitIndexTree(mutabletree.MutableTree):
1074
self._lock_mode = None
1075
self._lock_count = 0
1076
self._versioned_dirs = None
1077
self._index_dirty = False
1078
self._submodules = None
1080
def is_versioned(self, path):
1081
with self.lock_read():
1082
path = path.rstrip('/').encode('utf-8')
1083
(index, subpath) = self._lookup_index(path)
1084
return (subpath in index or self._has_dir(path))
1086
def _has_dir(self, path):
1087
if not isinstance(path, bytes):
1088
raise TypeError(path)
1091
if self._versioned_dirs is None:
1093
return path in self._versioned_dirs
1095
def _load_dirs(self):
1096
if self._lock_mode is None:
1097
raise errors.ObjectNotLocked(self)
1098
self._versioned_dirs = set()
1099
for p, i in self._recurse_index_entries():
1100
self._ensure_versioned_dir(posixpath.dirname(p))
1102
def _ensure_versioned_dir(self, dirname):
1103
if not isinstance(dirname, bytes):
1104
raise TypeError(dirname)
1105
if dirname in self._versioned_dirs:
1108
self._ensure_versioned_dir(posixpath.dirname(dirname))
1109
self._versioned_dirs.add(dirname)
1111
def path2id(self, path):
1112
with self.lock_read():
1113
path = path.rstrip('/')
1114
if self.is_versioned(path.rstrip('/')):
1115
return self.mapping.generate_file_id(
1116
osutils.safe_unicode(path))
1119
def id2path(self, file_id, recurse='down'):
1122
if type(file_id) is not bytes:
1123
raise TypeError(file_id)
1124
with self.lock_read():
1126
path = self.mapping.parse_file_id(file_id)
1128
raise errors.NoSuchId(self, file_id)
1129
if self.is_versioned(path):
1131
raise errors.NoSuchId(self, file_id)
1133
def _set_root_id(self, file_id):
1134
raise errors.UnsupportedOperation(self._set_root_id, self)
1136
def _add(self, files, ids, kinds):
1137
for (path, file_id, kind) in zip(files, ids, kinds):
1138
if file_id is not None:
1139
raise workingtree.SettingFileIdUnsupported()
1140
path, can_access = osutils.normalized_filename(path)
1142
raise errors.InvalidNormalization(path)
1143
self._index_add_entry(path, kind)
1145
def _read_submodule_head(self, path):
1146
raise NotImplementedError(self._read_submodule_head)
1148
def _submodule_info(self):
1149
if self._submodules is None:
1151
with self.get_file('.gitmodules') as f:
1152
config = GitConfigFile.from_file(f)
1153
self._submodules = {
1154
path: (url, section)
1155
for path, url, section in parse_submodules(config)}
1156
except errors.NoSuchFile:
1157
self._submodules = {}
1158
return self._submodules
1160
def _lookup_index(self, encoded_path):
1161
if not isinstance(encoded_path, bytes):
1162
raise TypeError(encoded_path)
1164
if encoded_path in self.index:
1165
return self.index, encoded_path
1166
# TODO(jelmer): Perhaps have a cache with paths under which some
1169
remaining_path = encoded_path
1171
parts = remaining_path.split(b'/')
1172
for i in range(1, len(parts)):
1173
basepath = b'/'.join(parts[:i])
1175
(ctime, mtime, dev, ino, mode, uid, gid, size, sha,
1176
flags) = index[basepath]
1180
if S_ISGITLINK(mode):
1181
index = self._get_submodule_index(basepath)
1182
remaining_path = b'/'.join(parts[i:])
1185
return index, remaining_path
1187
return index, remaining_path
1188
return index, remaining_path
1190
def _index_del_entry(self, index, path):
1192
# TODO(jelmer): Keep track of dirty per index
1193
self._index_dirty = True
1195
def _index_add_entry(self, path, kind, flags=0, reference_revision=None):
1196
if kind == "directory":
1197
# Git indexes don't contain directories
1202
file, stat_val = self.get_file_with_stat(path)
1203
except (errors.NoSuchFile, IOError):
1204
# TODO: Rather than come up with something here, use the old
1207
stat_val = os.stat_result(
1208
(stat.S_IFREG | 0o644, 0, 0, 0, 0, 0, 0, 0, 0, 0))
1210
blob.set_raw_string(file.read())
1211
# Add object to the repository if it didn't exist yet
1212
if blob.id not in self.store:
1213
self.store.add_object(blob)
1215
elif kind == "symlink":
1218
stat_val = self._lstat(path)
1219
except EnvironmentError:
1220
# TODO: Rather than come up with something here, use the
1222
stat_val = os.stat_result(
1223
(stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
1224
blob.set_raw_string(
1225
self.get_symlink_target(path).encode("utf-8"))
1226
# Add object to the repository if it didn't exist yet
1227
if blob.id not in self.store:
1228
self.store.add_object(blob)
1230
elif kind == "tree-reference":
1231
if reference_revision is not None:
1232
hexsha = self.branch.lookup_bzr_revision_id(
1233
reference_revision)[0]
1235
hexsha = self._read_submodule_head(path)
1237
raise errors.NoCommits(path)
1239
stat_val = self._lstat(path)
1240
except EnvironmentError:
1241
stat_val = os.stat_result(
1242
(S_IFGITLINK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
1243
stat_val = os.stat_result((S_IFGITLINK, ) + stat_val[1:])
1245
raise AssertionError("unknown kind '%s'" % kind)
1246
# Add an entry to the index or update the existing entry
1247
ensure_normalized_path(path)
1248
encoded_path = path.encode("utf-8")
1249
if b'\r' in encoded_path or b'\n' in encoded_path:
1250
# TODO(jelmer): Why do we need to do this?
1251
trace.mutter('ignoring path with invalid newline in it: %r', path)
1253
(index, index_path) = self._lookup_index(encoded_path)
1254
index[index_path] = index_entry_from_stat(stat_val, hexsha, flags)
1255
self._index_dirty = True
1256
if self._versioned_dirs is not None:
1257
self._ensure_versioned_dir(index_path)
1259
def _recurse_index_entries(self, index=None, basepath=b"",
1260
recurse_nested=False):
1261
# Iterate over all index entries
1262
with self.lock_read():
1265
for path, value in index.items():
1266
(ctime, mtime, dev, ino, mode, uid, gid, size, sha,
1268
if S_ISGITLINK(mode) and recurse_nested:
1269
subindex = self._get_submodule_index(path)
1270
for entry in self._recurse_index_entries(
1271
index=subindex, basepath=path,
1272
recurse_nested=recurse_nested):
1275
yield (posixpath.join(basepath, path), value)
1277
def iter_entries_by_dir(self, specific_files=None,
1278
recurse_nested=False):
1279
with self.lock_read():
1280
if specific_files is not None:
1281
specific_files = set(specific_files)
1283
specific_files = None
1284
root_ie = self._get_dir_ie(u"", None)
1286
if specific_files is None or u"" in specific_files:
1287
ret[(u"", u"")] = root_ie
1288
dir_ids = {u"": root_ie.file_id}
1289
for path, value in self._recurse_index_entries(
1290
recurse_nested=recurse_nested):
1291
if self.mapping.is_special_file(path):
1293
path = path.decode("utf-8")
1294
if specific_files is not None and path not in specific_files:
1296
(parent, name) = posixpath.split(path)
1298
file_ie = self._get_file_ie(name, path, value, None)
1299
except errors.NoSuchFile:
1301
if specific_files is None:
1302
for (dir_path, dir_ie) in self._add_missing_parent_ids(
1304
ret[(posixpath.dirname(dir_path), dir_path)] = dir_ie
1305
file_ie.parent_id = self.path2id(parent)
1306
ret[(posixpath.dirname(path), path)] = file_ie
1307
# Special casing for directories
1309
for path in specific_files:
1310
key = (posixpath.dirname(path), path)
1311
if key not in ret and self.is_versioned(path):
1312
ret[key] = self._get_dir_ie(path, self.path2id(key[0]))
1313
return ((path, ie) for ((_, path), ie) in sorted(viewitems(ret)))
1315
def iter_references(self):
1316
if self.supports_tree_reference():
1317
# TODO(jelmer): Implement a more efficient version of this
1318
for path, entry in self.iter_entries_by_dir():
1319
if entry.kind == 'tree-reference':
1322
def _get_dir_ie(self, path, parent_id):
1323
file_id = self.path2id(path)
1324
return GitTreeDirectory(file_id,
1325
posixpath.basename(path).strip("/"), parent_id)
1327
def _get_file_ie(self, name, path, value, parent_id):
1328
if not isinstance(name, text_type):
1329
raise TypeError(name)
1330
if not isinstance(path, text_type):
1331
raise TypeError(path)
1332
if not isinstance(value, tuple) or len(value) != 10:
1333
raise TypeError(value)
1334
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
1335
file_id = self.path2id(path)
1336
if not isinstance(file_id, bytes):
1337
raise TypeError(file_id)
1338
kind = mode_kind(mode)
1339
ie = entry_factory[kind](file_id, name, parent_id)
1340
if kind == 'symlink':
1341
ie.symlink_target = self.get_symlink_target(path)
1342
elif kind == 'tree-reference':
1343
ie.reference_revision = self.get_reference_revision(path)
1346
data = self.get_file_text(path)
1347
except errors.NoSuchFile:
1349
except IOError as e:
1350
if e.errno != errno.ENOENT:
1354
data = self.branch.repository._git.object_store[sha].data
1355
ie.text_sha1 = osutils.sha_string(data)
1356
ie.text_size = len(data)
1357
ie.executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
1360
def _add_missing_parent_ids(self, path, dir_ids):
1363
parent = posixpath.dirname(path).strip("/")
1364
ret = self._add_missing_parent_ids(parent, dir_ids)
1365
parent_id = dir_ids[parent]
1366
ie = self._get_dir_ie(path, parent_id)
1367
dir_ids[path] = ie.file_id
1368
ret.append((path, ie))
1371
def _comparison_data(self, entry, path):
1373
return None, False, None
1374
return entry.kind, entry.executable, None
1376
def _unversion_path(self, path):
1377
if self._lock_mode is None:
1378
raise errors.ObjectNotLocked(self)
1379
encoded_path = path.encode("utf-8")
1381
(index, subpath) = self._lookup_index(encoded_path)
1383
self._index_del_entry(index, encoded_path)
1385
# A directory, perhaps?
1386
# TODO(jelmer): Deletes that involve submodules?
1387
for p in list(index):
1388
if p.startswith(subpath + b"/"):
1390
self._index_del_entry(index, p)
1393
self._versioned_dirs = None
1396
def unversion(self, paths):
1397
with self.lock_tree_write():
1399
if self._unversion_path(path) == 0:
1400
raise errors.NoSuchFile(path)
1401
self._versioned_dirs = None
1407
def update_basis_by_delta(self, revid, delta):
1408
# TODO(jelmer): This shouldn't be called, it's inventory specific.
1409
for (old_path, new_path, file_id, ie) in delta:
1410
if old_path is not None:
1411
(index, old_subpath) = self._lookup_index(
1412
old_path.encode('utf-8'))
1413
if old_subpath in index:
1414
self._index_del_entry(index, old_subpath)
1415
self._versioned_dirs = None
1416
if new_path is not None and ie.kind != 'directory':
1417
self._index_add_entry(new_path, ie.kind)
1419
self._set_merges_from_parent_ids([])
1421
def move(self, from_paths, to_dir=None, after=None):
1423
with self.lock_tree_write():
1424
to_abs = self.abspath(to_dir)
1425
if not os.path.isdir(to_abs):
1426
raise errors.BzrMoveFailedError('', to_dir,
1427
errors.NotADirectory(to_abs))
1429
for from_rel in from_paths:
1430
from_tail = os.path.split(from_rel)[-1]
1431
to_rel = os.path.join(to_dir, from_tail)
1432
self.rename_one(from_rel, to_rel, after=after)
1433
rename_tuples.append((from_rel, to_rel))
1435
return rename_tuples
1437
def rename_one(self, from_rel, to_rel, after=None):
1438
from_path = from_rel.encode("utf-8")
1439
to_rel, can_access = osutils.normalized_filename(to_rel)
1441
raise errors.InvalidNormalization(to_rel)
1442
to_path = to_rel.encode("utf-8")
1443
with self.lock_tree_write():
1445
# Perhaps it's already moved?
1447
not self.has_filename(from_rel) and
1448
self.has_filename(to_rel) and
1449
not self.is_versioned(to_rel))
1451
if not self.has_filename(to_rel):
1452
raise errors.BzrMoveFailedError(
1453
from_rel, to_rel, errors.NoSuchFile(to_rel))
1454
if self.basis_tree().is_versioned(to_rel):
1455
raise errors.BzrMoveFailedError(
1456
from_rel, to_rel, errors.AlreadyVersionedError(to_rel))
1458
kind = self.kind(to_rel)
1461
to_kind = self.kind(to_rel)
1462
except errors.NoSuchFile:
1463
exc_type = errors.BzrRenameFailedError
1466
exc_type = errors.BzrMoveFailedError
1467
if self.is_versioned(to_rel):
1468
raise exc_type(from_rel, to_rel,
1469
errors.AlreadyVersionedError(to_rel))
1470
if not self.has_filename(from_rel):
1471
raise errors.BzrMoveFailedError(
1472
from_rel, to_rel, errors.NoSuchFile(from_rel))
1473
kind = self.kind(from_rel)
1474
if not self.is_versioned(from_rel) and kind != 'directory':
1475
raise exc_type(from_rel, to_rel,
1476
errors.NotVersionedError(from_rel))
1477
if self.has_filename(to_rel):
1478
raise errors.RenameFailedFilesExist(
1479
from_rel, to_rel, errors.FileExists(to_rel))
1481
kind = self.kind(from_rel)
1483
if not after and kind != 'directory':
1484
(index, from_subpath) = self._lookup_index(from_path)
1485
if from_subpath not in index:
1487
raise errors.BzrMoveFailedError(
1489
errors.NotVersionedError(path=from_rel))
1493
self._rename_one(from_rel, to_rel)
1494
except OSError as e:
1495
if e.errno == errno.ENOENT:
1496
raise errors.BzrMoveFailedError(
1497
from_rel, to_rel, errors.NoSuchFile(to_rel))
1499
if kind != 'directory':
1500
(index, from_index_path) = self._lookup_index(from_path)
1502
self._index_del_entry(index, from_path)
1505
self._index_add_entry(to_rel, kind)
1507
todo = [(p, i) for (p, i) in self._recurse_index_entries()
1508
if p.startswith(from_path + b'/')]
1509
for child_path, child_value in todo:
1510
(child_to_index, child_to_index_path) = self._lookup_index(
1511
posixpath.join(to_path, posixpath.relpath(child_path, from_path)))
1512
child_to_index[child_to_index_path] = child_value
1513
# TODO(jelmer): Mark individual index as dirty
1514
self._index_dirty = True
1515
(child_from_index, child_from_index_path) = self._lookup_index(
1517
self._index_del_entry(
1518
child_from_index, child_from_index_path)
1520
self._versioned_dirs = None
1523
def find_related_paths_across_trees(self, paths, trees=[],
1524
require_versioned=True):
1528
if require_versioned:
1529
trees = [self] + (trees if trees is not None else [])
1533
if t.is_versioned(p):
1538
raise errors.PathsNotVersionedError(unversioned)
1540
return filter(self.is_versioned, paths)
1542
def path_content_summary(self, path):
1543
"""See Tree.path_content_summary."""
1545
stat_result = self._lstat(path)
1546
except OSError as e:
1547
if getattr(e, 'errno', None) == errno.ENOENT:
1549
return ('missing', None, None, None)
1550
# propagate other errors
1552
kind = mode_kind(stat_result.st_mode)
1554
return self._file_content_summary(path, stat_result)
1555
elif kind == 'directory':
1556
# perhaps it looks like a plain directory, but it's really a
1558
if self._directory_is_tree_reference(path):
1559
kind = 'tree-reference'
1560
return kind, None, None, None
1561
elif kind == 'symlink':
1562
target = osutils.readlink(self.abspath(path))
1563
return ('symlink', None, None, target)
1565
return (kind, None, None, None)
1567
def stored_kind(self, relpath):
1568
(index, index_path) = self._lookup_index(relpath.encode('utf-8'))
1572
mode = index[index_path].mode
1576
if S_ISGITLINK(mode):
1577
return 'tree-reference'
1580
def kind(self, relpath):
1581
kind = osutils.file_kind(self.abspath(relpath))
1582
if kind == 'directory':
1583
if self._directory_is_tree_reference(relpath):
1584
return 'tree-reference'
1589
def _live_entry(self, relpath):
1590
raise NotImplementedError(self._live_entry)
1592
def get_transform(self, pb=None):
1593
from ..transform import TreeTransform
1594
return TreeTransform(self, pb=pb)
1598
class InterIndexGitTree(InterGitTrees):
1599
"""InterTree that works between a Git revision tree and an index."""
1601
def __init__(self, source, target):
1602
super(InterIndexGitTree, self).__init__(source, target)
1603
self._index = target.index
1606
def is_compatible(cls, source, target):
1607
return (isinstance(source, GitRevisionTree) and
1608
isinstance(target, MutableGitIndexTree))
1610
def _iter_git_changes(self, want_unchanged=False, specific_files=None,
1611
require_versioned=False, extra_trees=None,
1612
want_unversioned=False):
1613
trees = [self.source]
1614
if extra_trees is not None:
1615
trees.extend(extra_trees)
1616
if specific_files is not None:
1617
specific_files = self.target.find_related_paths_across_trees(
1618
specific_files, trees,
1619
require_versioned=require_versioned)
1620
# TODO(jelmer): Restrict to specific_files, for performance reasons.
1621
with self.lock_read():
1622
return changes_between_git_tree_and_working_copy(
1623
self.source.store, self.source.tree,
1624
self.target, want_unchanged=want_unchanged,
1625
want_unversioned=want_unversioned)
1628
_mod_tree.InterTree.register_optimiser(InterIndexGitTree)
1631
def changes_between_git_tree_and_working_copy(store, from_tree_sha, target,
1632
want_unchanged=False,
1633
want_unversioned=False):
1634
"""Determine the changes between a git tree and a working tree with index.
1639
# Report dirified directories to commit_tree first, so that they can be
1640
# replaced with non-empty directories if they have contents.
1642
trust_executable = target._supports_executable()
1643
for path, index_entry in target._recurse_index_entries():
1645
live_entry = target._live_entry(path)
1646
except EnvironmentError as e:
1647
if e.errno == errno.ENOENT:
1648
# Entry was removed; keep it listed, but mark it as gone.
1649
blobs[path] = (ZERO_SHA, 0)
1653
if live_entry is None:
1654
# Entry was turned into a directory.
1655
# Maybe it's just a submodule that's not checked out?
1656
if S_ISGITLINK(index_entry.mode):
1657
blobs[path] = (index_entry.sha, index_entry.mode)
1659
dirified.append((path, Tree().id, stat.S_IFDIR))
1660
store.add_object(Tree())
1662
mode = live_entry.mode
1663
if not trust_executable:
1664
if mode_is_executable(index_entry.mode):
1668
blobs[path] = (live_entry.sha, cleanup_mode(live_entry.mode))
1669
if want_unversioned:
1670
for e in target.extras():
1671
st = target._lstat(e)
1673
np, accessible = osutils.normalized_filename(e)
1674
except UnicodeDecodeError:
1675
raise errors.BadFilenameEncoding(
1677
if stat.S_ISDIR(st.st_mode):
1680
blob = blob_from_path_and_stat(
1681
target.abspath(e).encode(osutils._fs_enc), st)
1682
store.add_object(blob)
1683
np = np.encode('utf-8')
1684
blobs[np] = (blob.id, cleanup_mode(st.st_mode))
1686
to_tree_sha = commit_tree(
1687
store, dirified + [(p, s, m) for (p, (s, m)) in blobs.items()])
1688
return store.tree_changes(
1689
from_tree_sha, to_tree_sha, include_trees=True,
1690
want_unchanged=want_unchanged, change_type_same=True), extras