##// 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 113 return 0
114 114
115 115 tmproot = tempfile.mkdtemp(prefix='extdiff.')
116 dir2root = ''
116 117 try:
118 # Always make a copy of node1
117 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 123 if node2:
119 124 dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot)
125 elif changes > 1:
126 dir2 = snapshot_wdir(ui, repo, modified + added, tmproot)
120 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 144 cmdline = ('%s %s %s %s' %
123 145 (util.shellquote(diffcmd), ' '.join(diffopts),
124 146 util.shellquote(dir1), util.shellquote(dir2)))
@@ -6,7 +6,9 b' echo "extdiff=" >> $HGRCPATH'
6 6 hg init a
7 7 cd a
8 8 echo a > a
9 echo b > b
9 10 hg add
11 # should diff cloned directories
10 12 hg extdiff -o -r $opt
11 13
12 14 echo "[extdiff]" >> $HGRCPATH
@@ -22,13 +24,17 b" hg ci -d '0 0' -mtest1"
22 24 echo b >> a
23 25 hg ci -d '1 0' -mtest2
24 26
27 # should diff cloned files directly
25 28 hg falabala -r 0:1
26 29
27 30 # test diff during merge
28 31 hg update 0
29 echo b >> b
30 hg add b
32 echo c >> c
33 hg add c
31 34 hg ci -m "new branch" -d '1 0'
32 35 hg update -C 1
33 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 1 adding a
2 adding b
2 3 Only in a: a
4 Only in a: b
3 5 diffing a.000000000000 a
4 6 hg falabala [OPTION]... [FILE]...
5 7
@@ -22,10 +24,10 b' options:'
22 24 -X --exclude exclude names matching the given patterns
23 25
24 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 28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
27 29 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
28 30 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 31 (branch merge, don't forget to commit)
30 diffing a.5e49ec8d3f05 a
31 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