Mercurial > hgsubversion
comparison cmdutil.py @ 256:7932d098cb5f
Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 10 Apr 2009 18:47:18 -0500 |
parents | 9ba31af57e4b |
children | ffccf0080e54 |
comparison
equal
deleted
inserted
replaced
255:246aaefb1cc0 | 256:7932d098cb5f |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 import re | 2 import re |
3 import os | |
3 | 4 |
4 from mercurial import util as hgutil | 5 from mercurial import util as hgutil |
5 | 6 |
6 from svn import core | 7 from svn import core |
7 | 8 |
20 | 21 |
21 class NoFilesException(Exception): | 22 class NoFilesException(Exception): |
22 """Exception raised when you try and commit without files. | 23 """Exception raised when you try and commit without files. |
23 """ | 24 """ |
24 | 25 |
25 | 26 def formatrev(rev): |
26 def filterdiff(diff, base_revision): | 27 if rev == -1: |
28 return '\t(working copy)' | |
29 return '\t(revision %d)' % rev | |
30 | |
31 | |
32 def filterdiff(diff, oldrev, newrev): | |
27 diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n' | 33 diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n' |
28 r'+++ \1\t(working copy)', | 34 r'+++ \1\t(working copy)', |
29 diff) | 35 diff) |
30 diff = a_re.sub(r'--- \1'+ ('\t(revision %d)' % base_revision), diff) | 36 oldrev = formatrev(oldrev) |
31 diff = b_re.sub(r'+++ \1' + '\t(working copy)', diff) | 37 newrev = formatrev(newrev) |
32 diff = devnull_re.sub(r'\1 /dev/null' '\t(working copy)', diff) | 38 diff = a_re.sub(r'--- \1'+ oldrev, diff) |
33 | 39 diff = b_re.sub(r'+++ \1' + newrev, diff) |
40 diff = devnull_re.sub(r'\1 /dev/null\t(working copy)', diff) | |
34 diff = header_re.sub(r'Index: \1' + '\n' + ('=' * 67), diff) | 41 diff = header_re.sub(r'Index: \1' + '\n' + ('=' * 67), diff) |
35 return diff | 42 return diff |
36 | 43 |
37 | 44 |
38 def parentrev(ui, repo, hge, svn_commit_hashes): | 45 def parentrev(ui, repo, hge, svn_commit_hashes): |
268 if hasattr(e, 'apr_err') and (e.apr_err == core.SVN_ERR_FS_TXN_OUT_OF_DATE | 275 if hasattr(e, 'apr_err') and (e.apr_err == core.SVN_ERR_FS_TXN_OUT_OF_DATE |
269 or e.apr_err == core.SVN_ERR_FS_CONFLICT): | 276 or e.apr_err == core.SVN_ERR_FS_CONFLICT): |
270 raise hgutil.Abort('Base text was out of date, maybe rebase?') | 277 raise hgutil.Abort('Base text was out of date, maybe rebase?') |
271 else: | 278 else: |
272 raise | 279 raise |
280 | |
281 def filecheck(path): | |
282 for x in ('locks', 'hooks', 'format', 'db', ): | |
283 if not os.path.exists(os.path.join(path, x)): | |
284 return False | |
285 return True | |
286 | |
287 | |
288 def issvnurl(url): | |
289 return url.startswith('svn+') or ( | |
290 url.startswith('file://') and | |
291 reduce(lambda x,y: x and y, | |
292 map(lambda p: os.path.exists(os.path.join(url[7:], p)), | |
293 ('locks', 'hooks', 'format', 'db', )))) |