Mercurial > hgsubversion
comparison cmdutil.py @ 244:28d0ee605308
Move diff to svncommands.
| author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
|---|---|
| date | Wed, 08 Apr 2009 18:21:47 +0200 |
| parents | 2027f851d60c |
| children | 9ba31af57e4b |
comparison
equal
deleted
inserted
replaced
| 243:2027f851d60c | 244:28d0ee605308 |
|---|---|
| 1 #!/usr/bin/python | |
| 2 import re | |
| 1 | 3 |
| 2 from mercurial import util as hgutil | 4 from mercurial import util as hgutil |
| 3 | 5 |
| 4 from svn import core | 6 from svn import core |
| 5 | 7 |
| 6 import svnwrap | 8 import svnwrap |
| 7 import svnexternals | 9 import svnexternals |
| 10 | |
| 11 | |
| 12 b_re = re.compile(r'^\+\+\+ b\/([^\n]*)', re.MULTILINE) | |
| 13 a_re = re.compile(r'^--- a\/([^\n]*)', re.MULTILINE) | |
| 14 devnull_re = re.compile(r'^([-+]{3}) /dev/null', re.MULTILINE) | |
| 15 header_re = re.compile(r'^diff --git .* b\/(.*)', re.MULTILINE) | |
| 16 newfile_devnull_re = re.compile(r'^--- /dev/null\n\+\+\+ b/([^\n]*)', | |
| 17 re.MULTILINE) | |
| 8 | 18 |
| 9 | 19 |
| 10 class NoFilesException(Exception): | 20 class NoFilesException(Exception): |
| 11 """Exception raised when you try and commit without files. | 21 """Exception raised when you try and commit without files. |
| 12 """ | 22 """ |
| 23 | |
| 24 | |
| 25 def filterdiff(diff, base_revision): | |
| 26 diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n' | |
| 27 r'+++ \1\t(working copy)', | |
| 28 diff) | |
| 29 diff = a_re.sub(r'--- \1'+ ('\t(revision %d)' % base_revision), diff) | |
| 30 diff = b_re.sub(r'+++ \1' + '\t(working copy)', diff) | |
| 31 diff = devnull_re.sub(r'\1 /dev/null' '\t(working copy)', diff) | |
| 32 | |
| 33 diff = header_re.sub(r'Index: \1' + '\n' + ('=' * 67), diff) | |
| 34 return diff | |
| 13 | 35 |
| 14 | 36 |
| 15 def replay_convert_rev(hg_editor, svn, r): | 37 def replay_convert_rev(hg_editor, svn, r): |
| 16 hg_editor.set_current_rev(r) | 38 hg_editor.set_current_rev(r) |
| 17 svn.get_replay(r.revnum, hg_editor) | 39 svn.get_replay(r.revnum, hg_editor) |
