bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.217.1
by John Carr
Start stubbing out rewritten git-serve |
1 |
# Copyright (C) 2008 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.217.7
by John Carr
Create tips |
17 |
from bzrlib.bzrdir import BzrDir |
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
18 |
from bzrlib.repository import Repository |
|
0.217.4
by John Carr
Easy bits of git pushing to bazaar |
19 |
|
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
20 |
from bzrlib.plugins.git.fetch import import_git_objects |
|
0.217.7
by John Carr
Create tips |
21 |
from bzrlib.plugins.git.mapping import default_mapping |
22 |
||
|
0.217.1
by John Carr
Start stubbing out rewritten git-serve |
23 |
from dulwich.server import Backend |
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
24 |
from dulwich.pack import Pack, PackData, write_pack_index_v2 |
25 |
from dulwich.objects import ShaFile |
|
|
0.217.5
by John Carr
Add a temporary hack to test pushing form git to bazaar |
26 |
|
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
27 |
import os, tempfile |
|
0.217.1
by John Carr
Start stubbing out rewritten git-serve |
28 |
|
29 |
class BzrBackend(Backend): |
|
30 |
||
|
0.217.2
by John Carr
Fix missing imports. Update TCPGitServer instantiation to latest. BzrBackend needs to know which directory its repo is in. |
31 |
def __init__(self, directory): |
32 |
self.directory = directory |
|
|
0.217.7
by John Carr
Create tips |
33 |
self.mapping = default_mapping |
|
0.217.2
by John Carr
Fix missing imports. Update TCPGitServer instantiation to latest. BzrBackend needs to know which directory its repo is in. |
34 |
|
|
0.217.1
by John Carr
Start stubbing out rewritten git-serve |
35 |
def get_refs(self): |
36 |
""" return a dict of all tags and branches in repository (and shas) """ |
|
37 |
return {} |
|
38 |
||
39 |
def apply_pack(self, refs, read): |
|
40 |
""" apply pack from client to current repository """ |
|
|
0.217.4
by John Carr
Easy bits of git pushing to bazaar |
41 |
|
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
42 |
fd, path = tempfile.mkstemp(suffix=".pack") |
43 |
f = os.fdopen(fd, 'w') |
|
|
0.217.6
by John Carr
Fix typos |
44 |
f.write(read()) |
|
0.217.5
by John Carr
Add a temporary hack to test pushing form git to bazaar |
45 |
f.close() |
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
46 |
|
47 |
p = PackData(path) |
|
48 |
entries = p.sorted_entries() |
|
49 |
write_pack_index_v2(path[:-5]+".idx", entries, p.calculate_checksum()) |
|
50 |
||
51 |
def get_objects(): |
|
52 |
pack = Pack(path[:-5]) |
|
53 |
for obj in pack.iterobjects(): |
|
54 |
yield obj |
|
55 |
||
56 |
target = Repository.open(self.directory) |
|
57 |
||
58 |
target.lock_write() |
|
|
0.217.4
by John Carr
Easy bits of git pushing to bazaar |
59 |
try: |
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
60 |
target.start_write_group() |
61 |
try: |
|
62 |
import_git_objects(target, self.mapping, iter(get_objects())) |
|
63 |
finally: |
|
64 |
target.commit_write_group() |
|
|
0.217.4
by John Carr
Easy bits of git pushing to bazaar |
65 |
finally: |
|
0.217.8
by John Carr
Don't bother using InterRepo, use import_git_objects directly. Don't need a full repository (just operating on a pack and index) |
66 |
target.unlock() |
|
0.217.4
by John Carr
Easy bits of git pushing to bazaar |
67 |
|
|
0.217.7
by John Carr
Create tips |
68 |
for oldsha, sha, ref in refs: |
69 |
if ref[:11] == 'refs/heads/': |
|
70 |
branch_nick = ref[11:] |
|
71 |
||
72 |
try: |
|
73 |
target_dir = BzrDir.open(self.directory + "/" + branch_nick) |
|
74 |
except: |
|
75 |
target_dir = BzrDir.create(self.directory + "/" + branch_nick) |
|
76 |
||
77 |
try: |
|
78 |
target_branch = target_dir.open_branch() |
|
79 |
except: |
|
80 |
target_branch = target_dir.create_branch() |
|
81 |
||
82 |
rev_id = self.mapping.revision_id_foreign_to_bzr(sha) |
|
83 |
target_branch.generate_revision_history(rev_id) |
|
84 |
||
|
0.217.1
by John Carr
Start stubbing out rewritten git-serve |
85 |
def fetch_objects(self, determine_wants, graph_walker, progress): |
86 |
""" yield git objects to send to client """ |
|
87 |