comparison fetch_command.py @ 301:79440ed81011

Allow specifying a revision to stop at using the -H flag. This is useful for converting repositories which have been deleted or renamed, such as llvm-gcc-4-2 in the LLVM repositories which was renamed to llvm-gcc-4.2 shortly after its creation. Also, consolidate the two places in svn_swig_wrapper.py where a default chunk size is specified to one, single variable declaration.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 27 Mar 2009 03:21:45 +0100
parents 4aba7542f6a9
children
comparison
equal deleted inserted replaced
300:4aba7542f6a9 301:79440ed81011
19 def print_your_svn_is_old_message(ui): #pragma: no cover 19 def print_your_svn_is_old_message(ui): #pragma: no cover
20 ui.status("In light of that, I'll fall back and do diffs, but it won't do " 20 ui.status("In light of that, I'll fall back and do diffs, but it won't do "
21 "as good a job. You should really upgrade your server.\n") 21 "as good a job. You should really upgrade your server.\n")
22 22
23 23
24 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None, 24 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, head=0,
25 stupid=None,
25 tag_locations='tags', 26 tag_locations='tags',
26 authors=None, 27 authors=None,
27 filemap=None, 28 filemap=None,
28 **opts): 29 **opts):
29 """pull new revisions from Subversion 30 """pull new revisions from Subversion
63 open(hg_editor.uuid_file, 'w').write(svn.uuid) 64 open(hg_editor.uuid_file, 'w').write(svn.uuid)
64 open(hg_editor.svn_url_file, 'w').write(svn_url) 65 open(hg_editor.svn_url_file, 'w').write(svn_url)
65 initializing_repo = True 66 initializing_repo = True
66 start = skipto_rev 67 start = skipto_rev
67 68
69 if head <= 0:
70 stop = svn.last_changed_rev
71 else:
72 stop = head
73
68 if initializing_repo and start > 0: 74 if initializing_repo and start > 0:
69 raise merc_util.Abort('Revision skipping at repository initialization ' 75 raise merc_util.Abort('Revision skipping at repository initialization '
70 'remains unimplemented.') 76 'remains unimplemented.')
71 77
78 if start >= stop:
79 ui.status('No new revisions beyond %d.\n' % stop)
80 return
81 else:
82 ui.status('Pulling revisions %d through %d.\n' % (start, stop))
83
72 # start converting revisions 84 # start converting revisions
73 for r in svn.revisions(start=start): 85 for r in svn.revisions(start=start, stop=head):
74 valid = True 86 valid = True
75 hg_editor.update_branch_tag_map_for_rev(r) 87 hg_editor.update_branch_tag_map_for_rev(r)
76 for p in r.paths: 88 for p in r.paths:
77 if hg_editor._is_path_valid(p): 89 if hg_editor._is_path_valid(p):
78 valid = True 90 valid = True
84 while not converted and tries < 3: 96 while not converted and tries < 3:
85 try: 97 try:
86 util.describe_revision(ui, r) 98 util.describe_revision(ui, r)
87 if have_replay: 99 if have_replay:
88 try: 100 try:
89 replay_convert_rev(hg_editor, svn, r) 101 replay_convert_rev(hg_editor, svn, r, skipto_rev)
90 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover 102 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
91 ui.status('%s\n' % e.message) 103 ui.status('%s\n' % e.message)
92 print_your_svn_is_old_message(ui) 104 print_your_svn_is_old_message(ui)
93 have_replay = False 105 have_replay = False
94 stupid_svn_server_pull_rev(ui, svn, hg_editor, r) 106 stupid_svn_server_pull_rev(ui, svn, hg_editor, r)
107 119
108 def cleanup_file_handles(svn, count): 120 def cleanup_file_handles(svn, count):
109 if count % 50 == 0: 121 if count % 50 == 0:
110 svn.init_ra_and_client() 122 svn.init_ra_and_client()
111 123
112 def replay_convert_rev(hg_editor, svn, r): 124 def replay_convert_rev(hg_editor, svn, r, skipto_rev):
113 hg_editor.set_current_rev(r) 125 hg_editor.set_current_rev(r)
114 svn.get_replay(r.revnum, hg_editor) 126 svn.get_replay(r.revnum, hg_editor, skipto_rev)
115 i = 1 127 i = 1
116 if hg_editor.missing_plaintexts: 128 if hg_editor.missing_plaintexts:
117 hg_editor.ui.debug('Fetching %s files that could not use replay.\n' % 129 hg_editor.ui.debug('Fetching %s files that could not use replay.\n' %
118 len(hg_editor.missing_plaintexts)) 130 len(hg_editor.missing_plaintexts))
119 files_to_grab = set() 131 files_to_grab = set()