comparison fetch_command.py @ 63:2e30b59a9c19

Added some coverage pragmas to stop it from trying to cover things we can't test.
author Augie Fackler <durin42@gmail.com>
date Thu, 06 Nov 2008 09:47:42 -0600
parents 430af23bef4a
children 9c1b53abefcb
comparison
equal deleted inserted replaced
62:cc5ebdb1e8d4 63:2e30b59a9c19
16 import hg_delta_editor 16 import hg_delta_editor
17 import svnwrap 17 import svnwrap
18 import util 18 import util
19 19
20 20
21 def print_your_svn_is_old_message(ui): 21 def print_your_svn_is_old_message(ui): #pragma: no cover
22 ui.status("In light of that, I'll fall back and do diffs, but it won't do " 22 ui.status("In light of that, I'll fall back and do diffs, but it won't do "
23 "as good a job. You should really upgrade your server.\n") 23 "as good a job. You should really upgrade your server.\n")
24 24
25 25
26 @util.register_subcommand('pull') 26 @util.register_subcommand('pull')
32 old_encoding = merc_util._encoding 32 old_encoding = merc_util._encoding
33 merc_util._encoding = 'UTF-8' 33 merc_util._encoding = 'UTF-8'
34 skipto_rev=int(skipto_rev) 34 skipto_rev=int(skipto_rev)
35 have_replay = not stupid 35 have_replay = not stupid
36 if have_replay and not callable(delta.svn_txdelta_apply(None, None, 36 if have_replay and not callable(delta.svn_txdelta_apply(None, None,
37 None)[0]): 37 None)[0]): #pragma: no cover
38 ui.status('You are using old Subversion SWIG bindings. Replay will not' 38 ui.status('You are using old Subversion SWIG bindings. Replay will not'
39 ' work until you upgrade to 1.5.0 or newer. Falling back to' 39 ' work until you upgrade to 1.5.0 or newer. Falling back to'
40 ' a slower method that may be buggier. Please upgrade, or' 40 ' a slower method that may be buggier. Please upgrade, or'
41 ' contribute a patch to use the ctypes bindings instead' 41 ' contribute a patch to use the ctypes bindings instead'
42 ' of SWIG.\n') 42 ' of SWIG.\n')
79 try: 79 try:
80 ui.status('converting %s\n' % r) 80 ui.status('converting %s\n' % r)
81 if have_replay: 81 if have_replay:
82 try: 82 try:
83 replay_convert_rev(hg_editor, svn, r) 83 replay_convert_rev(hg_editor, svn, r)
84 except svnwrap.SubversionRepoCanNotReplay, e: 84 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
85 ui.status('%s\n' % e.message) 85 ui.status('%s\n' % e.message)
86 print_your_svn_is_old_message(ui) 86 print_your_svn_is_old_message(ui)
87 have_replay = False 87 have_replay = False
88 stupid_svn_server_pull_rev(ui, svn, hg_editor, r) 88 stupid_svn_server_pull_rev(ui, svn, hg_editor, r)
89 else: 89 else:
93 fp = open(tmpfile, 'w') 93 fp = open(tmpfile, 'w')
94 fp.write(str(r.revnum)) 94 fp.write(str(r.revnum))
95 fp.close() 95 fp.close()
96 merc_util.rename(tmpfile, 96 merc_util.rename(tmpfile,
97 hg_editor.last_revision_handled_file) 97 hg_editor.last_revision_handled_file)
98 except core.SubversionException, e: 98 except core.SubversionException, e: #pragma: no cover
99 if hasattr(e, 'message') and ( 99 if hasattr(e, 'message') and (
100 'Server sent unexpected return value (502 Bad Gateway)' 100 'Server sent unexpected return value (502 Bad Gateway)'
101 ' in response to PROPFIND') in e.message: 101 ' in response to PROPFIND') in e.message:
102 tries += 1 102 tries += 1
103 ui.status('Got a 502, retrying (%s)\n' % tries) 103 ui.status('Got a 502, retrying (%s)\n' % tries)
131 # no idea why. TODO(augie) figure out the why. 131 # no idea why. TODO(augie) figure out the why.
132 try: 132 try:
133 pl = svn.proplist(p2, r.revnum, recurse=True) 133 pl = svn.proplist(p2, r.revnum, recurse=True)
134 cleanup_file_handles(svn, i) 134 cleanup_file_handles(svn, i)
135 i += 1 135 i += 1
136 except core.SubversionException, e: 136 except core.SubversionException, e: #pragma: no cover
137 pass 137 pass
138 props.update(pl) 138 props.update(pl)
139 if p[-1] == '/': 139 if p[-1] == '/':
140 dirs_to_list.append(p) 140 dirs_to_list.append(p)
141 else: 141 else:
389 svn.fetch_all_files_to_dir(diff_path, r.revnum, our_tempdir) 389 svn.fetch_all_files_to_dir(diff_path, r.revnum, our_tempdir)
390 except core.SubversionException, e: 390 except core.SubversionException, e:
391 if e.apr_err == 170000 or (e.message.startswith("URL '") 391 if e.apr_err == 170000 or (e.message.startswith("URL '")
392 and e.message.endswith("' doesn't exist")): 392 and e.message.endswith("' doesn't exist")):
393 delete_all_files = True 393 delete_all_files = True
394 else: 394 else: #pragma: no cover
395 raise 395 raise
396 396
397 except BadPatchApply, e: 397 except BadPatchApply, e:
398 # previous rev didn't exist, so this is most likely the first 398 # previous rev didn't exist, so this is most likely the first
399 # revision. We'll have to pull all files by hand. 399 # revision. We'll have to pull all files by hand.