Mercurial > hgsubversion
annotate push_cmd.py @ 72:9ec2a12c12ae
hg_delta_editor: make branches_in_paths() return the branch svn path too
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 05 Nov 2008 13:37:08 +0100 |
parents | 49b7cbe4c8e3 |
children | 6c9b7cf1c5aa |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 from mercurial import util as merc_util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 from mercurial import hg |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 from svn import core |
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 import util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import hg_delta_editor |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 import svnwrap |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 import fetch_command |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 import utility_commands |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 @util.register_subcommand('push') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 @util.register_subcommand('dcommit') # for git expats |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url, **opts): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 """Push revisions starting at a specified head back to Subversion. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 """ |
44
85fcac4e2291
Fix an encoding bug that would occur if the local encoding was not utf-8.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
17 oldencoding = 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:
39
diff
changeset
|
18 merc_util._encoding = 'UTF-8' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 hge.revmap.iterkeys())) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 # Strategy: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 # 1. Find all outgoing commits from this head |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 outgoing = utility_commands.outgoing_revisions(ui, repo, hge, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 svn_commit_hashes) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 if not (outgoing and len(outgoing)): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 ui.status('No revisions to push.') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 return 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 if len(repo.parents()) != 1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 ui.status('Cowardly refusing to push branch merge') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 return 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 while outgoing: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 oldest = outgoing.pop(-1) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 old_ctx = repo[oldest] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 if len(old_ctx.parents()) != 1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 ui.status('Found a branch merge, this needs discussion and ' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 'implementation.') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 return 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 base_n = old_ctx.parents()[0].node() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 old_children = repo[base_n].children() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 # 2. Commit oldest revision that needs to be pushed |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 base_revision = svn_commit_hashes[old_ctx.parents()[0].node()][0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 # 3. Fetch revisions from svn |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 assert not r or r == 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 # 4. Find the new head of the target branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 repo = hg.repository(ui, hge.path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 base_c = repo[base_n] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 replacement = [c for c in base_c.children() if c not in old_children |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 and c.branch() == old_ctx.branch()] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 assert len(replacement) == 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 replacement = replacement[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 # 5. Rebase all children of the currently-pushing rev to the new branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 heads = repo.heads(old_ctx.node()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 for needs_transplant in heads: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 hg.clean(repo, needs_transplant) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 utility_commands.rebase_commits(ui, repo, hg_repo_path, **opts) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 repo = hg.repository(ui, hge.path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 if needs_transplant in outgoing: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 hg.clean(repo, repo['tip'].node()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 hge.revmap.iterkeys())) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 outgoing = utility_commands.outgoing_revisions(ui, repo, hge, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 svn_commit_hashes) |
44
85fcac4e2291
Fix an encoding bug that would occur if the local encoding was not utf-8.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
68 merc_util._encoding = oldencoding |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 return 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 |
65
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
72 def _findmissing(dirname, svn, branch_path): |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
73 """Find missing directories in svn. dirname *must* end in a / |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
74 """ |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
75 assert dirname[-1] == '/' |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
76 missing = [] |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
77 keep_checking = True |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
78 # check and see if the dir exists svn-side. |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
79 path = dirname |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
80 while keep_checking: |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
81 try: |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
82 assert svn.list_dir('%s/%s' % (branch_path, path)) |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
83 keep_checking = False |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
84 except core.SubversionException, e: |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
85 # dir must not exist |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
86 missing.append(path[:-1]) |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
87 path = '/'.join(path.split('/')[:-2] + ['']) |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
88 return missing |
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
89 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
90 def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 """Build and send a commit from Mercurial to Subversion. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
92 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 file_data = {} |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
94 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser()) |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
95 parent = rev_ctx.parents()[0] |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
96 parent_branch = rev_ctx.parents()[0].branch() |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
97 branch_path = 'trunk' |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
98 |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
99 if parent_branch and parent_branch != 'default': |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
100 branch_path = 'branches/%s' % parent_branch |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
101 |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
102 added_dirs = [] |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
103 props = {} |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
104 copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 for file in rev_ctx.files(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 new_data = base_data = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 action = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 if file in rev_ctx: |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
109 fctx = rev_ctx.filectx(file) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
110 new_data = fctx.data() |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
111 |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
112 if 'x' in fctx.flags(): |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
113 props.setdefault(file, {})['svn:executable'] = '*' |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
114 if 'l' in fctx.flags(): |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
115 props.setdefault(file, {})['svn:special'] = '*' |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
116 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 if file not in parent: |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
118 renamed = fctx.renamed() |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
119 if renamed: |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
120 # TODO current model (and perhaps svn model) does not support |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
121 # this kind of renames: a -> b, b -> c |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
122 copies[file] = renamed[0] |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
123 base_data = parent[renamed[0]].data() |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
124 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 action = 'add' |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
126 dirname = '/'.join(file.split('/')[:-1] + ['']) |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
127 # check for new directories |
39
b3c7b844b782
Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents:
12
diff
changeset
|
128 if not list(parent.walk(util.PrefixMatch(dirname))): |
65
b33940d54fe2
push: Fix missing directory creation for the case of a new dir inside a new dir.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
129 added_dirs += _findmissing(dirname, svn, branch_path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
130 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
131 base_data = parent.filectx(file).data() |
62
cc5ebdb1e8d4
push_cmd: Further simplified some logic thanks to an improved test.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
132 if ('x' in parent.filectx(file).flags() |
cc5ebdb1e8d4
push_cmd: Further simplified some logic thanks to an improved test.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
133 and 'x' not in rev_ctx.filectx(file).flags()): |
cc5ebdb1e8d4
push_cmd: Further simplified some logic thanks to an improved test.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
134 props.setdefault(file, {})['svn:executable'] = None |
60
41dc00c7aef1
Fixed a problem where if you edited an existing symlink by replacing with another symlink, things would get corrupt.
Augie Fackler <durin42@gmail.com>
parents:
57
diff
changeset
|
135 if ('l' in parent.filectx(file).flags() |
41dc00c7aef1
Fixed a problem where if you edited an existing symlink by replacing with another symlink, things would get corrupt.
Augie Fackler <durin42@gmail.com>
parents:
57
diff
changeset
|
136 and 'l' not in rev_ctx.filectx(file).flags()): |
41dc00c7aef1
Fixed a problem where if you edited an existing symlink by replacing with another symlink, things would get corrupt.
Augie Fackler <durin42@gmail.com>
parents:
57
diff
changeset
|
137 props.setdefault(file, {})['svn:special'] = None |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 action = 'modify' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
139 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 base_data = parent.filectx(file).data() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 action = 'delete' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 file_data[file] = base_data, new_data, action |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 # TODO check for directory deletes here |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
145 def svnpath(p): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
146 return '%s/%s' % (branch_path, p) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
147 |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
148 newcopies = {} |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
149 for source, dest in copies.iteritems(): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
150 newcopies[svnpath(source)] = (svnpath(dest), base_revision) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
151 |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
152 new_target_files = [svnpath(f) for f in rev_ctx.files()] |
56
0be16f306a42
push_cmd: remove redundant variable in commit_from_rev()
Patrick Mezard <pmezard@gmail.com>
parents:
44
diff
changeset
|
153 for tf, ntf in zip(rev_ctx.files(), new_target_files): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 if tf in file_data: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 file_data[ntf] = file_data[tf] |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
156 if tf in props: |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
157 props[ntf] = props[tf] |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
158 del props[tf] |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
159 if merc_util.binary(file_data[ntf][1]): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
160 props.setdefault(ntf, {}).update(props.get(ntf, {})) |
12
c5039390332f
Fix partial implementation.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
161 props.setdefault(ntf, {})['svn:mime-type'] = 'application/octet-stream' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 del file_data[tf] |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
163 added_dirs = ['%s/%s' % (branch_path, f) for f in added_dirs] |
57
c3c5546eefb1
Don't try and add a directory more than once.
Augie Fackler <durin42@gmail.com>
parents:
56
diff
changeset
|
164 added_dirs = set(added_dirs) |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
165 new_target_files += added_dirs |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 svn.commit(new_target_files, rev_ctx.description(), file_data, |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
168 base_revision, set(added_dirs), props, newcopies) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
169 except core.SubversionException, e: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 if hasattr(e, 'apr_err') and e.apr_err == 160028: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 raise merc_util.Abort('Base text was out of date, maybe rebase?') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
173 raise |