bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.5.1
by John Arbash Meinel
Just an initial working step. |
1 |
#!/usr/bin/env python
|
2 |
"""\
|
|
3 |
This is an attempt to take the internal delta object, and represent
|
|
4 |
it as a single-file text-only changeset.
|
|
5 |
This should have commands for both generating a changeset,
|
|
6 |
and for applying a changeset.
|
|
7 |
"""
|
|
8 |
||
9 |
import bzrlib, bzrlib.commands |
|
10 |
||
|
0.5.24
by John Arbash Meinel
Adding send-changeset from Johan Rydberg |
11 |
class cmd_send_changeset(bzrlib.commands.Command): |
12 |
"""Send a bundled up changset via mail. |
|
13 |
||
14 |
If no revision has been specified, the last commited change will
|
|
15 |
be sent.
|
|
16 |
||
17 |
Subject of the mail can be specified by the --subject option,
|
|
18 |
otherwise information from the changeset log will be used.
|
|
19 |
"""
|
|
20 |
takes_options = ['revision', 'subject', 'diff-options'] |
|
21 |
takes_args = ['to?'] |
|
22 |
||
23 |
def run(self, to=None, subject=None, revision=None, diff_options=None): |
|
24 |
from tempfile import TemporaryFile |
|
25 |
from bzrlib import find_branch |
|
26 |
from bzrlib.commands import BzrCommandError |
|
27 |
import gen_changeset |
|
28 |
import send_changeset |
|
29 |
import sys |
|
30 |
||
31 |
if isinstance(revision, (list, tuple)): |
|
32 |
if len(revision) > 1: |
|
33 |
raise BzrCommandError('We do not support rollup-changesets yet.') |
|
34 |
revision = revision[0] |
|
35 |
||
36 |
b = find_branch('.') |
|
37 |
||
38 |
if not to: |
|
39 |
try: |
|
40 |
to = b.controlfile('x-send-address', 'rb').read().strip('\n') |
|
41 |
except: |
|
42 |
raise BzrCommandError('destination address is not known') |
|
43 |
||
44 |
if not revision: |
|
45 |
revision = b.revno() |
|
46 |
||
47 |
rev = b.get_revision(b.lookup_revision(revision)) |
|
48 |
if not subject: |
|
49 |
subject = rev.message.split('\n')[0] |
|
50 |
||
51 |
info = "Changset for revision %d by %s\n" % (revision, rev.committer) |
|
52 |
info += "with the following message:\n" |
|
53 |
for line in rev.message.split('\n'): |
|
54 |
info += " " + line + "\n" |
|
55 |
||
56 |
message = bzrlib.osutils.get_text_message(info) |
|
57 |
||
58 |
# FIXME: StringIO instead of temporary file
|
|
59 |
changeset_fp = TemporaryFile() |
|
60 |
gen_changeset.show_changeset(b, revision, |
|
61 |
external_diff_options=diff_options, |
|
62 |
to_file=changeset_fp) |
|
63 |
||
64 |
changeset_fp.seek(0) |
|
65 |
send_changeset.send_changeset(to, bzrlib.osutils._get_user_id(), |
|
66 |
subject, changeset_fp, message) |
|
67 |
||
68 |
||
|
0.5.1
by John Arbash Meinel
Just an initial working step. |
69 |
class cmd_changeset(bzrlib.commands.Command): |
70 |
"""Generate a bundled up changeset. |
|
71 |
||
72 |
This changeset contains all of the meta-information of a
|
|
73 |
diff, rather than just containing the patch information.
|
|
|
0.5.7
by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information. |
74 |
|
75 |
Right now, rollup changesets, or working tree changesets are
|
|
76 |
not supported. This will only generate a changeset that has been
|
|
77 |
committed. You can use "--revision" to specify a certain change
|
|
78 |
to display.
|
|
|
0.5.1
by John Arbash Meinel
Just an initial working step. |
79 |
"""
|
|
0.5.3
by John Arbash Meinel
Added a couple more bits |
80 |
takes_options = ['revision', 'diff-options'] |
|
0.5.1
by John Arbash Meinel
Just an initial working step. |
81 |
takes_args = ['file*'] |
82 |
aliases = ['cset'] |
|
83 |
||
84 |
def run(self, revision=None, file_list=None, diff_options=None): |
|
85 |
from bzrlib import find_branch |
|
86 |
import gen_changeset |
|
87 |
import sys |
|
88 |
||
|
0.5.7
by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information. |
89 |
if isinstance(revision, (list, tuple)): |
90 |
if len(revision) > 1: |
|
91 |
raise BzrCommandError('We do not support rollup-changesets yet.') |
|
92 |
revision = revision[0] |
|
|
0.5.1
by John Arbash Meinel
Just an initial working step. |
93 |
if file_list: |
94 |
b = find_branch(file_list[0]) |
|
95 |
file_list = [b.relpath(f) for f in file_list] |
|
96 |
if file_list == ['']: |
|
97 |
# just pointing to top-of-tree
|
|
98 |
file_list = None |
|
99 |
else: |
|
100 |
b = find_branch('.') |
|
101 |
||
102 |
gen_changeset.show_changeset(b, revision, |
|
103 |
specific_files=file_list, |
|
104 |
external_diff_options=diff_options, |
|
105 |
to_file=sys.stdout) |
|
106 |
||
|
0.5.7
by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information. |
107 |
class cmd_verify_changeset(bzrlib.commands.Command): |
108 |
"""Read a written changeset, and make sure it is valid. |
|
109 |
||
110 |
"""
|
|
111 |
takes_args = ['filename?'] |
|
112 |
||
113 |
def run(self, filename=None): |
|
114 |
import sys, read_changeset |
|
115 |
if filename is None or filename == '-': |
|
116 |
f = sys.stdin |
|
117 |
else: |
|
118 |
f = open(filename, 'rb') |
|
119 |
||
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
120 |
cset_info = read_changeset.read_changeset(f) |
121 |
print cset_info |
|
122 |
cset = cset_info.get_changeset() |
|
123 |
print cset.entries |
|
|
0.5.7
by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information. |
124 |
|
|
0.5.15
by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing. |
125 |
class cmd_apply_changeset(bzrlib.commands.Command): |
126 |
"""Read in the given changeset, and apply it to the |
|
127 |
current tree.
|
|
128 |
||
129 |
"""
|
|
130 |
takes_args = ['filename?'] |
|
131 |
takes_options = [] |
|
132 |
||
|
0.5.18
by John Arbash Meinel
Some minor fixups |
133 |
def run(self, filename=None, reverse=False, auto_commit=False): |
|
0.5.15
by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing. |
134 |
from bzrlib import find_branch |
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
135 |
import sys |
136 |
import apply_changeset |
|
|
0.5.15
by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing. |
137 |
|
138 |
b = find_branch('.') # Make sure we are in a branch |
|
139 |
if filename is None or filename == '-': |
|
140 |
f = sys.stdin |
|
141 |
else: |
|
142 |
f = open(filename, 'rb') |
|
143 |
||
|
0.5.17
by John Arbash Meinel
adding apply-changset, plus more meta information. |
144 |
apply_changeset.apply_changeset(b, f, reverse=reverse, |
145 |
auto_commit=auto_commit) |
|
|
0.5.15
by John Arbash Meinel
Created an apply-changeset function, and modified output for better parsing. |
146 |
|
|
0.5.7
by John Arbash Meinel
Added a bunch more information about changesets. Can now read back in all of the meta information. |
147 |
|
|
0.5.24
by John Arbash Meinel
Adding send-changeset from Johan Rydberg |
148 |
bzrlib.commands.register_command(cmd_changeset) |
149 |
bzrlib.commands.register_command(cmd_verify_changeset) |
|
150 |
bzrlib.commands.register_command(cmd_apply_changeset) |
|
151 |
bzrlib.commands.register_command(cmd_send_changeset) |
|
152 |
||
153 |
bzrlib.commands.OPTIONS['subject'] = str |
|
154 |
bzrlib.commands.OPTIONS['reverse'] = None |
|
155 |
bzrlib.commands.OPTIONS['auto-commit'] = None |
|
156 |
cmd_apply_changeset.takes_options.append('reverse') |
|
157 |
cmd_apply_changeset.takes_options.append('auto-commit') |