Mercurial > hgsubversion
comparison push_cmd.py @ 220:06eb60f9a026
push: Do not attempt to push empty revisions.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 28 Mar 2009 17:50:00 -0500 |
parents | c2e51d6a2d7b |
children | 330f0b15d417 |
comparison
equal
deleted
inserted
replaced
219:794f473b9b49 | 220:06eb60f9a026 |
---|---|
7 import hg_delta_editor | 7 import hg_delta_editor |
8 import svnexternals | 8 import svnexternals |
9 import svnwrap | 9 import svnwrap |
10 import fetch_command | 10 import fetch_command |
11 import utility_commands | 11 import utility_commands |
12 | |
13 | |
14 class BaseException(Exception): | |
15 pass | |
16 | |
17 | |
18 class NoFilesException(BaseException): | |
19 """Exception raised when you try and commit without files. | |
20 """ | |
12 | 21 |
13 | 22 |
14 def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url, | 23 def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url, |
15 stupid=False, **opts): | 24 stupid=False, **opts): |
16 """push revisions starting at a specified head back to Subversion. | 25 """push revisions starting at a specified head back to Subversion. |
48 oldtip = samebranchchildren[0].node() | 57 oldtip = samebranchchildren[0].node() |
49 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch | 58 samebranchchildren = [c for c in repo[oldtip].children() if c.branch() == svnbranch |
50 and c.node() in svn_commit_hashes] | 59 and c.node() in svn_commit_hashes] |
51 # 2. Commit oldest revision that needs to be pushed | 60 # 2. Commit oldest revision that needs to be pushed |
52 base_revision = svn_commit_hashes[base_n][0] | 61 base_revision = svn_commit_hashes[base_n][0] |
53 commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision) | 62 try: |
63 commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision) | |
64 except NoFilesException: | |
65 ui.warn("Could not push revision %s because it had no changes in svn.\n" % | |
66 old_ctx) | |
67 return 1 | |
54 # 3. Fetch revisions from svn | 68 # 3. Fetch revisions from svn |
55 r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, | 69 r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, |
56 stupid=stupid) | 70 stupid=stupid) |
57 assert not r or r == 0 | 71 assert not r or r == 0 |
58 # 4. Find the new head of the target branch | 72 # 4. Find the new head of the target branch |
266 del file_data[tf] | 280 del file_data[tf] |
267 | 281 |
268 addeddirs = [svnpath(d) for d in addeddirs] | 282 addeddirs = [svnpath(d) for d in addeddirs] |
269 deleteddirs = [svnpath(d) for d in deleteddirs] | 283 deleteddirs = [svnpath(d) for d in deleteddirs] |
270 new_target_files += addeddirs + deleteddirs + changeddirs | 284 new_target_files += addeddirs + deleteddirs + changeddirs |
285 if not new_target_files: | |
286 raise NoFilesException() | |
271 try: | 287 try: |
272 svn.commit(new_target_files, rev_ctx.description(), file_data, | 288 svn.commit(new_target_files, rev_ctx.description(), file_data, |
273 base_revision, set(addeddirs), set(deleteddirs), | 289 base_revision, set(addeddirs), set(deleteddirs), |
274 props, newcopies) | 290 props, newcopies) |
275 except core.SubversionException, e: | 291 except core.SubversionException, e: |