##// END OF EJS Templates
diff: don't crash when merged-in addition was removed (issue4786)...
Martin von Zweigbergk -
r27901:29c8e35d default
parent child Browse files
Show More
@@ -2258,14 +2258,21 b' def diff(repo, node1=None, node2=None, m'
2258
2258
2259 modifiedset = set(modified)
2259 modifiedset = set(modified)
2260 addedset = set(added)
2260 addedset = set(added)
2261 removedset = set(removed)
2261 for f in modified:
2262 for f in modified:
2262 if f not in ctx1:
2263 if f not in ctx1:
2263 # Fix up added, since merged-in additions appear as
2264 # Fix up added, since merged-in additions appear as
2264 # modifications during merges
2265 # modifications during merges
2265 modifiedset.remove(f)
2266 modifiedset.remove(f)
2266 addedset.add(f)
2267 addedset.add(f)
2268 for f in removed:
2269 if f not in ctx1:
2270 # Merged-in additions that are then removed are reported as removed.
2271 # They are not in ctx1, so We don't want to show them in the diff.
2272 removedset.remove(f)
2267 modified = sorted(modifiedset)
2273 modified = sorted(modifiedset)
2268 added = sorted(addedset)
2274 added = sorted(addedset)
2275 removed = sorted(removedset)
2269
2276
2270 def difffn(opts, losedata):
2277 def difffn(opts, losedata):
2271 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
2278 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
@@ -38,3 +38,33 b''
38 $ hg diff -r tip -r ""
38 $ hg diff -r tip -r ""
39 hg: parse error: empty query
39 hg: parse error: empty query
40 [255]
40 [255]
41
42 Remove a file that was added via merge. Since the file is not in parent 1,
43 it should not be in the diff.
44
45 $ hg ci -m 'a=foo' a
46 $ hg co -Cq null
47 $ echo 123 > b
48 $ hg add b
49 $ hg ci -m "b"
50 created new head
51 $ hg merge 1
52 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
53 (branch merge, don't forget to commit)
54 $ hg rm -f a
55 $ hg diff --nodates
56
57 Rename a file that was added via merge. Since the rename source is not in
58 parent 1, the diff should be relative to /dev/null
59
60 $ hg co -Cq 2
61 $ hg merge 1
62 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
63 (branch merge, don't forget to commit)
64 $ hg mv a a2
65 $ hg diff --nodates
66 diff -r cf44b38435e5 a2
67 --- /dev/null
68 +++ b/a2
69 @@ -0,0 +1,1 @@
70 +foo
General Comments 0
You need to be logged in to leave comments. Login now