111 node1, node2, files, match=matchfn)[:5] |
111 node1, node2, files, match=matchfn)[:5] |
112 if not (modified or added or removed): |
112 if not (modified or added or removed): |
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))) |
125 ui.debug('running %r in %s\n' % (cmdline, tmproot)) |
147 ui.debug('running %r in %s\n' % (cmdline, tmproot)) |
126 util.system(cmdline, cwd=tmproot) |
148 util.system(cmdline, cwd=tmproot) |