##// END OF EJS Templates
merge: pull findcopies helpers inside, refactor checkpair to checkcopies
Matt Mackall -
r3732:ffe9fef8 default
parent child Browse files
Show More
@@ -87,20 +87,13 def forgetremoved(wctx, mctx):
87
87
88 return action
88 return action
89
89
90 def nonoverlap(d1, d2, d3):
90 def findcopies(repo, m1, m2, ma, limit):
91 "Return list of elements in d1 not in d2 or d3"
91 """
92 Find moves and copies between m1 and m2 back to limit linkrev
93 """
92
94
93 l = []
95 def findold(fctx):
94 for d in d1:
95 if d not in d3 and d not in d2:
96 l.append(d)
97
98 l.sort()
99 return l
100
101 def findold(fctx, limit):
102 "find files that path was copied from, back to linkrev limit"
96 "find files that path was copied from, back to linkrev limit"
103
104 old = {}
97 old = {}
105 orig = fctx.path()
98 orig = fctx.path()
106 visit = [fctx]
99 visit = [fctx]
@@ -116,10 +109,23 def findold(fctx, limit):
116 old.sort()
109 old.sort()
117 return old
110 return old
118
111
119 def findcopies(repo, m1, m2, ma, limit):
112 def nonoverlap(d1, d2, d3):
120 """
113 "Return list of elements in d1 not in d2 or d3"
121 Find moves and copies between m1 and m2 back to limit linkrev
114 l = [d for d in d1 if d not in d3 and d not in d2]
122 """
115 l.sort()
116 return l
117
118 def checkcopies(c, man):
119 '''check possible copies for filectx c'''
120 for of in findold(c):
121 if of not in man:
122 return
123 c2 = ctx(of, man[of])
124 ca = c.ancestor(c2)
125 if not ca or c == ca or c2 == ca:
126 return
127 if ca.path() == c.path() or ca.path() == c2.path():
128 copy[c.path()] = of
123
129
124 if not repo.ui.configbool("merge", "followcopies", True):
130 if not repo.ui.configbool("merge", "followcopies", True):
125 return {}
131 return {}
@@ -134,26 +140,11 def findcopies(repo, m1, m2, ma, limit):
134 u2 = nonoverlap(m2, m1, ma)
140 u2 = nonoverlap(m2, m1, ma)
135 ctx = util.cachefunc(lambda f, n: repo.filectx(f, fileid=n[:20]))
141 ctx = util.cachefunc(lambda f, n: repo.filectx(f, fileid=n[:20]))
136
142
137 def checkpair(c, f2, man):
138 ''' check if an apparent pair actually matches '''
139 if f2 not in man:
140 return
141 c2 = ctx(f2, man[f2])
142 ca = c.ancestor(c2)
143 if not ca or c == ca or c2 == ca:
144 return
145 if ca.path() == c.path() or ca.path() == c2.path():
146 copy[c.path()] = f2
147
148 for f in u1:
143 for f in u1:
149 c = ctx(dcopies.get(f, f), m1[f])
144 checkcopies(ctx(dcopies.get(f, f), m1[f]), m2)
150 for of in findold(c, limit):
151 checkpair(c, of, m2)
152
145
153 for f in u2:
146 for f in u2:
154 c = ctx(f, m2[f])
147 checkcopies(ctx(f, m2[f]), m1)
155 for of in findold(c, limit):
156 checkpair(c, of, m1)
157
148
158 return copy
149 return copy
159
150
General Comments 0
You need to be logged in to leave comments. Login now