##// END OF EJS Templates
extdiff: do single file diffs from the wc with no copy...
Brad Schick -
r5137:2be225ea default
parent child Browse files
Show More
@@ -113,12 +113,34 b' def dodiff(ui, repo, diffcmd, diffopts, '
113 return 0
113 return 0
114
114
115 tmproot = tempfile.mkdtemp(prefix='extdiff.')
115 tmproot = tempfile.mkdtemp(prefix='extdiff.')
116 dir2root = ''
116 try:
117 try:
118 # Always make a copy of node1
117 dir1 = snapshot_node(ui, repo, modified + removed, node1, tmproot)
119 dir1 = snapshot_node(ui, repo, modified + removed, node1, tmproot)
120 changes = len(modified) + len(removed) + len(added)
121
122 # If node2 in not the wc or there is >1 change, copy it
118 if node2:
123 if node2:
119 dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot)
124 dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot)
125 elif changes > 1:
126 dir2 = snapshot_wdir(ui, repo, modified + added, tmproot)
120 else:
127 else:
121 dir2 = snapshot_wdir(ui, repo, modified + added, tmproot)
128 # This lets the diff tool open the changed file directly
129 dir2 = ''
130 dir2root = repo.root
131
132 # If only one change, diff the files instead of the directories
133 if changes == 1 :
134 if len(modified):
135 dir1 = os.path.join(dir1, util.localpath(modified[0]))
136 dir2 = os.path.join(dir2root, dir2, util.localpath(modified[0]))
137 elif len(removed) :
138 dir1 = os.path.join(dir1, util.localpath(removed[0]))
139 dir2 = os.devnull
140 else:
141 dir1 = os.devnull
142 dir2 = os.path.join(dir2root, dir2, util.localpath(added[0]))
143
122 cmdline = ('%s %s %s %s' %
144 cmdline = ('%s %s %s %s' %
123 (util.shellquote(diffcmd), ' '.join(diffopts),
145 (util.shellquote(diffcmd), ' '.join(diffopts),
124 util.shellquote(dir1), util.shellquote(dir2)))
146 util.shellquote(dir1), util.shellquote(dir2)))
@@ -6,7 +6,9 b' echo "extdiff=" >> $HGRCPATH'
6 hg init a
6 hg init a
7 cd a
7 cd a
8 echo a > a
8 echo a > a
9 echo b > b
9 hg add
10 hg add
11 # should diff cloned directories
10 hg extdiff -o -r $opt
12 hg extdiff -o -r $opt
11
13
12 echo "[extdiff]" >> $HGRCPATH
14 echo "[extdiff]" >> $HGRCPATH
@@ -22,13 +24,17 b" hg ci -d '0 0' -mtest1"
22 echo b >> a
24 echo b >> a
23 hg ci -d '1 0' -mtest2
25 hg ci -d '1 0' -mtest2
24
26
27 # should diff cloned files directly
25 hg falabala -r 0:1
28 hg falabala -r 0:1
26
29
27 # test diff during merge
30 # test diff during merge
28 hg update 0
31 hg update 0
29 echo b >> b
32 echo c >> c
30 hg add b
33 hg add c
31 hg ci -m "new branch" -d '1 0'
34 hg ci -m "new branch" -d '1 0'
32 hg update -C 1
35 hg update -C 1
33 hg merge tip
36 hg merge tip
34 hg falabala || echo "diff-like tools yield a non-zero exit code"
37 # should diff cloned file against wc file
38 hg falabala > out || echo "diff-like tools yield a non-zero exit code"
39 # cleanup the output since the wc is a tmp directory
40 sed 's:\(.* \).*\(\/test-extdiff\):\1[tmp]\2:' out
@@ -1,5 +1,7 b''
1 adding a
1 adding a
2 adding b
2 Only in a: a
3 Only in a: a
4 Only in a: b
3 diffing a.000000000000 a
5 diffing a.000000000000 a
4 hg falabala [OPTION]... [FILE]...
6 hg falabala [OPTION]... [FILE]...
5
7
@@ -22,10 +24,10 b' options:'
22 -X --exclude exclude names matching the given patterns
24 -X --exclude exclude names matching the given patterns
23
25
24 use "hg -v help falabala" to show global options
26 use "hg -v help falabala" to show global options
25 diffing a.e27a2475d60a a.5e49ec8d3f05
27 diffing a.8a5febb7f867/a a.34eed99112ab/a
26 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
27 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
29 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 (branch merge, don't forget to commit)
31 (branch merge, don't forget to commit)
30 diffing a.5e49ec8d3f05 a
31 diff-like tools yield a non-zero exit code
32 diff-like tools yield a non-zero exit code
33 diffing a.34eed99112ab/c [tmp]/test-extdiff/a/c
General Comments 0
You need to be logged in to leave comments. Login now