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