Mercurial > hgsubversion
annotate push_cmd.py @ 230:4c3bad24f950
rebase: cleanup slightly.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 30 Mar 2009 16:11:45 -0500 |
parents | 330f0b15d417 |
children | 33e885f5f86a |
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 |
151
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
3 from mercurial import node |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 from svn import core |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 import hg_delta_editor |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
8 import svnexternals |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 import svnwrap |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import fetch_command |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 import utility_commands |
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 |
220
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
14 class BaseException(Exception): |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
15 pass |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
16 |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
17 |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
18 class NoFilesException(BaseException): |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
19 """Exception raised when you try and commit without files. |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
20 """ |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
21 |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
22 |
86
6ecdbd22eb1d
push_cmd: add option to push in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
85
diff
changeset
|
23 def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url, |
6ecdbd22eb1d
push_cmd: add option to push in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
85
diff
changeset
|
24 stupid=False, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
25 """push revisions starting at a specified head back to Subversion. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 """ |
223
330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents:
220
diff
changeset
|
27 old_encoding = util.swap_out_encoding() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 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
|
29 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 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
|
31 hge.revmap.iterkeys())) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 # Strategy: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 # 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
|
34 if len(repo.parents()) != 1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 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
|
36 return 1 |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
37 workingrev = repo.parents()[0] |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
38 outgoing = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, workingrev.node()) |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
39 if not (outgoing and len(outgoing)): |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
40 ui.status('No revisions to push.') |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
41 return 0 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 while outgoing: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 oldest = outgoing.pop(-1) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 old_ctx = repo[oldest] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 if len(old_ctx.parents()) != 1: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 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
|
47 'implementation.') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 return 1 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 base_n = old_ctx.parents()[0].node() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 old_children = repo[base_n].children() |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
51 svnbranch = repo[base_n].branch() |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
52 oldtip = base_n |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
53 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
54 and c.node() in svn_commit_hashes] |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
55 while samebranchchildren: |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
56 oldtip = samebranchchildren[0].node() |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
57 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
58 and c.node() in svn_commit_hashes] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 # 2. Commit oldest revision that needs to be pushed |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
60 base_revision = svn_commit_hashes[base_n][0] |
220
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
61 try: |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
62 commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision) |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
63 except NoFilesException: |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
64 ui.warn("Could not push revision %s because it had no changes in svn.\n" % |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
65 old_ctx) |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
66 return 1 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 # 3. Fetch revisions from svn |
86
6ecdbd22eb1d
push_cmd: add option to push in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
85
diff
changeset
|
68 r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, |
6ecdbd22eb1d
push_cmd: add option to push in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents:
85
diff
changeset
|
69 stupid=stupid) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 assert not r or r == 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 # 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
|
72 repo = hg.repository(ui, hge.path) |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
73 oldtipctx = repo[oldtip] |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
74 replacement = [c for c in oldtipctx.children() if c not in old_children |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
75 and c.branch() == oldtipctx.branch()] |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
76 assert len(replacement) == 1, 'Replacement node came back as: %r' % replacement |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 replacement = replacement[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 # 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
|
79 heads = repo.heads(old_ctx.node()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 for needs_transplant in heads: |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
81 def extrafn(ctx, extra): |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
82 if ctx.node() == oldest: |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
83 return |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
84 extra['branch'] = ctx.branch() |
230
4c3bad24f950
rebase: cleanup slightly.
Augie Fackler <durin42@gmail.com>
parents:
223
diff
changeset
|
85 utility_commands.rebase_commits(ui, repo, |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
86 extrafn=extrafn, |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
87 sourcerev=needs_transplant, |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
88 **opts) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 repo = hg.repository(ui, hge.path) |
151
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
90 for child in repo[replacement.node()].children(): |
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
91 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid))) |
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
92 if rebasesrc in outgoing: |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
93 while rebasesrc in outgoing: |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
94 rebsrcindex = outgoing.index(rebasesrc) |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
95 outgoing = (outgoing[0:rebsrcindex] + |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
96 [child.node(), ] + outgoing[rebsrcindex+1:]) |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
97 children = [c for c in child.children() if c.branch() == child.branch()] |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
98 if children: |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
99 child = children[0] |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
151
diff
changeset
|
100 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid))) |
151
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
101 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) |
2decec74ad0c
push: Use a better method for finding the outgoing revisions.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
102 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) |
223
330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents:
220
diff
changeset
|
103 util.swap_out_encoding(old_encoding) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 return 0 |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
175
diff
changeset
|
105 push_revisions_to_subversion = util.register_subcommand('push')(push_revisions_to_subversion) |
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
175
diff
changeset
|
106 # for git expats |
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
175
diff
changeset
|
107 push_revisions_to_subversion = util.register_subcommand('dcommit')(push_revisions_to_subversion) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 |
173
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
109 def _isdir(svn, branchpath, svndir): |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
110 try: |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
111 svn.list_dir('%s/%s' % (branchpath, svndir)) |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
112 return True |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
113 except core.SubversionException: |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
114 return False |
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
115 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
116 def _getdirchanges(svn, branchpath, parentctx, ctx, changedfiles, extchanges): |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
117 """Compute directories to add or delete when moving from parentctx |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
118 to ctx, assuming only 'changedfiles' files changed, and 'extchanges' |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
119 external references changed (as returned by svnexternals.diff()). |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
121 Return (added, deleted) where 'added' is the list of all added |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
122 directories and 'deleted' the list of deleted directories. |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
123 Intermediate directories are included: if a/b/c is new and requires |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
124 the addition of a/b and a, those will be listed too. Intermediate |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
125 deleted directories are also listed, but item order of undefined |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
126 in either list. |
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
|
127 """ |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
128 def finddirs(path, includeself=False): |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
129 if includeself: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
130 yield path |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
131 pos = path.rfind('/') |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
132 while pos != -1: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
133 yield path[:pos] |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
134 pos = path.rfind('/', 0, pos) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
135 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
136 def getctxdirs(ctx, keptdirs, extdirs): |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
137 dirs = {} |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
138 for f in ctx.manifest(): |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
139 for d in finddirs(f): |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
140 if d in dirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
141 break |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
142 if d in keptdirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
143 dirs[d] = 1 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
144 for extdir in extdirs: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
145 for d in finddirs(extdir, True): |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
146 dirs[d] = 1 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
147 return dirs |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
148 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
149 deleted, added = [], [] |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
150 changeddirs = {} |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
151 for f in changedfiles: |
85
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
152 if f in parentctx and f in ctx: |
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
153 # Updated files cannot cause directories to be created |
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
154 # or removed. |
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
155 continue |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
156 for d in finddirs(f): |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
157 changeddirs[d] = 1 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
158 for e in extchanges: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
159 if not e[1] or not e[2]: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
160 for d in finddirs(e[0], True): |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
161 changeddirs[d] = 1 |
85
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
162 if not changeddirs: |
05a0c4f6060f
push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
163 return added, deleted |
206
c2e51d6a2d7b
push: Converted a magic number to an actual constant, and catch another apr_err that appears to also mean base text out of date.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
164 olddirs = getctxdirs(parentctx, changeddirs, |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
165 [e[0] for e in extchanges if e[1]]) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
166 newdirs = getctxdirs(ctx, changeddirs, |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
167 [e[0] for e in extchanges if e[2]]) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
168 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
169 for d in newdirs: |
173
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
170 if d not in olddirs and not _isdir(svn, branchpath, d): |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
171 added.append(d) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
172 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
173 for d in olddirs: |
173
f244eaee5069
push_cmd: make _isdir() a standalone function
Patrick Mezard <pmezard@gmail.com>
parents:
171
diff
changeset
|
174 if d not in newdirs and _isdir(svn, branchpath, d): |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
175 deleted.append(d) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
176 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
177 return added, deleted |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
178 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
179 def _externals(ctx): |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
180 ext = svnexternals.externalsfile() |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
181 if '.hgsvnexternals' in ctx: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
182 ext.read(ctx['.hgsvnexternals'].data()) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
183 return ext |
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
|
184 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 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
|
186 """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
|
187 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 file_data = {} |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
189 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
|
190 parent = rev_ctx.parents()[0] |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
191 parent_branch = rev_ctx.parents()[0].branch() |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
192 branch_path = 'trunk' |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
193 |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
194 if parent_branch and parent_branch != 'default': |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
195 branch_path = 'branches/%s' % parent_branch |
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
196 |
206
c2e51d6a2d7b
push: Converted a magic number to an actual constant, and catch another apr_err that appears to also mean base text out of date.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
197 extchanges = list(svnexternals.diff(_externals(parent), |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
198 _externals(rev_ctx))) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
199 addeddirs, deleteddirs = _getdirchanges(svn, branch_path, parent, rev_ctx, |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
200 rev_ctx.files(), extchanges) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
201 deleteddirs = set(deleteddirs) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
202 |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
203 props = {} |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
204 copies = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
205 for file in rev_ctx.files(): |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
206 if file == '.hgsvnexternals': |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
207 continue |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
208 new_data = base_data = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
209 action = '' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
210 if file in rev_ctx: |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
211 fctx = rev_ctx.filectx(file) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
212 new_data = fctx.data() |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
213 |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
214 if 'x' in fctx.flags(): |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
215 props.setdefault(file, {})['svn:executable'] = '*' |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
216 if 'l' in fctx.flags(): |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
217 props.setdefault(file, {})['svn:special'] = '*' |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
218 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 if file not in parent: |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
220 renamed = fctx.renamed() |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
221 if renamed: |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
222 # 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
|
223 # 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
|
224 copies[file] = renamed[0] |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
225 base_data = parent[renamed[0]].data() |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
226 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
227 action = 'add' |
9
9eb6bf2be1e7
Fix adding files that require new directories.
Augie Fackler <durin42@gmail.com>
parents:
6
diff
changeset
|
228 dirname = '/'.join(file.split('/')[:-1] + ['']) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 props.setdefault(file, {})['svn:special'] = None |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 action = 'modify' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
238 else: |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
239 pos = file.rfind('/') |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
240 if pos >= 0: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
241 if file[:pos] in deleteddirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
242 # This file will be removed when its directory is removed |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
243 continue |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 action = 'delete' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 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
|
246 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
247 def svnpath(p): |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
248 return '%s/%s' % (branch_path, p) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
249 |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
250 changeddirs = [] |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
251 for d, v1, v2 in extchanges: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
252 props.setdefault(svnpath(d), {})['svn:externals'] = v2 |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
253 if d not in deleteddirs and d not in addeddirs: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
254 changeddirs.append(svnpath(d)) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
255 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
256 # Now we are done with files, we can prune deleted directories |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
257 # against themselves: ignore a/b if a/ is already removed |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
258 deleteddirs2 = list(deleteddirs) |
163 | 259 deleteddirs2.sort(reverse=True) |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
260 for d in deleteddirs2: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
261 pos = d.rfind('/') |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
262 if pos >= 0 and d[:pos] in deleteddirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
263 deleteddirs.remove(d[:pos]) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
264 |
70
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
265 newcopies = {} |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
266 for source, dest in copies.iteritems(): |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
267 newcopies[svnpath(source)] = (svnpath(dest), base_revision) |
49b7cbe4c8e3
push_cmd: handle copies at file level
Patrick Mezard <pmezard@gmail.com>
parents:
65
diff
changeset
|
268 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
269 new_target_files = [svnpath(f) for f in file_data] |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
270 for tf, ntf in zip(file_data, new_target_files): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
271 if tf in file_data: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 file_data[ntf] = file_data[tf] |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
273 if tf in props: |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
274 props[ntf] = props[tf] |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
275 del props[tf] |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
276 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
|
277 props.setdefault(ntf, {}).update(props.get(ntf, {})) |
12
c5039390332f
Fix partial implementation.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
278 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
|
279 del file_data[tf] |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
280 |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
281 addeddirs = [svnpath(d) for d in addeddirs] |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
282 deleteddirs = [svnpath(d) for d in deleteddirs] |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
173
diff
changeset
|
283 new_target_files += addeddirs + deleteddirs + changeddirs |
220
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
284 if not new_target_files: |
06eb60f9a026
push: Do not attempt to push empty revisions.
Augie Fackler <durin42@gmail.com>
parents:
206
diff
changeset
|
285 raise NoFilesException() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
286 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
287 svn.commit(new_target_files, rev_ctx.description(), file_data, |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
99
diff
changeset
|
288 base_revision, set(addeddirs), set(deleteddirs), |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
289 props, newcopies) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
290 except core.SubversionException, e: |
206
c2e51d6a2d7b
push: Converted a magic number to an actual constant, and catch another apr_err that appears to also mean base text out of date.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
291 if hasattr(e, 'apr_err') and (e.apr_err == core.SVN_ERR_FS_TXN_OUT_OF_DATE |
c2e51d6a2d7b
push: Converted a magic number to an actual constant, and catch another apr_err that appears to also mean base text out of date.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
292 or e.apr_err == core.SVN_ERR_FS_CONFLICT): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
293 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
|
294 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 raise |