Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/cvs/cvsclient.py
Show First 20 Lines • Show All 326 Lines • ▼ Show 20 Lines | def checkout(self, path, rev, dest_dir, expand_keywords): | ||||
""" | """ | ||||
skip_line = False | skip_line = False | ||||
expect_modeline = False | expect_modeline = False | ||||
expect_bytecount = False | expect_bytecount = False | ||||
have_bytecount = False | have_bytecount = False | ||||
bytecount = 0 | bytecount = 0 | ||||
dirname = os.path.dirname(path) | dirname = os.path.dirname(path) | ||||
if dirname: | if dirname: | ||||
self.conn_write_str("Directory %s\n%s\n" % (dirname, dirname)) | self.conn_write_str( | ||||
"Directory %s\n%s\n" | |||||
% (dirname, os.path.join(self.cvsroot_path, dirname)) | |||||
) | |||||
filename = os.path.basename(path) | filename = os.path.basename(path) | ||||
co_output = tempfile.NamedTemporaryFile( | co_output = tempfile.NamedTemporaryFile( | ||||
dir=dest_dir, | dir=dest_dir, | ||||
delete=True, | delete=True, | ||||
prefix="cvsclient-checkout-%s-r%s-" % (filename, rev), | prefix="cvsclient-checkout-%s-r%s-" % (filename, rev), | ||||
) | ) | ||||
if expand_keywords: | if expand_keywords: | ||||
# use server-side per-file default expansion rules | # use server-side per-file default expansion rules | ||||
karg = "" | karg = "" | ||||
else: | else: | ||||
# force binary file mode | # force binary file mode | ||||
karg = "Argument -kb\n" | karg = "Argument -kb\n" | ||||
# TODO: cvs <= 1.10 servers expect to be given every Directory along the path. | # TODO: cvs <= 1.10 servers expect to be given every Directory along the path. | ||||
self.conn_write_str( | self.conn_write_str( | ||||
"Directory %s\n%s\n" | "Directory %s\n%s\n" | ||||
"Global_option -q\n" | "Global_option -q\n" | ||||
"Argument -r%s\n" | "Argument -r%s\n" | ||||
"%s" | "%s" | ||||
"Argument --\nArgument %s\nco \n" | "Argument --\nArgument %s\nco \n" | ||||
% (self.cvs_module_name, self.cvs_module_name, rev, karg, path) | % ( | ||||
self.cvs_module_name, | |||||
os.path.join(self.cvsroot_path, self.cvs_module_name), | |||||
rev, | |||||
karg, | |||||
path, | |||||
) | |||||
) | ) | ||||
while True: | while True: | ||||
if have_bytecount: | if have_bytecount: | ||||
if bytecount < 0: | if bytecount < 0: | ||||
raise CVSProtocolError("server sent too much file content data") | raise CVSProtocolError("server sent too much file content data") | ||||
response = self.conn_read_line(require_newline=False) | response = self.conn_read_line(require_newline=False) | ||||
if response is None: | if response is None: | ||||
raise CVSProtocolError("Incomplete response from CVS server") | raise CVSProtocolError("Incomplete response from CVS server") | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |