##// END OF EJS Templates
Fix copies reporting in log and convert....
Maxim Dounin -
r5811:180a3eee default
parent child Browse files
Show More
@@ -881,7 +881,8 b' def debugrename(ui, repo, file1, *pats, '
881 881 ctx = repo.changectx(opts.get('rev', 'tip'))
882 882 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
883 883 ctx.node()):
884 m = ctx.filectx(abs).renamed()
884 fctx = ctx.filectx(abs)
885 m = fctx.filelog().renamed(fctx.filenode())
885 886 if m:
886 887 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
887 888 else:
@@ -1701,8 +1702,7 b' def log(ui, repo, *pats, **opts):'
1701 1702 endrev = repo.changelog.count()
1702 1703 rcache = {}
1703 1704 ncache = {}
1704 dcache = []
1705 def getrenamed(fn, rev, man):
1705 def getrenamed(fn, rev):
1706 1706 '''looks up all renames for a file (up to endrev) the first
1707 1707 time the file is given. It indexes on the changerev and only
1708 1708 parses the manifest if linkrev != changerev.
@@ -1722,13 +1722,14 b' def log(ui, repo, *pats, **opts):'
1722 1722 break
1723 1723 if rev in rcache[fn]:
1724 1724 return rcache[fn][rev]
1725 mr = repo.manifest.rev(man)
1726 if repo.manifest.parentrevs(mr) != (mr - 1, nullrev):
1727 return ncache[fn].get(repo.manifest.find(man, fn)[0])
1728 if not dcache or dcache[0] != man:
1729 dcache[:] = [man, repo.manifest.readdelta(man)]
1730 if fn in dcache[1]:
1731 return ncache[fn].get(dcache[1][fn])
1725
1726 # If linkrev != rev (i.e. rev not found in rcache) fallback to
1727 # filectx logic.
1728
1729 try:
1730 return repo.changectx(rev).filectx(fn).renamed()
1731 except revlog.LookupError:
1732 pass
1732 1733 return None
1733 1734
1734 1735 df = False
@@ -1765,9 +1766,8 b' def log(ui, repo, *pats, **opts):'
1765 1766
1766 1767 copies = []
1767 1768 if opts.get('copies') and rev:
1768 mf = get(rev)[0]
1769 1769 for fn in get(rev)[3]:
1770 rename = getrenamed(fn, rev, mf)
1770 rename = getrenamed(fn, rev)
1771 1771 if rename:
1772 1772 copies.append((fn, rename[0]))
1773 1773 displayer.show(rev, changenode, copies=copies)
@@ -235,6 +235,7 b' class filectx(object):'
235 235 return self._changectx.rev()
236 236 return self._filelog.linkrev(self._filenode)
237 237
238 def linkrev(self): return self._filelog.linkrev(self._filenode)
238 239 def node(self): return self._changectx.node()
239 240 def user(self): return self._changectx.user()
240 241 def date(self): return self._changectx.date()
@@ -245,12 +246,36 b' class filectx(object):'
245 246 def changectx(self): return self._changectx
246 247
247 248 def data(self): return self._filelog.read(self._filenode)
248 def renamed(self): return self._filelog.renamed(self._filenode)
249 249 def path(self): return self._path
250 250 def size(self): return self._filelog.size(self._filerev)
251 251
252 252 def cmp(self, text): return self._filelog.cmp(self._filenode, text)
253 253
254 def renamed(self):
255 """check if file was actually renamed in this changeset revision
256
257 If rename logged in file revision, we report copy for changeset only
258 if file revisions linkrev points back to the changeset in question
259 or both changeset parents contain different file revisions.
260 """
261
262 renamed = self._filelog.renamed(self._filenode)
263 if not renamed:
264 return renamed
265
266 if self.rev() == self.linkrev():
267 return renamed
268
269 name = self.path()
270 fnode = self._filenode
271 for p in self._changectx.parents():
272 try:
273 if fnode == p.filenode(name):
274 return None
275 except revlog.LookupError:
276 pass
277 return renamed
278
254 279 def parents(self):
255 280 p = self._path
256 281 fl = self._filelog
@@ -322,7 +347,7 b' class filectx(object):'
322 347 return [getctx(p, n) for p, n in pl if n != nullrev]
323 348
324 349 # use linkrev to find the first changeset where self appeared
325 if self.rev() != self._filelog.linkrev(self._filenode):
350 if self.rev() != self.linkrev():
326 351 base = self.filectx(self.filerev())
327 352 else:
328 353 base = self
@@ -29,6 +29,9 b' hg up -C 1'
29 29 hg merge 2
30 30 hg ci -m 'merge remote copy' -d '4 0'
31 31
32 chmod +x baz
33 hg ci -m 'mark baz executable' -d '5 0'
34
32 35 cd ..
33 36 hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
34 37 cd new
@@ -9,11 +9,12 b' initializing destination new repository'
9 9 scanning source...
10 10 sorting...
11 11 converting...
12 4 add foo bar
13 3 change foo
14 2 make bar and baz copies of foo
15 1 merge local copy
16 0 merge remote copy
12 5 add foo bar
13 4 change foo
14 3 make bar and baz copies of foo
15 2 merge local copy
16 1 merge remote copy
17 0 mark baz executable
17 18 comparing with ../orig
18 19 searching for changes
19 20 no changes found
@@ -167,31 +167,29 b' c'
167 167 d1
168 168 % executable
169 169 5:f205b3636d77
170 svn: Path 'b' does not exist
171 170 assuming destination a-hg
172 171 initializing svn wc 'a-hg-wc'
173 172 scanning source...
174 173 sorting...
175 174 converting...
176 175 0 make a file executable
177 abort: svn exited with status 1
178 At revision 5.
179 5 5 test .
180 M 5 4 test c
181 5 1 test d1
182 5 1 test d1/d2
183 5 1 test d1/d2/b
176 At revision 6.
177 6 6 test .
178 6 6 test c
179 6 1 test d1
180 6 1 test d1/d2
181 6 1 test d1/d2/b
184 182 <?xml version="1.0"?>
185 183 <log>
186 184 <logentry
187 revision="5">
185 revision="6">
188 186 <author>test</author>
189 187 <date/>
190 188 <paths>
191 189 <path
192 action="D">/b</path>
190 action="M">/c</path>
193 191 </paths>
194 <msg>remove a file</msg>
192 <msg>make a file executable</msg>
195 193 </logentry>
196 194 </log>
197 195 executable
@@ -41,6 +41,11 b' echo foo > foo'
41 41 hg ci -Ame2 -d '6 0'
42 42 hg log -vC --template '{rev} {file_copies%filecopy}\n' -r 5
43 43
44 echo % log copies, execute bit set
45 chmod +x e
46 hg ci -me3 -d '7 0'
47 hg log -vC --template '{rev} {file_copies%filecopy}\n' -r 6
48
44 49 echo '% log -p d'
45 50 hg log -pv d
46 51
@@ -86,6 +86,8 b' 0'
86 86 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 87 adding foo
88 88 5 e (dir/b)
89 % log copies, execute bit set
90 6
89 91 % log -p d
90 92 changeset: 3:16b60bf3f99a
91 93 user: test
General Comments 0
You need to be logged in to leave comments. Login now