equal
deleted
inserted
replaced
123 return mdiff.textdiff(a, b) |
123 return mdiff.textdiff(a, b) |
124 return d |
124 return d |
125 else: |
125 else: |
126 return mdiff.textdiff(a, b) |
126 return mdiff.textdiff(a, b) |
127 |
127 |
128 def add(self, map, flags, transaction, link, p1=None, p2=None,changed=None): |
128 def add(self, map, flags, transaction, link, p1=None, p2=None, |
|
129 changed=None): |
129 # directly generate the mdiff delta from the data collected during |
130 # directly generate the mdiff delta from the data collected during |
130 # the bisect loop below |
131 # the bisect loop below |
131 def gendelta(delta): |
132 def gendelta(delta): |
132 i = 0 |
133 i = 0 |
133 result = [] |
134 result = [] |
135 start = delta[i][2] |
136 start = delta[i][2] |
136 end = delta[i][3] |
137 end = delta[i][3] |
137 l = delta[i][4] |
138 l = delta[i][4] |
138 if l == None: |
139 if l == None: |
139 l = "" |
140 l = "" |
140 while i < len(delta) - 1 and start <= delta[i+1][2] and end >= delta[i+1][2]: |
141 while i < len(delta) - 1 and start <= delta[i+1][2] \ |
|
142 and end >= delta[i+1][2]: |
141 if delta[i+1][3] > end: |
143 if delta[i+1][3] > end: |
142 end = delta[i+1][3] |
144 end = delta[i+1][3] |
143 if delta[i+1][4]: |
145 if delta[i+1][4]: |
144 l += delta[i+1][4] |
146 l += delta[i+1][4] |
145 i += 1 |
147 i += 1 |
175 offsets[i] = offset |
177 offsets[i] = offset |
176 return offsets |
178 return offsets |
177 |
179 |
178 # if we're using the listcache, make sure it is valid and |
180 # if we're using the listcache, make sure it is valid and |
179 # parented by the same node we're diffing against |
181 # parented by the same node we're diffing against |
180 if not changed or not self.listcache or not p1 or self.mapcache[0] != p1: |
182 if not changed or not self.listcache or not p1 or \ |
|
183 self.mapcache[0] != p1: |
181 files = map.keys() |
184 files = map.keys() |
182 files.sort() |
185 files.sort() |
183 |
186 |
184 self.addlist = ["%s\000%s%s\n" % |
187 self.addlist = ["%s\000%s%s\n" % |
185 (f, hex(map[f]), flags[f] and "x" or '') |
188 (f, hex(map[f]), flags[f] and "x" or '') |
199 delta = [] |
202 delta = [] |
200 bs = 0 |
203 bs = 0 |
201 |
204 |
202 for w in work: |
205 for w in work: |
203 f = w[0] |
206 f = w[0] |
204 # bs will either be the index of the item or the insertion point |
207 # bs will either be the index of the item or the insert point |
205 bs = bisect.bisect(addlist, f, bs) |
208 bs = bisect.bisect(addlist, f, bs) |
206 if bs < len(addlist): |
209 if bs < len(addlist): |
207 fn = addlist[bs][:addlist[bs].index('\0')] |
210 fn = addlist[bs][:addlist[bs].index('\0')] |
208 else: |
211 else: |
209 fn = None |
212 fn = None |
210 if w[1] == 0: |
213 if w[1] == 0: |
211 l = "%s\000%s%s\n" % (f, hex(map[f]), flags[f] and "x" or '') |
214 l = "%s\000%s%s\n" % (f, hex(map[f]), |
|
215 flags[f] and "x" or '') |
212 else: |
216 else: |
213 l = None |
217 l = None |
214 start = bs |
218 start = bs |
215 if fn != f: |
219 if fn != f: |
216 # item not found, insert a new one |
220 # item not found, insert a new one |
812 # update manifest |
816 # update manifest |
813 m1.update(new) |
817 m1.update(new) |
814 for f in remove: |
818 for f in remove: |
815 if f in m1: |
819 if f in m1: |
816 del m1[f] |
820 del m1[f] |
817 mn = self.manifest.add(m1, mf1, tr, linkrev, c1[0], c2[0], (new,remove)) |
821 mn = self.manifest.add(m1, mf1, tr, linkrev, c1[0], c2[0], |
|
822 (new, remove)) |
818 |
823 |
819 # add changeset |
824 # add changeset |
820 new = new.keys() |
825 new = new.keys() |
821 new.sort() |
826 new.sort() |
822 |
827 |
862 mf = dict(self.manifest.read(node)) |
867 mf = dict(self.manifest.read(node)) |
863 for fn in mf.keys(): |
868 for fn in mf.keys(): |
864 if not match(fn): |
869 if not match(fn): |
865 del mf[fn] |
870 del mf[fn] |
866 return mf |
871 return mf |
867 |
872 |
868 # are we comparing the working directory? |
873 # are we comparing the working directory? |
869 if not node2: |
874 if not node2: |
870 l, c, a, d, u = self.dirstate.changes(files, match) |
875 l, c, a, d, u = self.dirstate.changes(files, match) |
871 |
876 |
872 # are we comparing working dir against its parent? |
877 # are we comparing working dir against its parent? |
924 for f in list: |
929 for f in list: |
925 p = self.wjoin(f) |
930 p = self.wjoin(f) |
926 if not os.path.exists(p): |
931 if not os.path.exists(p): |
927 self.ui.warn("%s does not exist!\n" % f) |
932 self.ui.warn("%s does not exist!\n" % f) |
928 elif not os.path.isfile(p): |
933 elif not os.path.isfile(p): |
929 self.ui.warn("%s not added: mercurial only supports files currently\n" % f) |
934 self.ui.warn("%s not added: only files supported currently\n" % f) |
930 elif self.dirstate.state(f) in 'an': |
935 elif self.dirstate.state(f) in 'an': |
931 self.ui.warn("%s already tracked!\n" % f) |
936 self.ui.warn("%s already tracked!\n" % f) |
932 else: |
937 else: |
933 self.dirstate.update([f], "a") |
938 self.dirstate.update([f], "a") |
934 |
939 |