67
83
self.basedir = bzrdir.root_transport.local_abspath('.')
68
84
self.bzrdir = bzrdir
69
85
self.repository = repo
86
self.store = self.repository._git.object_store
70
87
self.mapping = self.repository.get_mapping()
71
88
self._branch = branch
72
89
self._transport = bzrdir.transport
74
self.controldir = self.bzrdir.transport.local_abspath('bzr')
77
os.makedirs(self.controldir)
78
os.makedirs(os.path.join(self.controldir, 'lock'))
82
self._control_files = lockable_files.LockableFiles(
83
transport.get_transport(self.controldir), 'lock', lockdir.LockDir)
84
90
self._format = GitWorkingTreeFormat()
92
self._versioned_dirs = None
86
93
self.views = self._make_views()
94
self._rules_searcher = None
87
95
self._detect_case_handling()
97
self._fileid_map = self._basis_fileid_map.copy()
98
self._lock_mode = None
102
"""Lock the repository for read operations.
104
:return: A bzrlib.lock.LogicalLockResult.
106
if not self._lock_mode:
107
self._lock_mode = 'r'
111
self._lock_count += 1
112
self.branch.lock_read()
113
return lock.LogicalLockResult(self.unlock)
115
def lock_tree_write(self):
116
if not self._lock_mode:
117
self._lock_mode = 'w'
120
elif self._lock_mode == 'r':
121
raise errors.ReadOnlyError(self)
124
self.branch.lock_read()
125
return lock.LogicalLockResult(self.unlock)
127
def lock_write(self, token=None):
128
if not self._lock_mode:
129
self._lock_mode = 'w'
132
elif self._lock_mode == 'r':
133
raise errors.ReadOnlyError(self)
136
self.branch.lock_write()
137
return lock.LogicalLockResult(self.unlock)
140
return self._lock_count >= 1
142
def get_physical_lock_status(self):
146
if not self._lock_count:
147
return lock.cant_unlock_not_held(self)
150
self._lock_count -= 1
151
if self._lock_count > 0:
153
self._lock_mode = None
155
def _detect_case_handling(self):
157
self._transport.stat(".git/cOnFiG")
158
except errors.NoSuchFile:
159
self.case_sensitive = True
161
self.case_sensitive = False
163
def merge_modified(self):
166
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
167
self.set_parent_ids([p for p, t in parents_list])
169
def _index_add_entry(self, path, file_id, kind):
170
assert self._lock_mode is not None
171
assert isinstance(path, basestring)
172
assert type(file_id) == str or file_id is None
173
if kind == "directory":
174
# Git indexes don't contain directories
179
file, stat_val = self.get_file_with_stat(file_id, path)
180
except (errors.NoSuchFile, IOError):
181
# TODO: Rather than come up with something here, use the old index
183
stat_val = os.stat_result(
184
(stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0))
185
blob.set_raw_string(file.read())
186
elif kind == "symlink":
189
stat_val = os.lstat(self.abspath(path))
190
except (errors.NoSuchFile, OSError):
191
# TODO: Rather than come up with something here, use the
193
stat_val = os.stat_result(
194
(stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
196
self.get_symlink_target(file_id, path).encode("utf-8"))
198
raise AssertionError("unknown kind '%s'" % kind)
199
# Add object to the repository if it didn't exist yet
200
if not blob.id in self.store:
201
self.store.add_object(blob)
202
# Add an entry to the index or update the existing entry
204
encoded_path = path.encode("utf-8")
205
self.index[encoded_path] = index_entry_from_stat(
206
stat_val, blob.id, flags)
207
if self._versioned_dirs is not None:
208
self._ensure_versioned_dir(encoded_path)
210
def _ensure_versioned_dir(self, dirname):
211
if dirname in self._versioned_dirs:
214
self._ensure_versioned_dir(posixpath.dirname(dirname))
215
self._versioned_dirs.add(dirname)
217
def _load_dirs(self):
218
assert self._lock_mode is not None
219
self._versioned_dirs = set()
221
self._ensure_versioned_dir(posixpath.dirname(p))
223
def _unversion_path(self, path):
224
assert self._lock_mode is not None
225
encoded_path = path.encode("utf-8")
227
del self.index[encoded_path]
229
# A directory, perhaps?
230
for p in list(self.index):
231
if p.startswith(encoded_path+"/"):
233
# FIXME: remove empty directories
235
@needs_tree_write_lock
236
def unversion(self, file_ids):
237
for file_id in file_ids:
238
path = self.id2path(file_id)
239
self._unversion_path(path)
242
def check_state(self):
243
"""Check that the working state is/isn't valid."""
246
@needs_tree_write_lock
247
def remove(self, files, verbose=False, to_file=None, keep_files=True,
249
"""Remove nominated files from the working tree metadata.
251
:param files: File paths relative to the basedir.
252
:param keep_files: If true, the files will also be kept.
253
:param force: Delete files and directories, even if they are changed
254
and even if the directories are not empty.
256
all_files = set() # specified and nested files
258
if isinstance(files, basestring):
264
files = list(all_files)
267
return # nothing to do
269
# Sort needed to first handle directory content before the directory
270
files.sort(reverse=True)
272
def backup(file_to_backup):
273
abs_path = self.abspath(file_to_backup)
274
backup_name = self.bzrdir._available_backup_name(file_to_backup)
275
osutils.rename(abs_path, self.abspath(backup_name))
276
return "removed %s (but kept a copy: %s)" % (
277
file_to_backup, backup_name)
280
fid = self.path2id(f)
282
message = "%s is not versioned." % (f,)
284
abs_path = self.abspath(f)
286
# having removed it, it must be either ignored or unknown
287
if self.is_ignored(f):
291
# XXX: Really should be a more abstract reporter interface
292
kind_ch = osutils.kind_marker(self.kind(fid))
293
to_file.write(new_status + ' ' + f + kind_ch + '\n')
295
# FIXME: _unversion_path() is O(size-of-index) for directories
296
self._unversion_path(f)
297
message = "removed %s" % (f,)
298
if osutils.lexists(abs_path):
299
if (osutils.isdir(abs_path) and
300
len(os.listdir(abs_path)) > 0):
302
osutils.rmtree(abs_path)
303
message = "deleted %s" % (f,)
308
osutils.delete_any(abs_path)
309
message = "deleted %s" % (f,)
311
# print only one message (if any) per file.
312
if message is not None:
316
def _add(self, files, ids, kinds):
317
for (path, file_id, kind) in zip(files, ids, kinds):
318
if file_id is not None:
319
self._fileid_map.set_file_id(path.encode("utf-8"), file_id)
321
file_id = self._fileid_map.lookup_file_id(path.encode("utf-8"))
322
self._index_add_entry(path, file_id, kind)
324
@needs_tree_write_lock
325
def smart_add(self, file_list, recurse=True, action=None, save=True):
329
for filepath in osutils.canonical_relpaths(self.basedir, file_list):
330
abspath = self.abspath(filepath)
331
kind = osutils.file_kind(abspath)
332
if action is not None:
333
file_id = action(self, None, filepath, kind)
336
if kind in ("file", "symlink"):
338
self._index_add_entry(filepath, file_id, kind)
339
added.append(filepath)
340
elif kind == "directory":
342
user_dirs.append(filepath)
344
raise errors.BadFileKindError(filename=abspath, kind=kind)
345
for user_dir in user_dirs:
346
abs_user_dir = self.abspath(user_dir)
347
for name in os.listdir(abs_user_dir):
348
subp = os.path.join(user_dir, name)
349
if self.is_control_filename(subp) or self.mapping.is_special_file(subp):
351
ignore_glob = self.is_ignored(subp)
352
if ignore_glob is not None:
353
ignored.setdefault(ignore_glob, []).append(subp)
355
abspath = self.abspath(subp)
356
kind = osutils.file_kind(abspath)
357
if kind == "directory":
358
user_dirs.append(subp)
360
if action is not None:
361
file_id = action(self, None, filepath, kind)
365
self._index_add_entry(subp, file_id, kind)
368
return added, ignored
370
def _set_root_id(self, file_id):
371
self._fileid_map.set_file_id("", file_id)
373
@needs_tree_write_lock
374
def move(self, from_paths, to_dir=None, after=False):
376
to_abs = self.abspath(to_dir)
377
if not os.path.isdir(to_abs):
378
raise errors.BzrMoveFailedError('', to_dir,
379
errors.NotADirectory(to_abs))
381
for from_rel in from_paths:
382
from_tail = os.path.split(from_rel)[-1]
383
to_rel = os.path.join(to_dir, from_tail)
384
self.rename_one(from_rel, to_rel, after=after)
385
rename_tuples.append((from_rel, to_rel))
389
@needs_tree_write_lock
390
def rename_one(self, from_rel, to_rel, after=False):
391
from_path = from_rel.encode("utf-8")
392
to_path = to_rel.encode("utf-8")
393
if not self.has_filename(to_rel):
394
raise errors.BzrMoveFailedError(from_rel, to_rel,
395
errors.NoSuchFile(to_rel))
396
if not from_path in self.index:
397
raise errors.BzrMoveFailedError(from_rel, to_rel,
398
errors.NotVersionedError(path=from_rel))
400
os.rename(self.abspath(from_rel), self.abspath(to_rel))
401
self.index[to_path] = self.index[from_path]
402
del self.index[from_path]
405
def get_root_id(self):
406
return self.path2id("")
408
def _has_dir(self, path):
411
if self._versioned_dirs is None:
413
return path in self._versioned_dirs
416
def path2id(self, path):
417
encoded_path = path.encode("utf-8")
418
if self._is_versioned(encoded_path):
419
return self._fileid_map.lookup_file_id(encoded_path)
422
def _iter_files_recursive(self, from_dir=None):
425
for (dirpath, dirnames, filenames) in os.walk(self.abspath(from_dir)):
426
dir_relpath = dirpath[len(self.basedir):].strip("/")
427
if self.bzrdir.is_control_filename(dir_relpath):
429
for filename in filenames:
430
if not self.mapping.is_special_file(filename):
431
yield os.path.join(dir_relpath, filename)
90
435
"""Yield all unversioned files in this WorkingTree.
92
for (dirpath, dirnames, filenames) in os.walk(self.basedir):
93
if self.bzrdir.is_control_filename(dirpath[len(self.basedir):].strip("/")):
95
for filename in filenames:
96
relpath = os.path.join(dirpath[len(self.basedir):].strip("/"), filename)
97
if not relpath in self.index:
102
# non-implementation specific cleanup
105
# reverse order of locking.
107
return self._control_files.unlock()
111
def is_control_filename(self, path):
112
return os.path.basename(path) == ".git"
114
def _rewrite_index(self):
116
for path, entry in self._inventory.iter_entries():
117
if entry.kind == "directory":
118
# Git indexes don't contain directories
120
if entry.kind == "file":
123
file, stat_val = self.get_file_with_stat(entry.file_id, path)
124
except (errors.NoSuchFile, IOError):
125
# TODO: Rather than come up with something here, use the old index
127
from posix import stat_result
128
stat_val = stat_result((stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0))
129
blob.set_raw_string(file.read())
130
elif entry.kind == "symlink":
133
stat_val = os.lstat(self.abspath(path))
134
except (errors.NoSuchFile, OSError):
135
# TODO: Rather than come up with something here, use the
137
from posix import stat_result
138
stat_val = stat_result((stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
139
blob.set_raw_string(entry.symlink_target)
141
raise AssertionError("unknown kind '%s'" % entry.kind)
142
# Add object to the repository if it didn't exist yet
143
if not blob.id in self.repository._git.object_store:
144
self.repository._git.object_store.add_object(blob)
145
# Add an entry to the index or update the existing entry
147
self.index[path.encode("utf-8")] = (stat_val.st_ctime, stat_val.st_mtime, stat_val.st_dev, stat_val.st_ino, stat_val.st_mode, stat_val.st_uid, stat_val.st_gid, stat_val.st_size, blob.id, flags)
437
return set(self._iter_files_recursive()) - set(self.index)
439
@needs_tree_write_lock
150
441
# TODO: Maybe this should only write on dirty ?
151
if self._control_files._lock_mode != 'w':
442
if self._lock_mode != 'w':
152
443
raise errors.NotWriteLocked(self)
153
self._rewrite_index()
154
444
self.index.write()
155
self._inventory_is_modified = False
448
for path in self.index:
449
yield self.path2id(path)
451
for path in self._versioned_dirs:
452
yield self.path2id(path)
454
def has_or_had_id(self, file_id):
455
if self.has_id(file_id):
457
if self.had_id(file_id):
461
def had_id(self, file_id):
462
path = self._basis_fileid_map.lookup_file_id(file_id)
464
head = self.repository._git.head()
466
# Assume no if basis is not accessible
470
root_tree = self.store[head].tree
472
tree_lookup_path(self.store.__getitem__, root_tree, path)
478
def has_id(self, file_id):
480
self.id2path(file_id)
481
except errors.NoSuchId:
487
def id2path(self, file_id):
488
assert type(file_id) is str, "file id not a string: %r" % file_id
489
file_id = osutils.safe_utf8(file_id)
490
path = self._fileid_map.lookup_path(file_id)
491
# FIXME: What about directories?
492
if self._is_versioned(path):
493
return path.decode("utf-8")
494
raise errors.NoSuchId(self, file_id)
496
def get_file_mtime(self, file_id, path=None):
497
"""See Tree.get_file_mtime."""
499
path = self.id2path(file_id)
500
return os.lstat(self.abspath(path)).st_mtime
157
502
def get_ignore_list(self):
158
503
ignoreset = getattr(self, '_ignoreset', None)
205
554
def revision_tree(self, revid):
206
555
return self.repository.revision_tree(revid)
557
def _is_versioned(self, path):
558
assert self._lock_mode is not None
559
return (path in self.index or self._has_dir(path))
561
def filter_unversioned_files(self, files):
562
return set([p for p in files if not self._is_versioned(p.encode("utf-8"))])
564
def _get_dir_ie(self, path, parent_id):
565
file_id = self.path2id(path)
566
return inventory.InventoryDirectory(file_id,
567
posixpath.basename(path).strip("/"), parent_id)
569
def _add_missing_parent_ids(self, path, dir_ids):
572
parent = posixpath.dirname(path).strip("/")
573
ret = self._add_missing_parent_ids(parent, dir_ids)
574
parent_id = dir_ids[parent]
575
ie = self._get_dir_ie(path, parent_id)
576
dir_ids[path] = ie.file_id
577
ret.append((path, ie))
580
def _get_file_ie(self, name, path, value, parent_id):
581
assert isinstance(name, unicode)
582
assert isinstance(path, unicode)
583
assert isinstance(value, tuple) and len(value) == 10
584
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
585
file_id = self.path2id(path)
586
if type(file_id) != str:
588
kind = mode_kind(mode)
589
ie = inventory.entry_factory[kind](file_id, name, parent_id)
590
if kind == 'symlink':
591
ie.symlink_target = self.get_symlink_target(file_id)
593
data = self.get_file_text(file_id, path)
594
ie.text_sha1 = osutils.sha_string(data)
595
ie.text_size = len(data)
596
ie.executable = self.is_executable(file_id, path)
600
def _is_executable_from_path_and_stat_from_stat(self, path, stat_result):
601
mode = stat_result.st_mode
602
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
605
def stored_kind(self, file_id, path=None):
607
path = self.id2path(file_id)
609
return mode_kind(self.index[path.encode("utf-8")][4])
611
# Maybe it's a directory?
612
if self._has_dir(path):
614
raise errors.NoSuchId(self, file_id)
616
def is_executable(self, file_id, path=None):
617
if getattr(self, "_supports_executable", osutils.supports_executable)():
619
path = self.id2path(file_id)
620
mode = os.lstat(self.abspath(path)).st_mode
621
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
623
basis_tree = self.basis_tree()
624
if file_id in basis_tree:
625
return basis_tree.is_executable(file_id)
626
# Default to not executable
629
def _is_executable_from_path_and_stat(self, path, stat_result):
630
if getattr(self, "_supports_executable", osutils.supports_executable)():
631
return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
633
return self._is_executable_from_path_and_stat_from_basis(path, stat_result)
636
def list_files(self, include_root=False, from_dir=None, recursive=True):
637
# FIXME: Yield non-versioned files
641
fk_entries = {'directory': workingtree.TreeDirectory,
642
'file': workingtree.TreeFile,
643
'symlink': workingtree.TreeLink}
644
root_ie = self._get_dir_ie(u"", None)
645
if include_root and not from_dir:
646
yield "", "V", root_ie.kind, root_ie.file_id, root_ie
647
dir_ids[u""] = root_ie.file_id
649
path_iterator = self._iter_files_recursive(from_dir)
654
start = os.path.join(self.basedir, from_dir)
655
path_iterator = sorted([os.path.join(from_dir, name) for name in
656
os.listdir(start) if not self.bzrdir.is_control_filename(name)
657
and not self.mapping.is_special_file(name)])
658
for path in path_iterator:
660
value = self.index[path]
663
path = path.decode("utf-8")
664
parent, name = posixpath.split(path)
665
for dir_path, dir_ie in self._add_missing_parent_ids(parent, dir_ids):
666
yield dir_path, "V", dir_ie.kind, dir_ie.file_id, dir_ie
667
if value is not None:
668
ie = self._get_file_ie(name, path, value, dir_ids[parent])
669
yield path, "V", ie.kind, ie.file_id, ie
671
kind = osutils.file_kind(self.abspath(path))
672
ie = fk_entries[kind]()
673
yield path, "?", kind, None, ie
676
def all_file_ids(self):
677
ids = {u"": self.path2id("")}
678
for path in self.index:
679
if self.mapping.is_special_file(path):
681
path = path.decode("utf-8")
682
parent = posixpath.dirname(path).strip("/")
683
for e in self._add_missing_parent_ids(parent, ids):
685
ids[path] = self.path2id(path)
686
return set(ids.values())
688
def _directory_is_tree_reference(self, path):
689
# FIXME: Check .gitsubmodules for path
693
def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
694
# FIXME: Is return order correct?
696
raise NotImplementedError(self.iter_entries_by_dir)
697
if specific_file_ids is not None:
698
specific_paths = [self.id2path(file_id) for file_id in specific_file_ids]
699
if specific_paths in ([u""], []):
700
specific_paths = None
702
specific_paths = set(specific_paths)
704
specific_paths = None
705
root_ie = self._get_dir_ie(u"", None)
706
if specific_paths is None:
708
dir_ids = {u"": root_ie.file_id}
709
for path, value in self.index.iteritems():
710
if self.mapping.is_special_file(path):
712
path = path.decode("utf-8")
713
if specific_paths is not None and not path in specific_paths:
715
(parent, name) = posixpath.split(path)
717
file_ie = self._get_file_ie(name, path, value, None)
720
for (dir_path, dir_ie) in self._add_missing_parent_ids(parent,
722
yield dir_path, dir_ie
723
file_ie.parent_id = self.path2id(parent)
209
727
def conflicts(self):
729
return _mod_conflicts.ConflictList()
731
def update_basis_by_delta(self, new_revid, delta):
732
# The index just contains content, which won't have changed.
736
def get_canonical_inventory_path(self, path):
738
if p.lower() == path.lower():
744
def _walkdirs(self, prefix=""):
747
per_dir = defaultdict(list)
748
for path, value in self.index.iteritems():
749
if self.mapping.is_special_file(path):
751
if not path.startswith(prefix):
753
(dirname, child_name) = posixpath.split(path)
754
dirname = dirname.decode("utf-8")
755
dir_file_id = self.path2id(dirname)
756
assert isinstance(value, tuple) and len(value) == 10
757
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
758
stat_result = os.stat_result((mode, ino,
759
dev, 1, uid, gid, size,
761
per_dir[(dirname, dir_file_id)].append(
762
(path.decode("utf-8"), child_name.decode("utf-8"),
763
mode_kind(mode), stat_result,
764
self.path2id(path.decode("utf-8")),
766
return per_dir.iteritems()
768
def _lookup_entry(self, path, update_index=False):
769
assert type(path) == str
770
entry = self.index[path]
771
index_mode = entry[-6]
772
index_sha = entry[-2]
773
disk_path = os.path.join(self.basedir, path)
774
disk_stat = os.lstat(disk_path)
775
disk_mtime = disk_stat.st_mtime
776
if isinstance(entry[1], tuple):
777
index_mtime = entry[1][0]
779
index_mtime = int(entry[1])
780
mtime_delta = (disk_mtime - index_mtime)
781
disk_mode = cleanup_mode(disk_stat.st_mode)
782
if mtime_delta > 0 or disk_mode != index_mode:
783
if stat.S_ISDIR(disk_mode):
785
subrepo = Repo(disk_path)
786
except NotGitRepository:
789
disk_mode = S_IFGITLINK
790
git_id = subrepo.head()
791
elif stat.S_ISLNK(disk_mode):
792
blob = Blob.from_string(os.readlink(disk_path).encode('utf-8'))
794
elif stat.S_ISREG(disk_mode):
795
with open(disk_path, 'r') as f:
796
blob = Blob.from_string(f.read())
802
self.index[path] = index_entry_from_stat(disk_stat, git_id, flags, disk_mode)
803
return (git_id, disk_mode)
804
return (index_sha, index_mode)
214
807
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):
809
_tree_class = GitWorkingTree
811
supports_versioned_directories = False
217
814
def _matchingbzrdir(self):
218
from bzrlib.plugins.git import LocalGitControlDirFormat
815
from bzrlib.plugins.git.dir import LocalGitControlDirFormat
219
816
return LocalGitControlDirFormat()
221
818
def get_format_description(self):
222
819
return "Git Working Tree"
821
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
822
accelerator_tree=None, hardlink=False):
823
"""See WorkingTreeFormat.initialize()."""
824
if not isinstance(a_bzrdir, LocalGitDir):
825
raise errors.IncompatibleFormat(self, a_bzrdir)
826
index = Index(a_bzrdir.root_transport.local_abspath(".git/index"))
828
return GitWorkingTree(a_bzrdir, a_bzrdir.open_repository(),
829
a_bzrdir.open_branch(), index)
225
832
class InterIndexGitTree(tree.InterTree):
226
833
"""InterTree that works between a Git revision tree and an index."""
235
842
return (isinstance(source, GitRevisionTree) and
236
843
isinstance(target, GitWorkingTree))
238
846
def compare(self, want_unchanged=False, specific_files=None,
239
847
extra_trees=None, require_versioned=False, include_root=False,
240
848
want_unversioned=False):
241
changes = self._index.changes_from_tree(
242
self.source._repository._git.object_store, self.source.tree,
243
want_unchanged=want_unchanged)
244
source_fileid_map = self.source.mapping.get_fileid_map(
245
self.source._repository._git.object_store.__getitem__,
247
if self.target.mapping.BZR_FILE_IDS_FILE is not None:
248
file_id = self.target.path2id(
249
self.target.mapping.BZR_FILE_IDS_FILE)
251
target_fileid_map = {}
253
target_fileid_map = self.target.mapping.import_fileid_map(Blob.from_string(self.target.get_file_text(file_id)))
255
target_fileid_map = {}
256
target_fileid_map = GitFileIdMap(target_fileid_map, self.target.mapping)
849
# FIXME: Handle include_root
850
changes = changes_between_git_tree_and_index(
851
self.source.store, self.source.tree,
852
self.target, want_unchanged=want_unchanged,
853
want_unversioned=want_unversioned)
854
source_fileid_map = self.source._fileid_map
855
target_fileid_map = self.target._fileid_map
257
856
ret = tree_delta_from_git_changes(changes, self.target.mapping,
258
857
(source_fileid_map, target_fileid_map),
259
858
specific_file=specific_files, require_versioned=require_versioned)
260
859
if want_unversioned:
261
860
for e in self.target.extras():
262
ret.unversioned.append((e, None, osutils.file_kind(self.target.abspath(e))))
861
ret.unversioned.append((e, None,
862
osutils.file_kind(self.target.abspath(e))))
265
866
def iter_changes(self, include_unchanged=False, specific_files=None,
266
pb=None, extra_trees=[], require_versioned=True, want_unversioned=False):
267
changes = self._index.changes_from_tree(
268
self.source._repository._git.object_store, self.source.tree,
269
want_unchanged=include_unchanged)
270
# FIXME: Handle want_unversioned
271
return changes_from_git_changes(changes, self.target.mapping,
867
pb=None, extra_trees=[], require_versioned=True,
868
want_unversioned=False):
869
changes = changes_between_git_tree_and_index(
870
self.source.store, self.source.tree,
871
self.target, want_unchanged=include_unchanged,
872
want_unversioned=want_unversioned)
873
return changes_from_git_changes(changes, self.target.mapping,
272
874
specific_file=specific_files)
274
877
tree.InterTree.register_optimiser(InterIndexGitTree)
880
def changes_between_git_tree_and_index(object_store, tree, target,
881
want_unchanged=False, want_unversioned=False, update_index=False):
882
"""Determine the changes between a git tree and a working tree with index.
886
names = target.index._byname.keys()
887
for (name, mode, sha) in changes_from_tree(names, target._lookup_entry,
888
object_store, tree, want_unchanged=want_unchanged):
889
if name == (None, None):
891
yield (name, mode, sha)