##// END OF EJS Templates
extdiff: add support for subrepos...
Matt Harbison -
r25813:18bae5eb default
parent child Browse files
Show More
@@ -74,7 +74,7 b' command = cmdutil.command(cmdtable)'
74 # leave the attribute unspecified.
74 # leave the attribute unspecified.
75 testedwith = 'internal'
75 testedwith = 'internal'
76
76
77 def snapshot(ui, repo, files, node, tmproot):
77 def snapshot(ui, repo, files, node, tmproot, listsubrepos):
78 '''snapshot files as of some revision
78 '''snapshot files as of some revision
79 if not using snapshot, -I/-X does not work and recursive diff
79 if not using snapshot, -I/-X does not work and recursive diff
80 in tools like kdiff3 and meld displays too many files.'''
80 in tools like kdiff3 and meld displays too many files.'''
@@ -98,7 +98,8 b' def snapshot(ui, repo, files, node, tmpr'
98 repo.ui.setconfig("ui", "archivemeta", False)
98 repo.ui.setconfig("ui", "archivemeta", False)
99
99
100 archival.archive(repo, base, node, 'files',
100 archival.archive(repo, base, node, 'files',
101 matchfn=scmutil.matchfiles(repo, files))
101 matchfn=scmutil.matchfiles(repo, files),
102 subrepos=listsubrepos)
102
103
103 ctx = repo[node]
104 ctx = repo[node]
104 for fn in sorted(files):
105 for fn in sorted(files):
@@ -146,10 +147,14 b' def dodiff(ui, repo, cmdline, pats, opts'
146 if node1b == nullid:
147 if node1b == nullid:
147 do3way = False
148 do3way = False
148
149
150 subrepos=opts.get('subrepos')
151
149 matcher = scmutil.match(repo[node2], pats, opts)
152 matcher = scmutil.match(repo[node2], pats, opts)
150 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3])
153 mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher,
154 listsubrepos=subrepos)[:3])
151 if do3way:
155 if do3way:
152 mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher)[:3])
156 mod_b, add_b, rem_b = map(set, repo.status(node1b, node2, matcher,
157 listsubrepos=subrepos)[:3])
153 else:
158 else:
154 mod_b, add_b, rem_b = set(), set(), set()
159 mod_b, add_b, rem_b = set(), set(), set()
155 modadd = mod_a | add_a | mod_b | add_b
160 modadd = mod_a | add_a | mod_b | add_b
@@ -161,11 +166,12 b' def dodiff(ui, repo, cmdline, pats, opts'
161 try:
166 try:
162 # Always make a copy of node1a (and node1b, if applicable)
167 # Always make a copy of node1a (and node1b, if applicable)
163 dir1a_files = mod_a | rem_a | ((mod_b | add_b) - add_a)
168 dir1a_files = mod_a | rem_a | ((mod_b | add_b) - add_a)
164 dir1a = snapshot(ui, repo, dir1a_files, node1a, tmproot)[0]
169 dir1a = snapshot(ui, repo, dir1a_files, node1a, tmproot, subrepos)[0]
165 rev1a = '@%d' % repo[node1a].rev()
170 rev1a = '@%d' % repo[node1a].rev()
166 if do3way:
171 if do3way:
167 dir1b_files = mod_b | rem_b | ((mod_a | add_a) - add_b)
172 dir1b_files = mod_b | rem_b | ((mod_a | add_a) - add_b)
168 dir1b = snapshot(ui, repo, dir1b_files, node1b, tmproot)[0]
173 dir1b = snapshot(ui, repo, dir1b_files, node1b, tmproot,
174 subrepos)[0]
169 rev1b = '@%d' % repo[node1b].rev()
175 rev1b = '@%d' % repo[node1b].rev()
170 else:
176 else:
171 dir1b = None
177 dir1b = None
@@ -177,14 +183,15 b' def dodiff(ui, repo, cmdline, pats, opts'
177 dir2root = ''
183 dir2root = ''
178 rev2 = ''
184 rev2 = ''
179 if node2:
185 if node2:
180 dir2 = snapshot(ui, repo, modadd, node2, tmproot)[0]
186 dir2 = snapshot(ui, repo, modadd, node2, tmproot, subrepos)[0]
181 rev2 = '@%d' % repo[node2].rev()
187 rev2 = '@%d' % repo[node2].rev()
182 elif len(common) > 1:
188 elif len(common) > 1:
183 #we only actually need to get the files to copy back to
189 #we only actually need to get the files to copy back to
184 #the working dir in this case (because the other cases
190 #the working dir in this case (because the other cases
185 #are: diffing 2 revisions or single file -- in which case
191 #are: diffing 2 revisions or single file -- in which case
186 #the file is already directly passed to the diff tool).
192 #the file is already directly passed to the diff tool).
187 dir2, fns_and_mtime = snapshot(ui, repo, modadd, None, tmproot)
193 dir2, fns_and_mtime = snapshot(ui, repo, modadd, None, tmproot,
194 subrepos)
188 else:
195 else:
189 # This lets the diff tool open the changed file directly
196 # This lets the diff tool open the changed file directly
190 dir2 = ''
197 dir2 = ''
@@ -252,7 +259,7 b' def dodiff(ui, repo, cmdline, pats, opts'
252 _('pass option to comparison program'), _('OPT')),
259 _('pass option to comparison program'), _('OPT')),
253 ('r', 'rev', [], _('revision'), _('REV')),
260 ('r', 'rev', [], _('revision'), _('REV')),
254 ('c', 'change', '', _('change made by revision'), _('REV')),
261 ('c', 'change', '', _('change made by revision'), _('REV')),
255 ] + commands.walkopts,
262 ] + commands.walkopts + commands.subrepoopts,
256 _('hg extdiff [OPT]... [FILE]...'),
263 _('hg extdiff [OPT]... [FILE]...'),
257 inferrepo=True)
264 inferrepo=True)
258 def extdiff(ui, repo, *pats, **opts):
265 def extdiff(ui, repo, *pats, **opts):
@@ -48,6 +48,7 b' Should diff cloned directories:'
48 -c --change REV change made by revision
48 -c --change REV change made by revision
49 -I --include PATTERN [+] include names matching the given patterns
49 -I --include PATTERN [+] include names matching the given patterns
50 -X --exclude PATTERN [+] exclude names matching the given patterns
50 -X --exclude PATTERN [+] exclude names matching the given patterns
51 -S --subrepos recurse into subrepositories
51
52
52 (some details hidden, use --verbose to show complete help)
53 (some details hidden, use --verbose to show complete help)
53
54
@@ -394,6 +394,7 b' Extension module help vs command help:'
394 -c --change REV change made by revision
394 -c --change REV change made by revision
395 -I --include PATTERN [+] include names matching the given patterns
395 -I --include PATTERN [+] include names matching the given patterns
396 -X --exclude PATTERN [+] exclude names matching the given patterns
396 -X --exclude PATTERN [+] exclude names matching the given patterns
397 -S --subrepos recurse into subrepositories
397
398
398 (some details hidden, use --verbose to show complete help)
399 (some details hidden, use --verbose to show complete help)
399
400
@@ -709,4 +709,96 b' Restore the trashed subrepo tracking'
709 $ hg rollback -q
709 $ hg rollback -q
710 $ hg update -Cq .
710 $ hg update -Cq .
711
711
712 Interaction with extdiff, largefiles and subrepos
713
714 $ hg --config extensions.extdiff= extdiff -S
715
716 $ hg --config extensions.extdiff= extdiff -r '.^' -S
717 diff -Npru cloned.*/.hgsub cloned/.hgsub (glob)
718 --- cloned.*/.hgsub * +0000 (glob)
719 +++ cloned/.hgsub * +0000 (glob)
720 @@ -1,2 +1 @@
721 sub1 = ../sub1
722 -sub3 = sub3
723 diff -Npru cloned.*/.hgsubstate cloned/.hgsubstate (glob)
724 --- cloned.*/.hgsubstate * +0000 (glob)
725 +++ cloned/.hgsubstate * +0000 (glob)
726 @@ -1,2 +1 @@
727 7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1
728 -b1a26de6f2a045a9f079323693614ee322f1ff7e sub3
729 [1]
730
731 $ hg --config extensions.extdiff= extdiff -r 0 -r '.^' -S
732 diff -Npru cloned.*/.hglf/b.dat cloned.*/.hglf/b.dat (glob)
733 --- cloned.*/.hglf/b.dat * (glob)
734 +++ cloned.*/.hglf/b.dat * (glob)
735 @@ -0,0 +1 @@
736 +da39a3ee5e6b4b0d3255bfef95601890afd80709
737 diff -Npru cloned.*/.hglf/foo/bar/large.dat cloned.*/.hglf/foo/bar/large.dat (glob)
738 --- cloned.*/.hglf/foo/bar/large.dat * (glob)
739 +++ cloned.*/.hglf/foo/bar/large.dat * (glob)
740 @@ -0,0 +1 @@
741 +2f6933b5ee0f5fdd823d9717d8729f3c2523811b
742 diff -Npru cloned.*/.hglf/large.bin cloned.*/.hglf/large.bin (glob)
743 --- cloned.*/.hglf/large.bin * (glob)
744 +++ cloned.*/.hglf/large.bin * (glob)
745 @@ -0,0 +1 @@
746 +7f7097b041ccf68cc5561e9600da4655d21c6d18
747 diff -Npru cloned.*/.hgsub cloned.*/.hgsub (glob)
748 --- cloned.*/.hgsub * (glob)
749 +++ cloned.*/.hgsub * (glob)
750 @@ -1 +1,2 @@
751 sub1 = ../sub1
752 +sub3 = sub3
753 diff -Npru cloned.*/.hgsubstate cloned.*/.hgsubstate (glob)
754 --- cloned.*/.hgsubstate * (glob)
755 +++ cloned.*/.hgsubstate * (glob)
756 @@ -1 +1,2 @@
757 -fc3b4ce2696f7741438c79207583768f2ce6b0dd sub1
758 +7a36fa02b66e61f27f3d4a822809f159479b8ab2 sub1
759 +b1a26de6f2a045a9f079323693614ee322f1ff7e sub3
760 diff -Npru cloned.*/foo/bar/def cloned.*/foo/bar/def (glob)
761 --- cloned.*/foo/bar/def * (glob)
762 +++ cloned.*/foo/bar/def * (glob)
763 @@ -0,0 +1 @@
764 +changed
765 diff -Npru cloned.*/main cloned.*/main (glob)
766 --- cloned.*/main * (glob)
767 +++ cloned.*/main * (glob)
768 @@ -1 +1 @@
769 -main
770 +foo
771 diff -Npru cloned.*/sub1/.hgsubstate cloned.*/sub1/.hgsubstate (glob)
772 --- cloned.*/sub1/.hgsubstate * (glob)
773 +++ cloned.*/sub1/.hgsubstate * (glob)
774 @@ -1 +1 @@
775 -c57a0840e3badd667ef3c3ef65471609acb2ba3c sub2
776 +c77908c81ccea3794a896c79e98b0e004aee2e9e sub2
777 diff -Npru cloned.*/sub1/sub2/folder/test.txt cloned.*/sub1/sub2/folder/test.txt (glob)
778 --- cloned.*/sub1/sub2/folder/test.txt * (glob)
779 +++ cloned.*/sub1/sub2/folder/test.txt * (glob)
780 @@ -0,0 +1 @@
781 +subfolder
782 diff -Npru cloned.*/sub1/sub2/sub2 cloned.*/sub1/sub2/sub2 (glob)
783 --- cloned.*/sub1/sub2/sub2 * (glob)
784 +++ cloned.*/sub1/sub2/sub2 * (glob)
785 @@ -1 +1 @@
786 -sub2
787 +modified
788 diff -Npru cloned.*/sub3/a.txt cloned.*/sub3/a.txt (glob)
789 --- cloned.*/sub3/a.txt * (glob)
790 +++ cloned.*/sub3/a.txt * (glob)
791 @@ -0,0 +1 @@
792 +xyz
793 [1]
794
795 $ echo mod > sub1/sub2/sub2
796 $ hg --config extensions.extdiff= extdiff -S
797 --- */cloned.*/sub1/sub2/sub2 * (glob)
798 +++ */cloned/sub1/sub2/sub2 * (glob)
799 @@ -1 +1 @@
800 -modified
801 +mod
802 [1]
803
712 $ cd ..
804 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now