##// END OF EJS Templates
mq: drop copy records when refreshing regular patches (issue1441)...
Patrick Mezard -
r7566:5f7e3f17 default
parent child Browse files
Show More
@@ -1190,17 +1190,16 b' class queue:'
1190 patchf.write(chunk)
1190 patchf.write(chunk)
1191
1191
1192 try:
1192 try:
1193 copies = {}
1194 for dst in a:
1195 src = repo.dirstate.copied(dst)
1196 # during qfold, the source file for copies may
1197 # be removed. Treat this as a simple add.
1198 if src is not None and src in repo.dirstate:
1199 copies.setdefault(src, []).append(dst)
1200 repo.dirstate.add(dst)
1201 # remember the copies between patchparent and tip
1202 # this may be slow, so don't do it if we're not tracking copies
1203 if self.diffopts().git:
1193 if self.diffopts().git:
1194 copies = {}
1195 for dst in a:
1196 src = repo.dirstate.copied(dst)
1197 # during qfold, the source file for copies may
1198 # be removed. Treat this as a simple add.
1199 if src is not None and src in repo.dirstate:
1200 copies.setdefault(src, []).append(dst)
1201 repo.dirstate.add(dst)
1202 # remember the copies between patchparent and tip
1204 for dst in aaa:
1203 for dst in aaa:
1205 f = repo.file(dst)
1204 f = repo.file(dst)
1206 src = f.renamed(man[dst])
1205 src = f.renamed(man[dst])
@@ -1211,9 +1210,15 b' class queue:'
1211 # we can't copy a file created by the patch itself
1210 # we can't copy a file created by the patch itself
1212 if dst in copies:
1211 if dst in copies:
1213 del copies[dst]
1212 del copies[dst]
1214 for src, dsts in copies.iteritems():
1213 for src, dsts in copies.iteritems():
1215 for dst in dsts:
1214 for dst in dsts:
1216 repo.dirstate.copy(src, dst)
1215 repo.dirstate.copy(src, dst)
1216 else:
1217 for dst in a:
1218 repo.dirstate.add(dst)
1219 # Drop useless copy information
1220 for f in list(repo.dirstate.copies()):
1221 repo.dirstate.copy(None, f)
1217 for f in r:
1222 for f in r:
1218 repo.dirstate.remove(f)
1223 repo.dirstate.remove(f)
1219 # if the patch excludes a modified file, mark that
1224 # if the patch excludes a modified file, mark that
@@ -216,10 +216,15 b' class dirstate(object):'
216 self._dirty = False
216 self._dirty = False
217
217
218 def copy(self, source, dest):
218 def copy(self, source, dest):
219 """Mark dest as a copy of source. Unmark dest if source is None.
220 """
219 if source == dest:
221 if source == dest:
220 return
222 return
221 self._dirty = True
223 self._dirty = True
222 self._copymap[dest] = source
224 if source is not None:
225 self._copymap[dest] = source
226 elif dest in self._copymap:
227 del self._copymap[dest]
223
228
224 def copied(self, file):
229 def copied(self, file):
225 return self._copymap.get(file, None)
230 return self._copymap.get(file, None)
@@ -123,15 +123,12 b" sed -n '/^diff/s/diff -r [^ ]* //p' .hg/"
123 echo
123 echo
124 cd ..
124 cd ..
125
125
126
127
128 echo "[diff]" >> $HGRCPATH
129 echo "git=True" >> $HGRCPATH
130
131 # Test qrefresh --git losing copy metadata
126 # Test qrefresh --git losing copy metadata
132 echo % create test repo
127 echo % create test repo
133 hg init repo
128 hg init repo
134 cd repo
129 cd repo
130 echo "[diff]" >> .hg/hgrc
131 echo "git=True" >> .hg/hgrc
135 echo a > a
132 echo a > a
136 hg ci -Am adda
133 hg ci -Am adda
137 hg copy a ab
134 hg copy a ab
@@ -146,3 +143,27 b' hg qref'
146 hg qdiff
143 hg qdiff
147 cd ..
144 cd ..
148
145
146 # Test issue 1441: qrefresh confused after hg rename
147 echo % issue1441 without git patches
148 hg init repo-1441
149 cd repo-1441
150 echo a > a
151 hg add a
152 hg qnew -f p
153 hg mv a b
154 hg qrefresh
155 hg qdiff --nodates
156 cd ..
157
158 echo % issue1441 with git patches
159 hg init repo-1441-git
160 cd repo-1441-git
161 echo "[diff]" >> .hg/hgrc
162 echo "git=True" >> .hg/hgrc
163 echo a > a
164 hg add a
165 hg qnew -f p
166 hg mv a b
167 hg qrefresh
168 hg qdiff --nodates
169 cd .. No newline at end of file
@@ -253,3 +253,16 b' copy to ac'
253 @@ -1,1 +1,2 @@
253 @@ -1,1 +1,2 @@
254 a
254 a
255 +c
255 +c
256 % issue1441 without git patches
257 diff -r 000000000000 b
258 --- /dev/null
259 +++ b/b
260 @@ -0,0 +1,1 @@
261 +a
262 % issue1441 with git patches
263 diff --git a/b b/b
264 new file mode 100644
265 --- /dev/null
266 +++ b/b
267 @@ -0,0 +1,1 @@
268 +a
General Comments 0
You need to be logged in to leave comments. Login now