diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2013-04-30 20:09:57 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-30 22:06:46 -0700 |
commit | f38dfc4c32507de2f7cf05350fe8b34fd4edd45d (patch) | |
tree | 50fa722a7bc32ffe22409d4c00a6ec432137a4b0 /contrib | |
parent | remote-bzr: always try to update the worktree (diff) | |
download | tgif-f38dfc4c32507de2f7cf05350fe8b34fd4edd45d.tar.xz |
remote-bzr: add support to push merges
In order to do that, we need to store the marks of every file, so that
they can be fetched when needed. Unfortunately we can't tell bazaar that
nothing changed, we need to send the data so that it can figure it out
by itself.
And since it will be requesting a bunch of information by the file_id,
it's better to have a helper dict (rev_files), so that we can fetch it
quickly.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/remote-helpers/git-remote-bzr | 29 | ||||
-rwxr-xr-x | contrib/remote-helpers/test-bzr.sh | 36 |
2 files changed, 57 insertions, 8 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index eb91d2814b..6a7f836ea6 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -393,7 +393,7 @@ class CustomTree(): tree = repo.repository.revision_tree(revid) try: for path, entry in tree.iter_entries_by_dir(): - files[path] = entry.file_id + files[path] = [entry.file_id, None] finally: repo.unlock() return files @@ -408,12 +408,18 @@ class CustomTree(): self.base_files = copy_tree(self.base_id) self.files = files_cache[revid] = self.base_files.copy() + self.rev_files = {} + + for path, data in self.files.iteritems(): + fid, mark = data + self.rev_files[fid] = [path, mark] for path, f in files.iteritems(): - fid = self.files.get(path, None) + fid, mark = self.files.get(path, [None, None]) if not fid: fid = bzrlib.generate_ids.gen_file_id(path) f['path'] = path + self.rev_files[fid] = [path, mark] self.updates[fid] = f def last_revision(self): @@ -423,10 +429,10 @@ class CustomTree(): changes = [] def get_parent(dirname, basename): - parent_fid = self.base_files.get(dirname, None) + parent_fid, mark = self.base_files.get(dirname, [None, None]) if parent_fid: return parent_fid - parent_fid = self.files.get(dirname, None) + parent_fid, mark = self.files.get(dirname, [None, None]) if parent_fid: return parent_fid if basename == '': @@ -453,7 +459,7 @@ class CustomTree(): (None, basename), (None, kind), (None, executable)) - self.files[path] = change[0] + self.files[path] = [change[0], None] changes.append(change) def update_entry(fid, path, kind, mode = None): @@ -474,7 +480,7 @@ class CustomTree(): (None, basename), (None, kind), (None, executable)) - self.files[path] = change[0] + self.files[path] = [change[0], None] changes.append(change) def remove_entry(fid, path, kind): @@ -503,16 +509,23 @@ class CustomTree(): else: add_entry(fid, path, 'file', f['mode']) + self.files[path][1] = f['mark'] + self.rev_files[fid][1] = f['mark'] + return changes def get_file_with_stat(self, file_id, path=None): - mark = self.updates[file_id]['mark'] + path, mark = self.rev_files[file_id] return (StringIO.StringIO(blob_marks[mark]), None) def get_symlink_target(self, file_id): - mark = self.updates[file_id]['mark'] + path, mark = self.rev_files[file_id] return blob_marks[mark] + def id2path(self, file_id): + path, mark = self.rev_files[file_id] + return path + def c_style_unescape(string): if string[0] == string[-1] == '"': return string.decode('string-escape')[1:-1] diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh index 34666e1d0f..eca347634e 100755 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@ -228,4 +228,40 @@ test_expect_success 'push utf-8 filenames' ' test_cmp expected actual ' +test_expect_success 'pushing a merge' ' + mkdir -p tmp && cd tmp && + test_when_finished "cd .. && rm -rf tmp" && + + ( + bzr init bzrrepo && + cd bzrrepo && + echo one > content && + bzr add content && + bzr commit -m one + ) && + + git clone "bzr::$PWD/bzrrepo" gitrepo && + + ( + cd bzrrepo && + echo two > content && + bzr commit -m two + ) && + + ( + cd gitrepo && + echo three > content && + git commit -a -m three && + git fetch && + git merge origin/master || true && + echo three > content && + git commit -a --no-edit && + git push + ) && + + echo three > expected && + cat bzrrepo/content > actual && + test_cmp expected actual +' + test_done |