Mercurial > hgsubversion
view diff_cmd.py @ 131:4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Project items copyfrom revisions are irrelevant to parent revision detection,
only the project one or those of its ancestors matter. Items copyfrom is
useful when retrieving items content.
Former code resulted in incorrect converted graph for pyglet repository,
especially on the following revision:
------------------------------------------------------------------------
r274 | r1chardj0n3s | 2006-12-21 02:02:14 +0100 (Jeu, 21 Dec 2006) | 2 lines
Changed paths:
A /branches/richard-glx-version (from /trunk:269)
M /branches/richard-glx-version/pyglet/window/xlib/__init__.py
R /branches/richard-glx-version/tests/test.py (from /trunk/tests/test.py:270)
R /branches/richard-glx-version/tools/info.py (from /trunk/tools/info.py:272)
R /branches/richard-glx-version/website/get_involved.php (from /trunk/website/get_involved.php:273)
Branching to horribly mangle GLX
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 10 Dec 2008 11:03:22 -0600 |
parents | 91ce18fa0375 |
children | 40474f6c1f84 |
line wrap: on
line source
#!/usr/bin/env python import re from mercurial import patch import util import hg_delta_editor b_re = re.compile(r'^\+\+\+ b\/([^\n]*)', re.MULTILINE) a_re = re.compile(r'^--- a\/([^\n]*)', re.MULTILINE) devnull_re = re.compile(r'^([-+]{3}) /dev/null', re.MULTILINE) header_re = re.compile(r'^diff --git .* b\/(.*)', re.MULTILINE) newfile_devnull_re = re.compile(r'^--- /dev/null\n\+\+\+ b/([^\n]*)', re.MULTILINE) def filterdiff(diff, base_revision): diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n' r'+++ \1\t(working copy)', diff) diff = a_re.sub(r'--- \1'+ ('\t(revision %d)' % base_revision), diff) diff = b_re.sub(r'+++ \1' + '\t(working copy)', diff) diff = devnull_re.sub(r'\1 /dev/null' '\t(working copy)', diff) diff = header_re.sub(r'Index: \1' + '\n' + ('=' * 67), diff) return diff @util.register_subcommand('diff') def diff_command(ui, repo, hg_repo_path, **opts): """Show a diff of the most recent revision against its parent from svn. """ hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes) parent = repo.parents()[0] if o_r: parent = repo[o_r[-1]].parents()[0] base_rev, _junk = svn_commit_hashes[parent.node()] it = patch.diff(repo, parent.node(), None, opts=patch.diffopts(ui, opts)) ui.write(filterdiff(''.join(it), base_rev))