Mercurial > hg
changeset 25813:18bae5eb58c5
extdiff: add support for subrepos
Git and svn subrepo support is incomplete, because they don't support archiving
the working copy.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 15 Jul 2012 12:43:10 -0400 |
parents | 68822b7cdd01 |
children | dc1a49264628 |
files | hgext/extdiff.py tests/test-extdiff.t tests/test-extension.t tests/test-subrepo-deep-nested-change.t |
diffstat | 4 files changed, 110 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/extdiff.py Wed Jul 11 20:48:51 2012 -0400 +++ b/hgext/extdiff.py Sun Jul 15 12:43:10 2012 -0400 @@ -74,7 +74,7 @@ # leave the attribute unspecified. testedwith = 'internal' -def snapshot(ui, repo, files, node, tmproot): +def snapshot(ui, repo, files, node, tmproot, listsubrepos): '''snapshot files as of some revision if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files.''' @@ -98,7 +98,8 @@ repo.ui.setconfig("ui", "archivemeta", False) archival.archive(repo, base, node, 'files', - matchfn=scmutil.matchfiles(repo, files)) + matchfn=scmutil.matchfiles(repo, files), + subrepos=listsubrepos) ctx = repo[node] for fn in sorted(files): @@ -146,10 +147,14 @@ if node1b == nullid: do3way = False + subrepos=opts.get('subrepos') + matcher = scmutil.match(repo[node2], pats, opts) - mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3]) + mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher, + listsubrepos=subrepos)[:3]) if do3way: - mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher)[:3]) + mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher, + listsubrepos=subrepos)[:3]) else: mod_b, add_b, rem_b = set(), set(), set() modadd = mod_a | add_a | mod_b | add_b @@ -161,11 +166,12 @@ try: # Always make a copy of node1a (and node1b, if applicable) dir1a_files = mod_a | rem_a | ((mod_b | add_b) - add_a) - dir1a = snapshot(ui, repo, dir1a_files, node1a, tmproot)[0] + dir1a = snapshot(ui, repo, dir1a_files, node1a, tmproot, subrepos)[0] rev1a = '@%d' % repo[node1a].rev() if do3way: dir1b_files = mod_b | rem_b | ((mod_a | add_a) - add_b) - dir1b = snapshot(ui, repo, dir1b_files, node1b, tmproot)[0] + dir1b = snapshot(ui, repo, dir1b_files, node1b, tmproot, + subrepos)[0] rev1b = '@%d' % repo[node1b].rev() else: dir1b = None @@ -177,14 +183,15 @@ dir2root = '' rev2 = '' if node2: - dir2 = snapshot(ui, repo, modadd, node2, tmproot)[0] + dir2 = snapshot(ui, repo, modadd, node2, tmproot, subrepos)[0] rev2 = '@%d' % repo[node2].rev() elif len(common) > 1: #we only actually need to get the files to copy back to #the working dir in this case (because the other cases #are: diffing 2 revisions or single file -- in which case #the file is already directly passed to the diff tool). - dir2, fns_and_mtime = snapshot(ui, repo, modadd, None, tmproot) + dir2, fns_and_mtime = snapshot(ui, repo, modadd, None, tmproot, + subrepos) else: # This lets the diff tool open the changed file directly dir2 = '' @@ -252,7 +259,7 @@ _('pass option to comparison program'), _('OPT')), ('r', 'rev', [], _('revision'), _('REV')), ('c', 'change', '', _('change made by revision'), _('REV')), - ] + commands.walkopts, + ] + commands.walkopts + commands.subrepoopts, _('hg extdiff [OPT]... [FILE]...'), inferrepo=True) def extdiff(ui, repo, *pats, **opts):
--- a/tests/test-extdiff.t Wed Jul 11 20:48:51 2012 -0400 +++ b/tests/test-extdiff.t Sun Jul 15 12:43:10 2012 -0400 @@ -48,6 +48,7 @@ -c --change REV change made by revision -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns + -S --subrepos recurse into subrepositories (some details hidden, use --verbose to show complete help)
--- a/tests/test-extension.t Wed Jul 11 20:48:51 2012 -0400 +++ b/tests/test-extension.t Sun Jul 15 12:43:10 2012 -0400 @@ -394,6 +394,7 @@ -c --change REV change made by revision -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns + -S --subrepos recurse into subrepositories (some details hidden, use --verbose to show complete help)
--- a/tests/test-subrepo-deep-nested-change.t Wed Jul 11 20:48:51 2012 -0400 +++ b/tests/test-subrepo-deep-nested-change.t Sun Jul 15 12:43:10 2012 -0400 @@ -709,4 +709,96 @@ $ hg rollback -q $ hg update -Cq . +Interaction with extdiff, largefiles and subrepos + + $ hg --config extensions.extdiff= extdiff -S + + $ hg --config extensions.extdiff= extdiff -r '.^' -S + diff -Npru cloned.*/.hgsub cloned/.hgsub (glob) + --- cloned.*/.hgsub * +0000 (glob) + +++ cloned/.hgsub * +0000 (glob) + @@ -1,2 +1 @@ + sub1 = ../sub1 + -sub3 = sub3 + diff -Npru cloned.*/.hgsubstate cloned/.hgsubstate (glob) + --- cloned.*/.hgsubstate * +0000 (glob) + +++ cloned/.hgsubstate * +0000 (glob) + @@ -1,2 +1 @@ + 7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1 + -b1a26de6f2a045a9f079323693614ee322f1ff7e sub3 + [1] + + $ hg --config extensions.extdiff= extdiff -r 0 -r '.^' -S + diff -Npru cloned.*/.hglf/b.dat cloned.*/.hglf/b.dat (glob) + --- cloned.*/.hglf/b.dat * (glob) + +++ cloned.*/.hglf/b.dat * (glob) + @@ -0,0 +1 @@ + +da39a3ee5e6b4b0d3255bfef95601890afd80709 + diff -Npru cloned.*/.hglf/foo/bar/large.dat cloned.*/.hglf/foo/bar/large.dat (glob) + --- cloned.*/.hglf/foo/bar/large.dat * (glob) + +++ cloned.*/.hglf/foo/bar/large.dat * (glob) + @@ -0,0 +1 @@ + +2f6933b5ee0f5fdd823d9717d8729f3c2523811b + diff -Npru cloned.*/.hglf/large.bin cloned.*/.hglf/large.bin (glob) + --- cloned.*/.hglf/large.bin * (glob) + +++ cloned.*/.hglf/large.bin * (glob) + @@ -0,0 +1 @@ + +7f7097b041ccf68cc5561e9600da4655d21c6d18 + diff -Npru cloned.*/.hgsub cloned.*/.hgsub (glob) + --- cloned.*/.hgsub * (glob) + +++ cloned.*/.hgsub * (glob) + @@ -1 +1,2 @@ + sub1 = ../sub1 + +sub3 = sub3 + diff -Npru cloned.*/.hgsubstate cloned.*/.hgsubstate (glob) + --- cloned.*/.hgsubstate * (glob) + +++ cloned.*/.hgsubstate * (glob) + @@ -1 +1,2 @@ + -fc3b4ce2696f7741438c79207583768f2ce6b0dd sub1 + +7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1 + +b1a26de6f2a045a9f079323693614ee322f1ff7e sub3 + diff -Npru cloned.*/foo/bar/def cloned.*/foo/bar/def (glob) + --- cloned.*/foo/bar/def * (glob) + +++ cloned.*/foo/bar/def * (glob) + @@ -0,0 +1 @@ + +changed + diff -Npru cloned.*/main cloned.*/main (glob) + --- cloned.*/main * (glob) + +++ cloned.*/main * (glob) + @@ -1 +1 @@ + -main + +foo + diff -Npru cloned.*/sub1/.hgsubstate cloned.*/sub1/.hgsubstate (glob) + --- cloned.*/sub1/.hgsubstate * (glob) + +++ cloned.*/sub1/.hgsubstate * (glob) + @@ -1 +1 @@ + -c57a0840e3badd667ef3c3ef65471609acb2ba3c sub2 + +c77908c81ccea3794a896c79e98b0e004aee2e9e sub2 + diff -Npru cloned.*/sub1/sub2/folder/test.txt cloned.*/sub1/sub2/folder/test.txt (glob) + --- cloned.*/sub1/sub2/folder/test.txt * (glob) + +++ cloned.*/sub1/sub2/folder/test.txt * (glob) + @@ -0,0 +1 @@ + +subfolder + diff -Npru cloned.*/sub1/sub2/sub2 cloned.*/sub1/sub2/sub2 (glob) + --- cloned.*/sub1/sub2/sub2 * (glob) + +++ cloned.*/sub1/sub2/sub2 * (glob) + @@ -1 +1 @@ + -sub2 + +modified + diff -Npru cloned.*/sub3/a.txt cloned.*/sub3/a.txt (glob) + --- cloned.*/sub3/a.txt * (glob) + +++ cloned.*/sub3/a.txt * (glob) + @@ -0,0 +1 @@ + +xyz + [1] + + $ echo mod > sub1/sub2/sub2 + $ hg --config extensions.extdiff= extdiff -S + --- */cloned.*/sub1/sub2/sub2 * (glob) + +++ */cloned/sub1/sub2/sub2 * (glob) + @@ -1 +1 @@ + -modified + +mod + [1] + $ cd ..