annotate fetch_command.py @ 87:b033d74be76b

fetch_command: in stupid non-diffy mode, take changed paths in account Former code was checkouting all branch files for every converted revision when diffs were not available in stupid mode. Now, only changed items are requested.
author Patrick Mezard <pmezard@gmail.com>
date Fri, 14 Nov 2008 16:18:24 -0600
parents 2e47623fa174
children 3b60f223893a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import cStringIO
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import re
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import operator
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 import shutil
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 import tempfile
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import patch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 from mercurial import node
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 from mercurial import context
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 from mercurial import revlog
6
1a5bb173170b Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
12 from mercurial import util as merc_util
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 from svn import core
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 from svn import delta
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 import hg_delta_editor
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 import svnwrap
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 import util
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20
63
2e30b59a9c19 Added some coverage pragmas to stop it from trying to cover things we can't test.
Augie Fackler <durin42@gmail.com>
parents: 59
diff changeset
21 def print_your_svn_is_old_message(ui): #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 ui.status("In light of that, I'll fall back and do diffs, but it won't do "
11
83ed086ddf72 Add a missing newline.
Augie Fackler <durin42@gmail.com>
parents: 6
diff changeset
23 "as good a job. You should really upgrade your server.\n")
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 @util.register_subcommand('pull')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 tag_locations='tags',
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 """Pull new revisions from Subversion.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 """
44
85fcac4e2291 Fix an encoding bug that would occur if the local encoding was not utf-8.
Augie Fackler <durin42@gmail.com>
parents: 42
diff changeset
32 old_encoding = merc_util._encoding
85fcac4e2291 Fix an encoding bug that would occur if the local encoding was not utf-8.
Augie Fackler <durin42@gmail.com>
parents: 42
diff changeset
33 merc_util._encoding = 'UTF-8'
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 skipto_rev=int(skipto_rev)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 have_replay = not stupid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 if have_replay and not callable(delta.svn_txdelta_apply(None, None,
63
2e30b59a9c19 Added some coverage pragmas to stop it from trying to cover things we can't test.
Augie Fackler <durin42@gmail.com>
parents: 59
diff changeset
37 None)[0]): #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 ui.status('You are using old Subversion SWIG bindings. Replay will not'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 ' work until you upgrade to 1.5.0 or newer. Falling back to'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 ' a slower method that may be buggier. Please upgrade, or'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 ' contribute a patch to use the ctypes bindings instead'
29
575bd29bc1d8 Fix a missing newline.
Augie Fackler <durin42@gmail.com>
parents: 25
diff changeset
42 ' of SWIG.\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 have_replay = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 initializing_repo = False
6
1a5bb173170b Fixes for win32 compatibility. Changes suggested by Shun-ichi GOTO, with some alterations by me.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
45 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 author_host = "@%s" % svn.uuid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 tag_locations = tag_locations.split(',')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 ui_=ui,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 subdir=svn.subdir,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 author_host=author_host,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 tag_locations=tag_locations)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 if os.path.exists(hg_editor.uuid_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 uuid = open(hg_editor.uuid_file).read()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 assert uuid == svn.uuid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 start = int(open(hg_editor.last_revision_handled_file, 'r').read())
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 open(hg_editor.uuid_file, 'w').write(svn.uuid)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 open(hg_editor.svn_url_file, 'w').write(svn_url)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 open(hg_editor.last_revision_handled_file, 'w').write(str(0))
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 initializing_repo = True
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 start = skipto_rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 # start converting revisions
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 for r in svn.revisions(start=start):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 valid = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 hg_editor.update_branch_tag_map_for_rev(r)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 for p in r.paths:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 if hg_editor._is_path_valid(p):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 valid = True
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 if initializing_repo and start > 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 assert False, 'This feature not ready yet.'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 if valid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 # got a 502? Try more than once!
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 tries = 0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 converted = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 while not converted and tries < 3:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 ui.status('converting %s\n' % r)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 if have_replay:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 replay_convert_rev(hg_editor, svn, r)
63
2e30b59a9c19 Added some coverage pragmas to stop it from trying to cover things we can't test.
Augie Fackler <durin42@gmail.com>
parents: 59
diff changeset
84 except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 ui.status('%s\n' % e.message)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 print_your_svn_is_old_message(ui)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 have_replay = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 stupid_svn_server_pull_rev(ui, svn, hg_editor, r)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90 stupid_svn_server_pull_rev(ui, svn, hg_editor, r)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 converted = True
32
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
92 tmpfile = '%s_tmp' % hg_editor.last_revision_handled_file
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
93 fp = open(tmpfile, 'w')
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
94 fp.write(str(r.revnum))
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
95 fp.close()
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
96 merc_util.rename(tmpfile,
d01196ca1e39 Fix non-atomic write of the last_revision_handled_file which was causing
Augie Fackler <durin42@gmail.com>
parents: 29
diff changeset
97 hg_editor.last_revision_handled_file)
63
2e30b59a9c19 Added some coverage pragmas to stop it from trying to cover things we can't test.
Augie Fackler <durin42@gmail.com>
parents: 59
diff changeset
98 except core.SubversionException, e: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 if hasattr(e, 'message') and (
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 'Server sent unexpected return value (502 Bad Gateway)'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 ' in response to PROPFIND') in e.message:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 tries += 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 ui.status('Got a 502, retrying (%s)\n' % tries)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 raise
44
85fcac4e2291 Fix an encoding bug that would occur if the local encoding was not utf-8.
Augie Fackler <durin42@gmail.com>
parents: 42
diff changeset
106 merc_util._encoding = old_encoding
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
109 def cleanup_file_handles(svn, count):
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
110 if count % 50 == 0:
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
111 svn.init_ra_and_client()
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
112
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 def replay_convert_rev(hg_editor, svn, r):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 hg_editor.set_current_rev(r)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115 svn.get_replay(r.revnum, hg_editor)
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
116 i = 1
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 if hg_editor.missing_plaintexts:
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
118 hg_editor.ui.status('Fetching %s files that could not use replay.\n' %
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
119 len(hg_editor.missing_plaintexts))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 files_to_grab = set()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 dirs_to_list = []
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 for p in hg_editor.missing_plaintexts:
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
123 hg_editor.ui.status('.')
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
124 hg_editor.ui.flush()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 if p[-1] == '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 dirs_to_list.append(p)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 files_to_grab.add(p)
42
485ae93bc358 Only print this message if we actually care.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
129 if dirs_to_list:
485ae93bc358 Only print this message if we actually care.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
130 hg_editor.ui.status('\nChecking for additional files in'
485ae93bc358 Only print this message if we actually care.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
131 ' directories...\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 while dirs_to_list:
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
133 hg_editor.ui.status('.')
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
134 hg_editor.ui.flush()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 p = dirs_to_list.pop(0)
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
136 cleanup_file_handles(svn, i)
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
137 i += 1
58
a8b9c7e7c2ac Fix a bug in real replay where dirs copied from outside the directory tree
Augie Fackler <durin42@gmail.com>
parents: 44
diff changeset
138 p2 = p[:-1]
a8b9c7e7c2ac Fix a bug in real replay where dirs copied from outside the directory tree
Augie Fackler <durin42@gmail.com>
parents: 44
diff changeset
139 if svn.subdir:
a8b9c7e7c2ac Fix a bug in real replay where dirs copied from outside the directory tree
Augie Fackler <durin42@gmail.com>
parents: 44
diff changeset
140 p2 = p2[len(svn.subdir)-1:]
a8b9c7e7c2ac Fix a bug in real replay where dirs copied from outside the directory tree
Augie Fackler <durin42@gmail.com>
parents: 44
diff changeset
141 l = svn.list_dir(p2, r.revnum)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 for f in l:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 if l[f].kind == core.svn_node_dir:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 dirs_to_list.append(p+f+'/')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 elif l[f].kind == core.svn_node_file:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 files_to_grab.add(p+f)
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
147 hg_editor.ui.status('\nFetching files...\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 for p in files_to_grab:
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
149 hg_editor.ui.status('.')
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
150 hg_editor.ui.flush()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 p2 = p
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 if svn.subdir:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 p2 = p2[len(svn.subdir)-1:]
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
154 cleanup_file_handles(svn, i)
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
155 i += 1
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 74
diff changeset
156 data, mode = svn.get_file(p2, r.revnum)
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 74
diff changeset
157 hg_editor.current_files[p] = data
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 74
diff changeset
158 hg_editor.current_files_exec[p] = 'x' in mode
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 74
diff changeset
159 hg_editor.current_files_symlink[p] = 'l' in mode
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 hg_editor.missing_plaintexts = set()
38
9ee7ce0505eb Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
161 hg_editor.ui.status('\n')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 hg_editor.commit_current_delta()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 binary_file_re = re.compile(r'''Index: ([^\n]*)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 =*
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 Cannot display: file marked as a binary type.''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 property_exec_set_re = re.compile(r'''Property changes on: ([^\n]*)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 _*
25
99f8e4b535e9 svn 1.4 and 1.5 have different ideas of diff output for prop changes.
Augie Fackler <durin42@gmail.com>
parents: 11
diff changeset
171 (?:Added|Name): svn:executable
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 \+ \*
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 ''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 property_exec_removed_re = re.compile(r'''Property changes on: ([^\n]*)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 _*
25
99f8e4b535e9 svn 1.4 and 1.5 have different ideas of diff output for prop changes.
Augie Fackler <durin42@gmail.com>
parents: 11
diff changeset
177 (?:Deleted|Name): svn:executable
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 - \*
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 ''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181 empty_file_patch_wont_make_re = re.compile(r'''Index: ([^\n]*)\n=*\n(?=Index:)''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
183 any_file_re = re.compile(r'''^Index: ([^\n]*)\n=*\n''', re.MULTILINE)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 property_special_set_re = re.compile(r'''Property changes on: ([^\n]*)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 _*
25
99f8e4b535e9 svn 1.4 and 1.5 have different ideas of diff output for prop changes.
Augie Fackler <durin42@gmail.com>
parents: 11
diff changeset
187 (?:Added|Name): svn:special
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 \+ \*
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189 ''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 property_special_removed_re = re.compile(r'''Property changes on: ([^\n]*)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 _*
25
99f8e4b535e9 svn 1.4 and 1.5 have different ideas of diff output for prop changes.
Augie Fackler <durin42@gmail.com>
parents: 11
diff changeset
193 (?:Deleted|Name): svn:special
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194 \- \*
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 ''')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 def make_diff_path(b):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198 if b == None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 return 'trunk'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 return 'branches/' + b
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201
73
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
202 def makecopyfinder(r, branchpath, rootdir):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
203 """Return a function detecting copies.
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
204
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
205 Returned copyfinder(path) returns None if no copy information can
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
206 be found or ((source, sourcerev), sourcepath) where "sourcepath" is the
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
207 copy source path, "sourcerev" the source svn revision and "source" is the
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
208 copy record path causing the copy to occur. If a single file was copied
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
209 "sourcepath" and "source" are the same, while file copies dectected from
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
210 directory copies return the copied source directory in "source".
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
211 """
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
212 # filter copy information for current branch
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
213 branchpath = branchpath + '/'
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
214 fullbranchpath = rootdir + branchpath
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
215 copies = []
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
216 for path, e in r.paths.iteritems():
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
217 if not e.copyfrom_path:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
218 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
219 if not path.startswith(branchpath):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
220 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
221 if not e.copyfrom_path.startswith(fullbranchpath):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
222 # ignore cross branch copies
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
223 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
224 dest = path[len(branchpath):]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
225 source = e.copyfrom_path[len(fullbranchpath):]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
226 copies.append((dest, (source, e.copyfrom_rev)))
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
227
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
228 copies.sort()
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
229 copies.reverse()
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
230 exactcopies = dict(copies)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
231
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
232 def finder(path):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
233 if path in exactcopies:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
234 return exactcopies[path], exactcopies[path][0]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
235 # look for parent directory copy, longest first
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
236 for dest, (source, sourcerev) in copies:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
237 dest = dest + '/'
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
238 if not path.startswith(dest):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
239 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
240 sourcepath = source + '/' + path[len(dest):]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
241 return (source, sourcerev), sourcepath
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
242 return None
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
243
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
244 return finder
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
245
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
246 def getcopies(svn, hg_editor, branch, branchpath, r, files, parentid):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
247 """Return a mapping {dest: source} for every file copied into r.
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
248 """
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
249 if parentid == revlog.nullid:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
250 return {}
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
251
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
252 # Extract svn copy information, group them by copy source.
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
253 # The idea is to duplicate the replay behaviour where copies are
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
254 # evaluated per copy event (one event for all files in a directory copy,
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
255 # one event for single file copy). We assume that copy events match
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
256 # copy sources in revision info.
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
257 svncopies = {}
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
258 finder = makecopyfinder(r, branchpath, svn.subdir)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
259 for f in files:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
260 copy = finder(f)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
261 if copy:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
262 svncopies.setdefault(copy[0], []).append((f, copy[1]))
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
263 if not svncopies:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
264 return {}
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
265
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
266 # cache changeset contexts and map them to source svn revisions
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
267 parentctx = hg_editor.repo.changectx(parentid)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
268 ctxs = {}
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
269 def getctx(svnrev):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
270 if svnrev in ctxs:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
271 return ctxs[svnrev]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
272 changeid = hg_editor.get_parent_revision(svnrev + 1, branch)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
273 ctx = None
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
274 if changeid != revlog.nullid:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
275 ctx = hg_editor.repo.changectx(changeid)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
276 ctxs[svnrev] = ctx
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
277 return ctx
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
278
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
279 # check svn copies really make sense in mercurial
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
280 hgcopies = {}
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
281 for (sourcepath, rev), copies in svncopies.iteritems():
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
282 sourcectx = getctx(rev)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
283 if sourcectx is None:
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
284 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
285 sources = [s[1] for s in copies]
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
286 if not hg_editor.aresamefiles(sourcectx, parentctx, sources):
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
287 continue
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
288 hgcopies.update(copies)
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
289 return hgcopies
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
290
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
291 def stupid_fetch_branchrev(svn, hg_editor, branch, branchpath, r, parentid):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
292 """Extract all 'branch' content at a given revision.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
293
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
294 Return a tuple (files, filectxfn) where 'files' is the list of all files
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
295 in the branch at the given revision, and 'filectxfn' is a memctx compatible
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
296 callable to retrieve individual file information.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
297 """
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
298 parentctx = hg_editor.repo[parentid]
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
299 kind = svn.checkpath(branchpath, r.revnum)
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
300 if kind is None:
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
301 # Branch does not exist at this revision. Get parent revision and
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
302 # remove everything.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
303 files = parentctx.manifest().keys()
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
304 def filectxfn(repo, memctx, path):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
305 raise IOError()
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
306 return files, filectxfn
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
307
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
308 files = []
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
309 branchprefix = branchpath + '/'
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
310 for path, e in r.paths.iteritems():
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
311 if not path.startswith(branchprefix):
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
312 continue
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
313 kind = svn.checkpath(path, r.revnum)
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
314 path = path[len(branchprefix):]
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
315 if kind == 'f':
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
316 files.append(path)
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
317 elif kind == 'd':
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
318 if e.action == 'M':
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
319 # Ignore property changes for now
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
320 continue
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
321 dirpath = branchprefix + path
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
322 for child, k in svn.list_files(dirpath, r.revnum):
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
323 if k == 'f':
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
324 files.append(path + '/' + child)
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
325 else:
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
326 if path in parentctx:
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
327 files.append(path)
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
328 continue
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
329 # Assume it's a deleted directory
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
330 path = path + '/'
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
331 deleted = [f for f in parentctx if f.startswith(path)]
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
332 files += deleted
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 79
diff changeset
333
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
334 copies = getcopies(svn, hg_editor, branch, branchpath, r, files, parentid)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
335
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
336 linkprefix = 'link '
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
337 def filectxfn(repo, memctx, path):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
338 data, mode = svn.get_file(branchpath + '/' + path, r.revnum)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
339 isexec = 'x' in mode
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
340 islink = 'l' in mode
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
341 if islink and data.startswith(linkprefix):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
342 data = data[len(linkprefix):]
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
343 copied = copies.get(path)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
344 return context.memfilectx(path=path, data=data, islink=islink,
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
345 isexec=isexec, copied=copied)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
346
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
347 return files, filectxfn
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
348
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 def stupid_svn_server_pull_rev(ui, svn, hg_editor, r):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
350 delete_all_files = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 # this server fails at replay
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
352 branches = hg_editor.branches_in_paths(r.paths)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
353 temp_location = os.path.join(hg_editor.path, '.hg', 'svn', 'temp')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
354 if not os.path.exists(temp_location):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
355 os.makedirs(temp_location)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
356 for b in branches:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
357 our_tempdir = tempfile.mkdtemp('svn_fetch_temp', dir=temp_location)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
358 diff_path = make_diff_path(b)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
359 parent_rev, br_p = hg_editor.get_parent_svn_branch_and_rev(r.revnum, b)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
360 parent_ha = hg_editor.get_parent_revision(r.revnum, b)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
361 files_touched = set()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
362 link_files = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
363 exec_files = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
364 try:
79
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
365 try:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
366 if br_p == b:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
367 # letting patch handle binaries sounded
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
368 # cool, but it breaks patch in sad ways
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
369 d = svn.get_unified_diff(diff_path, r.revnum, deleted=False,
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
370 ignore_type=False)
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
371 else:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
372 d = svn.get_unified_diff(diff_path, r.revnum,
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
373 other_path=make_diff_path(br_p),
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
374 other_rev=parent_rev,
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
375 deleted=True, ignore_type=True)
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
376 if d:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
377 ui.status('Branch creation with mods, pulling full rev.\n')
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
378 raise BadPatchApply()
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
379 except core.SubversionException, e:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
380 # "Can't write to stream: The handle is invalid."
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
381 # This error happens systematically under Windows, possibly
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
382 # related to file handles being non-write shareable by default.
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
383 if e.apr_err != 720006:
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
384 raise
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
385 raise BadPatchApply()
2e47623fa174 fetch_command: handle failing svn.diff3() on Windows, fetch full revision
Patrick Mezard <pmezard@gmail.com>
parents: 77
diff changeset
386
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
387 for m in binary_file_re.findall(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
388 # we have to pull each binary file by hand as a fulltext,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
389 # which sucks but we've got no choice
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
390 file_path = os.path.join(our_tempdir, m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
391 files_touched.add(m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
392 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
393 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
394 os.makedirs(os.path.dirname(file_path))
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
395 except OSError, e:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
396 pass
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
397 f = open(file_path, 'w')
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 74
diff changeset
398 f.write(svn.get_file(diff_path+'/'+m, r.revnum)[0])
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
399 f.close()
74
450d5d9d3b80 SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
400 except IOError:
450d5d9d3b80 SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
401 pass
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
402 d2 = empty_file_patch_wont_make_re.sub('', d)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 d2 = property_exec_set_re.sub('', d2)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
404 d2 = property_exec_removed_re.sub('', d2)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
405 old_cwd = os.getcwd()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
406 os.chdir(our_tempdir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
407 for f in any_file_re.findall(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
408 files_touched.add(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
409 # this check is here because modified binary files will get
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
410 # created before here.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
411 if os.path.exists(f):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
412 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
413 dn = os.path.dirname(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
414 if dn and not os.path.exists(dn):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
415 os.makedirs(dn)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
416 if f in hg_editor.repo[parent_ha].manifest():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
417 data = hg_editor.repo[parent_ha].filectx(f).data()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
418 fi = open(f, 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
419 fi.write(data)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420 fi.close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
421 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
422 open(f, 'w').close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
423 if f.startswith(our_tempdir):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
424 f = f[len(our_tempdir)+1:]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
425 os.chdir(old_cwd)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
426 if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
427 old_cwd = os.getcwd()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
428 os.chdir(our_tempdir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
429 changed = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
430 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431 patch_st = patch.applydiff(ui, cStringIO.StringIO(d2),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 changed, strip=0)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 except patch.PatchError:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 # TODO: this happens if the svn server has the wrong mime
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
435 # type stored and doesn't know a file is binary. It would
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
436 # be better to do one file at a time and only do a
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
437 # full fetch on files that had problems.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
438 os.chdir(old_cwd)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
439 raise BadPatchApply()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
440 for x in changed.iterkeys():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
441 ui.status('M %s\n' % x)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
442 files_touched.add(x)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
443 os.chdir(old_cwd)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
444 # if this patch didn't apply right, fall back to exporting the
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
445 # entire rev.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
446 if patch_st == -1:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
447 parent_ctx = hg_editor.repo[parent_ha]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
448 parent_manifest = parent_ctx.manifest()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
449 for fn in files_touched:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 if (fn in parent_manifest and
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 'l' in parent_ctx.filectx(fn).flags()):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
452 # I think this might be an underlying bug in svn -
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
453 # I get diffs of deleted symlinks even though I
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
454 # specifically said no deletes above.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
455 ui.status('Pulling whole rev because of a deleted'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
456 'symlink')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
457 raise BadPatchApply()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
458 assert False, ('This should only happen on case-insensitive'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
459 ' volumes.')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
460 elif patch_st == 1:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
461 # When converting Django, I saw fuzz on .po files that was
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
462 # causing revisions to end up failing verification. If that
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
463 # can be fixed, maybe this won't ever be reached.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
464 ui.status('There was some fuzz, not using diff after all.')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
465 raise BadPatchApply()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
466 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
467 ui.status('Not using patch for %s, diff had no hunks.\n' %
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
468 r.revnum)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
469
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
470 # we create the files if they don't exist here because we know
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
471 # that we'll never have diff info for a deleted file, so if the
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
472 # property is set, we should force the file to exist no matter what.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
473 for m in property_exec_removed_re.findall(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
474 f = os.path.join(our_tempdir, m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
475 if not os.path.exists(f):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
476 d = os.path.dirname(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
477 if not os.path.exists(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
478 os.makedirs(d)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
479 if not m in hg_editor.repo[parent_ha].manifest():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
480 open(f, 'w').close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
481 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
482 data = hg_editor.repo[parent_ha].filectx(m).data()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
483 fp = open(f, 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
484 fp.write(data)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
485 fp.close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
486 exec_files[m] = False
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
487 files_touched.add(m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
488 for m in property_exec_set_re.findall(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
489 f = os.path.join(our_tempdir, m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
490 if not os.path.exists(f):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
491 d = os.path.dirname(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
492 if not os.path.exists(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
493 os.makedirs(d)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
494 if m not in hg_editor.repo[parent_ha].manifest():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
495 open(f, 'w').close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
496 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
497 data = hg_editor.repo[parent_ha].filectx(m).data()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
498 fp = open(f, 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
499 fp.write(data)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
500 fp.close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
501 exec_files[m] = True
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
502 files_touched.add(m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
503 for m in property_special_set_re.findall(d):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
504 # TODO(augie) when a symlink is removed, patching will fail.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
505 # We're seeing that above - there's gotta be a better
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
506 # workaround than just bailing like that.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
507 path = os.path.join(our_tempdir, m)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
508 assert os.path.exists(path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
509 link_path = open(path).read()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
510 link_path = link_path[len('link '):]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
511 os.remove(path)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
512 link_files[m] = link_path
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
513 files_touched.add(m)
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
514 except (core.SubversionException, BadPatchApply), e:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
515 if (hasattr(e, 'apr_err') and e.apr_err != 160013):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
516 raise
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
517 # Either this revision or the previous one does not exist.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
518 ui.status("fetching entire rev previous rev does not exist.\n")
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
519 files_touched, filectxfn = stupid_fetch_branchrev(
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
520 svn, hg_editor, b, branches[b], r, parent_ha)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
521 else:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
522 for p in r.paths:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
523 if p.startswith(diff_path) and r.paths[p].action == 'D':
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
524 p2 = p[len(diff_path)+1:]
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
525 files_touched.add(p2)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
526 p3 = os.path.join(our_tempdir, p2)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
527 if os.path.exists(p3) and not os.path.isdir(p3):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
528 os.unlink(p3)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
529 if p2 and p2[0] == '/':
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
530 p2 = p2[1:]
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
531 # If this isn't in the parent ctx, it must've been a dir
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
532 if not p2 in hg_editor.repo[parent_ha]:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
533 d_files = [f for f in hg_editor.repo[parent_ha].manifest().iterkeys()
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
534 if f.startswith(p2 + '/')]
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
535 for d in d_files:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
536 files_touched.add(d)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
537 if delete_all_files:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
538 for p in hg_editor.repo[parent_ha].manifest().iterkeys():
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
539 if p:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
540 files_touched.add(p)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
541
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
542 copies = getcopies(svn, hg_editor, b, branches[b], r, files_touched,
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
543 parent_ha)
73
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
544
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
545 def filectxfn(repo, memctx, path):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
546 disk_path = os.path.join(our_tempdir, path)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
547 if path in link_files:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
548 return context.memfilectx(path=path, data=link_files[path],
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
549 islink=True, isexec=False,
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
550 copied=False)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
551 fp = open(disk_path)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
552 exe = exec_files.get(path, None)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
553 if exe is None and path in hg_editor.repo[parent_ha]:
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
554 exe = 'x' in hg_editor.repo[parent_ha].filectx(path).flags()
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
555 copied = copies.get(path)
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
556 return context.memfilectx(path=path, data=fp.read(), islink=False,
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
557 isexec=exe, copied=copied)
73
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 63
diff changeset
558
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
559 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
560 date += ' -0000'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
561 extra = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
562 if b:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
563 extra['branch'] = b
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 58
diff changeset
564 if '' in files_touched:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 58
diff changeset
565 files_touched.remove('')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
566 if parent_ha != node.nullid or files_touched:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
567 # TODO(augie) remove this debug code? Or maybe it's sane to have it.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
568 for f in files_touched:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
569 if f:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
570 assert f[0] != '/'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
571 current_ctx = context.memctx(hg_editor.repo,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
572 [parent_ha, revlog.nullid],
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
573 r.message or '...',
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
574 files_touched,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
575 filectxfn,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
576 '%s%s' % (r.author,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
577 hg_editor.author_host),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
578 date,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
579 extra)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
580 ha = hg_editor.repo.commitctx(current_ctx)
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 32
diff changeset
581 hg_editor.add_to_revmap(r.revnum, b, ha)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
582 hg_editor._save_metadata()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
583 ui.status('committed as %s on branch %s\n' %
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
584 (node.hex(ha), b or 'default'))
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
585 shutil.rmtree(our_tempdir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
586
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
587
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
588 class BadPatchApply(Exception):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
589 pass