Mercurial > hgsubversion
annotate fetch_command.py @ 225:2117cb0118fe
Get rid of .hg/svn/last_rev:
We now calculate the last known revision by iterating over all known
revisions and finding the highest number. Theoretically, we might be
able to simply read the latest entry, but in practice, that's a bug
waiting to happen. For instance, we might want to achieve
compatibility with '.hg/shamap' as generated by the
ConvertExtension, and it not only cannot offer a guarantee of
linearity, but it also allows more than one conversion to source exists.
I'd say we have other problems to care about until this turns up as a
hotspot in profiling. Such as why we leak circa 100MB of memory per
1000 revisions converted ;)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 27 Mar 2009 01:09:36 +0100 |
parents | 2165461d2dd8 |
children | f71af18c4379 4aba7542f6a9 |
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 os |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import patch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import node |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from mercurial import context |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 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
|
9 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
|
10 from svn import core |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 from svn import delta |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 import hg_delta_editor |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 import svnwrap |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
15 import svnexternals |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 import util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 |
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
|
19 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
|
20 ui.status("In light of that, I'll fall back and do diffs, but it won't do " |
11 | 21 "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
|
22 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 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
|
25 tag_locations='tags', |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
166
diff
changeset
|
26 authors=None, |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
27 filemap=None, |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
184
diff
changeset
|
29 """pull new revisions from Subversion |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 """ |
140
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
31 svn_url = util.normalize_url(svn_url) |
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 |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
36 if have_replay and not callable( |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
37 delta.svn_txdelta_apply(None, None, 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 | 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, |
167
3cd6a7354207
fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents:
166
diff
changeset
|
52 tag_locations=tag_locations, |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
53 authors=authors, |
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
54 filemap=filemap) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 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
|
56 uuid = open(hg_editor.uuid_file).read() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 assert uuid == svn.uuid |
225
2117cb0118fe
Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
224
diff
changeset
|
58 start = hg_editor.last_known_revision() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 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
|
61 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
|
62 initializing_repo = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 start = skipto_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 |
197
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
188
diff
changeset
|
65 if initializing_repo and start > 0: |
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
188
diff
changeset
|
66 raise merc_util.Abort('Revision skipping at repository initialization ' |
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
188
diff
changeset
|
67 'remains unimplemented.') |
43d56e973c3c
Replace a few asserts with aborts.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
188
diff
changeset
|
68 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 # start converting revisions |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 for r in svn.revisions(start=start): |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
71 valid = True |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 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
|
73 for p in r.paths: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 if hg_editor._is_path_valid(p): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 valid = True |
166
db88e528e8e6
Fixed typo: "continue" should have been "break".
Martin Geisler <mg@daimi.au.dk>
parents:
163
diff
changeset
|
76 break |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 if valid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 # got a 502? Try more than once! |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 tries = 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 converted = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 while not converted and tries < 3: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 try: |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
83 util.describe_revision(ui, r) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 if have_replay: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 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
|
87 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
|
88 ui.status('%s\n' % e.message) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 print_your_svn_is_old_message(ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
90 have_replay = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 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
|
92 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 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
|
94 converted = True |
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
|
95 except core.SubversionException, e: #pragma: no cover |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
203
diff
changeset
|
96 if e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 tries += 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 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
|
99 else: |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
203
diff
changeset
|
100 raise merc_util.Abort(*e.args) |
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
|
101 merc_util._encoding = old_encoding |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
179
diff
changeset
|
102 fetch_revisions = util.register_subcommand('pull')(fetch_revisions) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 |
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
|
105 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
|
106 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
|
107 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
|
108 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 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
|
110 hg_editor.set_current_rev(r) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 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
|
112 i = 1 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
113 if hg_editor.missing_plaintexts: |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
114 hg_editor.ui.debug('Fetching %s files that could not use replay.\n' % |
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
115 len(hg_editor.missing_plaintexts)) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 files_to_grab = set() |
98
c7ac013cf7fd
fetch_command: simplify replay_convert_rev() with svn.list_files()
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
117 rootpath = svn.subdir and svn.subdir[1:] or '' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 for p in hg_editor.missing_plaintexts: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
119 hg_editor.ui.note('.') |
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
|
120 hg_editor.ui.flush() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 if p[-1] == '/': |
98
c7ac013cf7fd
fetch_command: simplify replay_convert_rev() with svn.list_files()
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
122 dirpath = p[len(rootpath):] |
182
47d25d61abfa
remove generators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
181
diff
changeset
|
123 files_to_grab.update([dirpath + f for f,k in |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
124 svn.list_files(dirpath, r.revnum) |
182
47d25d61abfa
remove generators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
181
diff
changeset
|
125 if k == 'f']) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
126 else: |
98
c7ac013cf7fd
fetch_command: simplify replay_convert_rev() with svn.list_files()
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
127 files_to_grab.add(p[len(rootpath):]) |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
128 hg_editor.ui.note('\nFetching files...\n') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
129 for p in files_to_grab: |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
130 hg_editor.ui.note('.') |
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
|
131 hg_editor.ui.flush() |
9ee7ce0505eb
Fixes so that I can clone the melange repository successfully. Fixes a bug that
Augie Fackler <durin42@gmail.com>
parents:
33
diff
changeset
|
132 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
|
133 i += 1 |
98
c7ac013cf7fd
fetch_command: simplify replay_convert_rev() with svn.list_files()
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
134 data, mode = svn.get_file(p, r.revnum) |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
90
diff
changeset
|
135 hg_editor.set_file(p, data, 'x' in mode, 'l' in mode) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
136 hg_editor.missing_plaintexts = set() |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
137 hg_editor.ui.note('\n') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 hg_editor.commit_current_delta() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
139 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 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
|
142 =* |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 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
|
144 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 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
|
146 _* |
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
|
147 (?:Added|Name): svn:executable |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
110
diff
changeset
|
148 \+''') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 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
|
151 _* |
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
|
152 (?:Deleted|Name): svn:executable |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
110
diff
changeset
|
153 -''') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 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
|
156 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 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
|
158 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 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
|
160 _* |
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
|
161 (?:Added|Name): svn:special |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
110
diff
changeset
|
162 \+''') |
0
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 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
|
165 _* |
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
|
166 (?:Deleted|Name): svn:special |
111
5497d1264b4d
fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents:
110
diff
changeset
|
167 \-''') |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
168 |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
169 def mempatchproxy(parentctx, files): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
170 # Avoid circular references patch.patchfile -> mempatch |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
171 patchfile = patch.patchfile |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
172 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
173 class mempatch(patchfile): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
174 def __init__(self, ui, fname, opener, missing=False): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
175 patchfile.__init__(self, ui, fname, None, False) |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
176 |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
177 def readlines(self, fname): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
178 if fname not in parentctx: |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
179 raise IOError('Cannot find %r to patch' % fname) |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
180 fctx = parentctx[fname] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
181 data = fctx.data() |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
182 if 'l' in fctx.flags(): |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
183 data = 'link ' + data |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
184 return cStringIO.StringIO(data).readlines() |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
185 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
186 def writelines(self, fname, lines): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
187 files[fname] = ''.join(lines) |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
188 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
189 def unlink(self, fname): |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
190 files[fname] = None |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
191 |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
192 return mempatch |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
193 |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
194 |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
195 def filteriterhunks(hg_editor): |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
196 iterhunks = patch.iterhunks |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
197 def filterhunks(ui, fp, sourcefile=None): |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
198 applycurrent = False |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
199 for data in iterhunks(ui, fp, sourcefile): |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
200 if data[0] == 'file': |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
201 if hg_editor._is_file_included(data[1][1]): |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
202 applycurrent = True |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
203 else: |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
204 applycurrent = False |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
205 assert data[0] != 'git', 'Filtering git hunks not supported.' |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
206 if applycurrent: |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
207 yield data |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
208 return filterhunks |
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
209 |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
210 def stupid_diff_branchrev(ui, svn, hg_editor, branch, r, parentctx): |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
211 """Extract all 'branch' content at a given revision. |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
212 |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
213 Return a tuple (files, filectxfn) where 'files' is the list of all files |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
214 in the branch at the given revision, and 'filectxfn' is a memctx compatible |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
215 callable to retrieve individual file information. Raise BadPatchApply upon |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
216 error. |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
217 """ |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
218 def make_diff_path(branch): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
219 if branch == 'trunk' or branch is None: |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
220 return 'trunk' |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
221 elif branch.startswith('../'): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
222 return branch[3:] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
223 return 'branches/%s' % branch |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
224 parent_rev, br_p = hg_editor.get_parent_svn_branch_and_rev(r.revnum, branch) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
225 diff_path = make_diff_path(branch) |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
226 try: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
227 if br_p == branch: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
228 # letting patch handle binaries sounded |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
229 # cool, but it breaks patch in sad ways |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
230 d = svn.get_unified_diff(diff_path, r.revnum, deleted=False, |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
231 ignore_type=False) |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
232 else: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
233 d = svn.get_unified_diff(diff_path, r.revnum, |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
234 other_path=make_diff_path(br_p), |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
235 other_rev=parent_rev, |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
236 deleted=True, ignore_type=True) |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
237 if d: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
238 raise BadPatchApply('branch creation with mods') |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
239 except svnwrap.SubversionRepoCanNotDiff: |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
240 raise BadPatchApply('subversion diffing code is not supported') |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
241 except core.SubversionException, e: |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
203
diff
changeset
|
242 if (hasattr(e, 'apr_err') and e.apr_err != core.SVN_ERR_FS_NOT_FOUND): |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
243 raise |
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
244 raise BadPatchApply('previous revision does not exist') |
169
f1919e1c35bf
fetch_command: cancel patching when encountering binary diffs
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
245 if '\0' in d: |
f1919e1c35bf
fetch_command: cancel patching when encountering binary diffs
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
246 raise BadPatchApply('binary diffs are not supported') |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
247 files_data = {} |
128
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
248 binary_files = {} |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
249 touched_files = {} |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
250 for m in binary_file_re.findall(d): |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
251 # we have to pull each binary file by hand as a fulltext, |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
252 # which sucks but we've got no choice |
128
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
253 binary_files[m] = 1 |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
254 touched_files[m] = 1 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
255 d2 = empty_file_patch_wont_make_re.sub('', d) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
256 d2 = property_exec_set_re.sub('', d2) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
257 d2 = property_exec_removed_re.sub('', d2) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
258 for f in any_file_re.findall(d): |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
259 # Here we ensure that all files, including the new empty ones |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
260 # are marked as touched. Content is loaded on demand. |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
261 touched_files[f] = 1 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
262 if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
263 try: |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
264 oldpatchfile = patch.patchfile |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
265 olditerhunks = patch.iterhunks |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
266 patch.patchfile = mempatchproxy(parentctx, files_data) |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
267 patch.iterhunks = filteriterhunks(hg_editor) |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
268 try: |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
269 # We can safely ignore the changed list since we are |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
270 # handling non-git patches. Touched files are known |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
271 # by our memory patcher. |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
272 patch_st = patch.applydiff(ui, cStringIO.StringIO(d2), |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
273 {}, strip=0) |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
274 finally: |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
275 patch.patchfile = oldpatchfile |
200
2e8c527f0456
stupid replay: Don't actually try and apply diffs to files we don't have anyway.
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
276 patch.iterhunks = olditerhunks |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
277 except patch.PatchError: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
278 # TODO: this happens if the svn server has the wrong mime |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
279 # type stored and doesn't know a file is binary. It would |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
280 # be better to do one file at a time and only do a |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
281 # full fetch on files that had problems. |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
282 raise BadPatchApply('patching failed') |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
283 for x in files_data.iterkeys(): |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
284 ui.note('M %s\n' % x) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
285 # if this patch didn't apply right, fall back to exporting the |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
286 # entire rev. |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
287 if patch_st == -1: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
288 assert False, ('This should only happen on case-insensitive' |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
289 ' volumes.') |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
290 elif patch_st == 1: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
291 # When converting Django, I saw fuzz on .po files that was |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
292 # causing revisions to end up failing verification. If that |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
293 # can be fixed, maybe this won't ever be reached. |
109
460443a96497
fetch_command: only raise BadPatchApply() from stupid_diff_branchrev()
Patrick Mezard <pmezard@gmail.com>
parents:
108
diff
changeset
|
294 raise BadPatchApply('patching succeeded with fuzz') |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
295 else: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
296 ui.status('Not using patch for %s, diff had no hunks.\n' % |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
297 r.revnum) |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
298 |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
299 exec_files = {} |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
300 for m in property_exec_removed_re.findall(d): |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
301 exec_files[m] = False |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
302 for m in property_exec_set_re.findall(d): |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
303 exec_files[m] = True |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
304 for m in exec_files: |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
305 touched_files[m] = 1 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
306 link_files = {} |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
307 for m in property_special_set_re.findall(d): |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
308 # TODO(augie) when a symlink is removed, patching will fail. |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
309 # We're seeing that above - there's gotta be a better |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
310 # workaround than just bailing like that. |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
311 assert m in files_data |
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
312 link_files[m] = True |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
313 for m in property_special_removed_re.findall(d): |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
314 assert m in files_data |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
315 link_files[m] = False |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
316 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
317 for p in r.paths: |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
318 if p.startswith(diff_path) and r.paths[p].action == 'D': |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
319 p2 = p[len(diff_path)+1:].strip('/') |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
320 if p2 in parentctx: |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
321 files_data[p2] = None |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
322 continue |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
323 # If this isn't in the parent ctx, it must've been a dir |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
324 files_data.update([(f, None) for f in parentctx if f.startswith(p2 + '/')]) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
325 |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
326 for f in files_data: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
327 touched_files[f] = 1 |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
328 |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
329 copies = getcopies(svn, hg_editor, branch, diff_path, r, touched_files, |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
330 parentctx) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
331 |
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
332 def filectxfn(repo, memctx, path): |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
333 if path in files_data and files_data[path] is None: |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
334 raise IOError() |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
335 |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
336 if path in binary_files: |
128
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
337 data, mode = svn.get_file(diff_path + '/' + path, r.revnum) |
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
338 isexe = 'x' in mode |
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
339 islink = 'l' in mode |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
340 else: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
341 isexe = exec_files.get(path, 'x' in parentctx.flags(path)) |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
342 islink = link_files.get(path, 'l' in parentctx.flags(path)) |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
343 data = '' |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
344 if path in files_data: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
345 data = files_data[path] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
346 if islink: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
347 data = data[len('link '):] |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
348 elif path in parentctx: |
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
349 data = parentctx[path].data() |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
350 |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
351 copied = copies.get(path) |
128
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
352 return context.memfilectx(path=path, data=data, islink=islink, |
bab5bcbbb3dc
fetch_command: in stupid mode, load binary files when necessary
Patrick Mezard <pmezard@gmail.com>
parents:
127
diff
changeset
|
353 isexec=isexe, copied=copied) |
108
de19a13edfa8
fetch_command: extract diff code in a function
Patrick Mezard <pmezard@gmail.com>
parents:
107
diff
changeset
|
354 |
129
59f8603a6641
fetch_command: in stupid mode, load file content on demand
Patrick Mezard <pmezard@gmail.com>
parents:
128
diff
changeset
|
355 return list(touched_files), filectxfn |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
357 def makecopyfinder(r, branchpath, rootdir): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
358 """Return a function detecting copies. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
359 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 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
|
364 "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
|
365 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
|
366 """ |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
367 # 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
|
368 branchpath = branchpath + '/' |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
369 fullbranchpath = rootdir + branchpath |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
370 copies = [] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
371 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
|
372 if not e.copyfrom_path: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
373 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
374 if not path.startswith(branchpath): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
375 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
376 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
|
377 # ignore cross branch copies |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
378 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
379 dest = path[len(branchpath):] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
380 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
|
381 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
|
382 |
163 | 383 copies.sort(reverse=True) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
384 exactcopies = dict(copies) |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
385 |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
386 def finder(path): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
387 if path in exactcopies: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
388 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
|
389 # 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
|
390 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
|
391 dest = dest + '/' |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
392 if not path.startswith(dest): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
393 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
394 sourcepath = source + '/' + path[len(dest):] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
395 return (source, sourcerev), sourcepath |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
396 return None |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
397 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
398 return finder |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
399 |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
400 def getcopies(svn, hg_editor, branch, branchpath, r, files, parentctx): |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
401 """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
|
402 """ |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
403 if parentctx.node() == revlog.nullid: |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
404 return {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
405 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
406 # 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
|
407 # 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
|
408 # 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
|
409 # 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
|
410 # copy sources in revision info. |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
411 svncopies = {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
412 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
|
413 for f in files: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
414 copy = finder(f) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
415 if copy: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
416 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
|
417 if not svncopies: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
418 return {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
419 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
420 # 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
|
421 ctxs = {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
422 def getctx(svnrev): |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
423 if svnrev in ctxs: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
424 return ctxs[svnrev] |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
425 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
|
426 ctx = None |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
427 if changeid != revlog.nullid: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
428 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
|
429 ctxs[svnrev] = ctx |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
430 return ctx |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
431 |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
432 # 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
|
433 hgcopies = {} |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
434 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
|
435 sourcectx = getctx(rev) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
436 if sourcectx is None: |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
437 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
438 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
|
439 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
|
440 continue |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
441 hgcopies.update(copies) |
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
442 return hgcopies |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
444 def stupid_fetch_externals(svn, branchpath, r, parentctx): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
445 """Extract svn:externals for the current revision and branch |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
446 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
447 Return an externalsfile instance or None if there are no externals |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
448 to convert and never were. |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
449 """ |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
450 externals = svnexternals.externalsfile() |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
451 if '.hgsvnexternals' in parentctx: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
452 externals.read(parentctx['.hgsvnexternals'].data()) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
453 # Detect property additions only, changes are handled by checking |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
454 # existing entries individually. Projects are unlikely to store |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
455 # externals on many different root directories, so we trade code |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
456 # duplication and complexity for a constant lookup price at every |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
457 # revision in the common case. |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
458 dirs = set(externals) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
459 if parentctx.node() == revlog.nullid: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
460 dirs.update([p for p,k in svn.list_files(branchpath, r.revnum) if k == 'd']) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
461 dirs.add('') |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
462 else: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
463 branchprefix = branchpath + '/' |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
464 for path, e in r.paths.iteritems(): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
465 if e.action == 'D': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
466 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
467 if not path.startswith(branchprefix) and path != branchpath: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
468 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
469 kind = svn.checkpath(path, r.revnum) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
470 if kind != 'd': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
471 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
472 path = path[len(branchprefix):] |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
473 dirs.add(path) |
184
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
474 if e.action == 'M' or (e.action == 'A' and e.copyfrom_path): |
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
475 # Do not recurse in copied directories, changes are marked |
d3ea6c98a086
Do not recurse for externals on copied directory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
182
diff
changeset
|
476 # as 'M', except for the copied one. |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
477 continue |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
478 for child, k in svn.list_files(branchprefix + path, r.revnum): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
479 if k == 'd': |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
480 dirs.add((path + '/' + child).strip('/')) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
481 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
482 # Retrieve new or updated values |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
483 for dir in dirs: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
484 try: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
485 values = svn.list_props(branchpath + '/' + dir, r.revnum) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
486 externals[dir] = values.get('svn:externals', '') |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
487 except IOError: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
488 externals[dir] = '' |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
489 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
490 if not externals and '.hgsvnexternals' not in parentctx: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
491 # Do not create empty externals files |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
492 return None |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
493 return externals |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
494 |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
495 def stupid_fetch_branchrev(svn, hg_editor, branch, branchpath, r, parentctx): |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
496 """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
|
497 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
498 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
|
499 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
|
500 callable to retrieve individual file information. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
501 """ |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
502 files = [] |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
503 if parentctx.node() == revlog.nullid: |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
504 # Initial revision, fetch all files |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
505 for path, kind in svn.list_files(branchpath, r.revnum): |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
506 if kind == 'f': |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
507 files.append(path) |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
508 else: |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
509 branchprefix = branchpath + '/' |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
510 for path, e in r.paths.iteritems(): |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
511 if not path.startswith(branchprefix): |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
512 continue |
187
68e506bc3a43
fetch_command: fix file exclusion in very stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
186
diff
changeset
|
513 if not hg_editor._is_path_valid(path): |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
514 continue |
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
515 kind = svn.checkpath(path, r.revnum) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
516 path = path[len(branchprefix):] |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
517 if kind == 'f': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
518 files.append(path) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
519 elif kind == 'd': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
520 if e.action == 'M': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
521 continue |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
522 dirpath = branchprefix + path |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
523 for child, k in svn.list_files(dirpath, r.revnum): |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
524 if k == 'f': |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
525 files.append(path + '/' + child) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
526 else: |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
527 if path in parentctx: |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
528 files.append(path) |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
529 continue |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
530 # Assume it's a deleted directory |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
531 path = path + '/' |
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
532 deleted = [f for f in parentctx if f.startswith(path)] |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
533 files += deleted |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
79
diff
changeset
|
534 |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
535 copies = getcopies(svn, hg_editor, branch, branchpath, r, files, parentctx) |
101
a3b717e4abf5
Cleanups based on pyflakes output.
Augie Fackler <durin42@gmail.com>
parents:
98
diff
changeset
|
536 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
537 def filectxfn(repo, memctx, path): |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
538 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
|
539 isexec = 'x' in mode |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
540 islink = 'l' in mode |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
541 copied = copies.get(path) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
542 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
|
543 isexec=isexec, copied=copied) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
544 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
545 return files, filectxfn |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
546 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
547 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
|
548 # this server fails at replay |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
549 branches = hg_editor.branches_in_paths(r.paths, r.revnum, svn.checkpath, svn.list_files) |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
550 deleted_branches = {} |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
551 brpaths = branches.values() |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
552 bad_branch_paths = {} |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
553 for br, bp in branches.iteritems(): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
554 bad_branch_paths[br] = [] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
555 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
556 # This next block might be needed, but for now I'm omitting it until it can be |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
557 # proven necessary. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
558 # for bad in brpaths: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
559 # if bad.startswith(bp) and len(bad) > len(bp): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
560 # bad_branch_paths[br].append(bad[len(bp)+1:]) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
561 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
562 # We've go a branch that contains other branches. We have to be careful to |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
563 # get results similar to real replay in this case. |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
564 for existingbr in hg_editor.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
565 bad = hg_editor._remotename(existingbr) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
566 if bad.startswith(bp) and len(bad) > len(bp): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
567 bad_branch_paths[br].append(bad[len(bp)+1:]) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
568 for p in r.paths: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
569 if hg_editor._is_path_tag(p): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
570 continue |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
571 branch = hg_editor._localname(p) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
572 if r.paths[p].action == 'R' and branch in hg_editor.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
573 branchedits = sorted(filter(lambda x: x[0][1] == branch and x[0][0] < r.revnum, |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
574 hg_editor.revmap.iteritems()), reverse=True) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
575 is_closed = False |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
576 if len(branchedits) > 0: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
577 branchtip = branchedits[0][1] |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
578 for child in hg_editor.repo[branchtip].children(): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
579 if child.branch() == 'closed-branches': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
580 is_closed = True |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
581 break |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
582 if not is_closed: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
583 deleted_branches[branch] = branchtip |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
584 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0] |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
585 date += ' -0000' |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
586 check_deleted_branches = set() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
587 for b in branches: |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
588 parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)] |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
589 if parentctx.branch() != (b or 'default'): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
590 check_deleted_branches.add(b) |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
591 kind = svn.checkpath(branches[b], r.revnum) |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
592 if kind != 'd': |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
593 # Branch does not exist at this revision. Get parent revision and |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
594 # remove everything. |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
595 deleted_branches[b] = parentctx.node() |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
596 continue |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
597 else: |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
598 try: |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
599 files_touched, filectxfn2 = stupid_diff_branchrev( |
127
7e45bcf52b64
fetch_command: patch files in memory in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
119
diff
changeset
|
600 ui, svn, hg_editor, b, r, parentctx) |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
601 except BadPatchApply, e: |
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
602 # Either this revision or the previous one does not exist. |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
203
diff
changeset
|
603 ui.status("Fetching entire revision: %s.\n" % e.args[0]) |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
604 files_touched, filectxfn2 = stupid_fetch_branchrev( |
119
ea65fe2b0856
hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents:
118
diff
changeset
|
605 svn, hg_editor, b, branches[b], r, parentctx) |
73
9c1b53abefcb
fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
63
diff
changeset
|
606 |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
607 externals = stupid_fetch_externals(svn, branches[b], r, parentctx) |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
608 if externals is not None: |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
609 files_touched.append('.hgsvnexternals') |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
610 |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
611 def filectxfn(repo, memctx, path): |
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
612 if path == '.hgsvnexternals': |
176
c4115b3918e9
Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents:
174
diff
changeset
|
613 if not externals: |
c4115b3918e9
Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents:
174
diff
changeset
|
614 raise IOError() |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
615 return context.memfilectx(path=path, data=externals.write(), |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
616 islink=False, isexec=False, copied=None) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
617 for bad in bad_branch_paths[b]: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
618 if path.startswith(bad): |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
619 raise IOError() |
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
620 return filectxfn2(repo, memctx, path) |
179
a336e3e82648
Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents:
176
diff
changeset
|
621 |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
622 extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir) |
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
|
623 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
|
624 files_touched.remove('') |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
625 excluded = [f for f in files_touched |
188
f48cd62a9de4
fetch_command: fix coding style
Patrick Mezard <pmezard@gmail.com>
parents:
187
diff
changeset
|
626 if not hg_editor._is_file_included(f)] |
f48cd62a9de4
fetch_command: fix coding style
Patrick Mezard <pmezard@gmail.com>
parents:
187
diff
changeset
|
627 for f in excluded: |
f48cd62a9de4
fetch_command: fix coding style
Patrick Mezard <pmezard@gmail.com>
parents:
187
diff
changeset
|
628 files_touched.remove(f) |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
629 if parentctx.node() != node.nullid or files_touched: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
630 # 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
|
631 for f in files_touched: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
632 if f: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
633 assert f[0] != '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
634 current_ctx = context.memctx(hg_editor.repo, |
110
a4dcffaa6538
fetch_command: pass parent changectx instead of identifier
Patrick Mezard <pmezard@gmail.com>
parents:
109
diff
changeset
|
635 [parentctx.node(), revlog.nullid], |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
636 r.message or util.default_commit_msg, |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
637 files_touched, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
638 filectxfn, |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
639 hg_editor.authorforsvnauthor(r.author), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
640 date, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
641 extra) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
642 ha = hg_editor.repo.commitctx(current_ctx) |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
643 branch = extra.get('branch', None) |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
644 if not branch in hg_editor.branches: |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
645 hg_editor.branches[branch] = None, 0, r.revnum |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
32
diff
changeset
|
646 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
|
647 hg_editor._save_metadata() |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
197
diff
changeset
|
648 util.describe_commit(ui, ha, b) |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
649 # These are branches which would have an 'R' status in svn log. This means they were |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
650 # replaced by some other branch, so we need to verify they get marked as closed. |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
651 for branch in check_deleted_branches: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
652 branchedits = sorted(filter(lambda x: x[0][1] == branch and x[0][0] < r.revnum, |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
653 hg_editor.revmap.iteritems()), reverse=True) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
654 is_closed = False |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
655 if len(branchedits) > 0: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
656 branchtip = branchedits[0][1] |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
657 for child in hg_editor.repo[branchtip].children(): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
658 if child.branch() == 'closed-branches': |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
659 is_closed = True |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
660 break |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
661 if not is_closed: |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
141
diff
changeset
|
662 deleted_branches[branch] = branchtip |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
663 for b, parent in deleted_branches.iteritems(): |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
664 if parent == node.nullid: |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
665 continue |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
666 parentctx = hg_editor.repo[parent] |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
667 files_touched = parentctx.manifest().keys() |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
668 def filectxfn(repo, memctx, path): |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
669 raise IOError() |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
670 closed = node.nullid |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
671 if 'closed-branches' in hg_editor.repo.branchtags(): |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
672 closed = hg_editor.repo['closed-branches'].node() |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
673 parents = (parent, closed) |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
674 current_ctx = context.memctx(hg_editor.repo, |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
675 parents, |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
676 r.message or util.default_commit_msg, |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
677 files_touched, |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
678 filectxfn, |
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
679 hg_editor.authorforsvnauthor(r.author), |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
680 date, |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
681 {'branch': 'closed-branches'}) |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
682 ha = hg_editor.repo.commitctx(current_ctx) |
141 | 683 ui.status('Marked branch %s as closed.\n' % (b or 'default')) |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
684 hg_editor._save_metadata() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
685 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
686 class BadPatchApply(Exception): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
687 pass |