1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import translate.storage.versioncontrol
24 from translate.storage.versioncontrol import run_command
25 from translate.storage.versioncontrol import GenericRevisionControlSystem
26
27 -class bzr(GenericRevisionControlSystem):
28 """Class to manage items under revision control of bzr."""
29
30 RCS_METADIR = ".bzr"
31 SCAN_PARENTS = True
32
33 - def update(self, revision=None):
34 """Does a clean update of the given path"""
35
36 command = ["bzr", "revert", self.location_abs]
37 exitcode, output_revert, error = run_command(command)
38 if exitcode != 0:
39 raise IOError("[BZR] revert of '%s' failed: %s" \
40 % (self.location_abs, error))
41
42 command = ["bzr", "pull"]
43 exitcode, output_pull, error = run_command(command)
44 if exitcode != 0:
45 raise IOError("[BZR] pull of '%s' failed: %s" \
46 % (self.location_abs, error))
47 return output_revert + output_pull
48
49 - def commit(self, message=None):
50 """Commits the file and supplies the given commit message if present"""
51
52 command = ["bzw", "commit"]
53 if message:
54 command.extend(["-m", message])
55
56 command.append(self.location_abs)
57 exitcode, output_commit, error = run_command(command)
58 if exitcode != 0:
59 raise IOError("[BZR] commit of '%s' failed: %s" \
60 % (self.location_abs, error))
61
62 command = ["bzr", "push"]
63 exitcode, output_push, error = run_command(command)
64 if exitcode != 0:
65 raise IOError("[BZR] push of '%s' failed: %s" \
66 % (self.location_abs, error))
67 return output_commit + output_push
68
70 """Get a clean version of a file from the bzr repository"""
71
72 command = ["bzr", "cat", self.location_abs]
73 exitcode, output, error = run_command(command)
74 if exitcode != 0:
75 raise IOError("[BZR] cat failed for '%s': %s" \
76 % (self.location_abs, error))
77 return output
78