bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2012-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
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
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
16 |
|
17 |
||
18 |
"""Support for pristine tar deltas."""
|
|
19 |
||
20 |
from base64 import ( |
|
21 |
standard_b64decode, |
|
22 |
)
|
|
23 |
||
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
24 |
from dulwich.objects import ( |
25 |
Blob, |
|
26 |
Tree, |
|
27 |
)
|
|
28 |
||
29 |
import stat |
|
30 |
||
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
31 |
README_CONTENTS = b"""\ |
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
32 |
This branch contains delta files that pristine-tar can use to
|
33 |
regenerate tarballs for its own releases.
|
|
34 |
"""
|
|
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
35 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
36 |
|
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
37 |
def revision_pristine_tar_data(rev): |
38 |
"""Export the pristine tar data from a revision.""" |
|
39 |
if 'deb-pristine-delta' in rev.properties: |
|
40 |
uuencoded = rev.properties['deb-pristine-delta'] |
|
0.277.6
by Jelmer Vernooij
Add 'bzr git-push-pristine-tar' command. |
41 |
kind = 'gz' |
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
42 |
elif 'deb-pristine-delta-bz2' in rev.properties: |
43 |
uuencoded = rev.properties['deb-pristine-delta-bz2'] |
|
0.277.6
by Jelmer Vernooij
Add 'bzr git-push-pristine-tar' command. |
44 |
kind = 'bz2' |
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
45 |
elif 'deb-pristine-delta-xz' in rev.properties: |
46 |
uuencoded = rev.properties['deb-pristine-delta-xz'] |
|
0.277.6
by Jelmer Vernooij
Add 'bzr git-push-pristine-tar' command. |
47 |
kind = 'xz' |
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
48 |
else: |
0.277.6
by Jelmer Vernooij
Add 'bzr git-push-pristine-tar' command. |
49 |
raise KeyError(rev.revision_id) |
0.277.1
by Jelmer Vernooij
Add function for extracting pristine tar data. |
50 |
|
0.277.6
by Jelmer Vernooij
Add 'bzr git-push-pristine-tar' command. |
51 |
return (standard_b64decode(uuencoded), kind) |
0.277.3
by Jelmer Vernooij
Add function for reading pristine tar data from a git repo. |
52 |
|
53 |
||
54 |
def get_pristine_tar_tree(repo): |
|
55 |
"""Retrieve the pristine tar tree for a repository. |
|
56 |
||
57 |
"""
|
|
58 |
try: |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
59 |
cid = repo.refs[b"refs/heads/pristine-tar"] |
0.277.3
by Jelmer Vernooij
Add function for reading pristine tar data from a git repo. |
60 |
except KeyError: |
61 |
return Tree() |
|
62 |
tid = repo.object_store[cid].tree |
|
63 |
return repo.object_store[tid] |
|
64 |
||
65 |
||
66 |
def read_git_pristine_tar_data(repo, filename): |
|
67 |
"""Read pristine data from a Git repository. |
|
68 |
||
69 |
:param repo: Git repository to read from
|
|
70 |
:param filename: Name of file to read
|
|
71 |
:return: Tuple with delta and id
|
|
72 |
"""
|
|
73 |
tree = get_pristine_tar_tree(repo) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
74 |
delta = tree[filename + b".delta"][1] |
75 |
gitid = tree[filename + b".id"][1] |
|
0.277.3
by Jelmer Vernooij
Add function for reading pristine tar data from a git repo. |
76 |
return (repo.object_store[delta].data, |
77 |
repo.object_store[gitid].data) |
|
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
78 |
|
79 |
||
80 |
def store_git_pristine_tar_data(repo, filename, delta, gitid, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
81 |
message=None, **kwargs): |
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
82 |
"""Add pristine tar data to a Git repository. |
83 |
||
84 |
:param repo: Git repository to add data to
|
|
85 |
:param filename: Name of file to store for
|
|
86 |
:param delta: pristine-tar delta
|
|
87 |
:param gitid: Git id the pristine tar delta is generated against
|
|
88 |
"""
|
|
89 |
delta_ob = Blob.from_string(delta) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
90 |
delta_name = filename + b".delta" |
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
91 |
id_ob = Blob.from_string(gitid) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
92 |
id_name = filename + b".id" |
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
93 |
objects = [ |
94 |
(delta_ob, delta_name), |
|
95 |
(id_ob, id_name)] |
|
96 |
tree = get_pristine_tar_tree(repo) |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
97 |
tree.add(delta_name, stat.S_IFREG | 0o644, delta_ob.id) |
98 |
tree.add(id_name, stat.S_IFREG | 0o644, id_ob.id) |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
99 |
if b"README" not in tree: |
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
100 |
readme_ob = Blob.from_string(README_CONTENTS) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
101 |
objects.append((readme_ob, b"README")) |
102 |
tree.add(b"README", stat.S_IFREG | 0o644, readme_ob.id) |
|
0.277.4
by Jelmer Vernooij
Add function for storing git pristine tar delta files. |
103 |
objects.append((tree, "")) |
104 |
repo.object_store.add_objects(objects) |
|
105 |
if message is None: |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
106 |
message = b'pristine-tar data for %s' % filename |
107 |
return repo.do_commit(ref=b'refs/heads/pristine-tar', tree=tree.id, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
108 |
message=message, **kwargs) |