##// END OF EJS Templates
merge: simplify checkcopies
Matt Mackall -
r6270:14f0fe2e default
parent child Browse files
Show More
@@ -118,27 +118,28 b' def findcopies(repo, m1, m2, ma, limit):'
118 fullcopy = {}
118 fullcopy = {}
119 diverge = {}
119 diverge = {}
120
120
121 def checkcopies(c, man, aman):
121 def checkcopies(f, m1, m2):
122 '''check possible copies for filectx c'''
122 '''check possible copies of f from m1 to m2'''
123 for of in _findoldnames(c, limit):
123 c1 = ctx(f, m1[f])
124 fullcopy[c.path()] = of # remember for dir rename detection
124 for of in _findoldnames(c1, limit):
125 if of not in man: # original file not in other manifest?
125 fullcopy[f] = of # remember for dir rename detection
126 if of not in m2: # original file not in other manifest?
126 if of in ma:
127 if of in ma:
127 diverge.setdefault(of, []).append(c.path())
128 diverge.setdefault(of, []).append(f)
128 continue
129 continue
129 # if the original file is unchanged on the other branch,
130 # if the original file is unchanged on the other branch,
130 # no merge needed
131 # no merge needed
131 if man[of] == aman.get(of):
132 if m2[of] == ma.get(of):
132 continue
133 continue
133 c2 = ctx(of, man[of])
134 c2 = ctx(of, m2[of])
134 ca = c.ancestor(c2)
135 ca = c1.ancestor(c2)
135 if not ca: # unrelated?
136 if not ca: # unrelated?
136 continue
137 continue
137 # named changed on only one side?
138 # named changed on only one side?
138 if ca.path() == c.path() or ca.path() == c2.path():
139 if ca.path() == f or ca.path() == c2.path():
139 if c == ca and c2 == ca: # no merge needed, ignore copy
140 if c1 == ca and c2 == ca: # no merge needed, ignore copy
140 continue
141 continue
141 copy[c.path()] = of
142 copy[f] = of
142
143
143 if not repo.ui.configbool("merge", "followcopies", True):
144 if not repo.ui.configbool("merge", "followcopies", True):
144 return {}, {}
145 return {}, {}
@@ -160,10 +161,10 b' def findcopies(repo, m1, m2, ma, limit):'
160 % "\n ".join(u2))
161 % "\n ".join(u2))
161
162
162 for f in u1:
163 for f in u1:
163 checkcopies(ctx(f, m1[f]), m2, ma)
164 checkcopies(f, m1, m2)
164
165
165 for f in u2:
166 for f in u2:
166 checkcopies(ctx(f, m2[f]), m1, ma)
167 checkcopies(f, m2, m1)
167
168
168 diverge2 = {}
169 diverge2 = {}
169 for of, fl in diverge.items():
170 for of, fl in diverge.items():
General Comments 0
You need to be logged in to leave comments. Login now