Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 689:5050ee565bd1
Issue 44: Renames/copies other than for the very first revision of a file are not recognized
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 27 Jul 2013 22:06:14 +0200 |
parents | 12a4f60ea972 |
children | b286222158be |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Sat Jul 27 20:15:37 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Sat Jul 27 22:06:14 2013 +0200 @@ -420,10 +420,24 @@ // removed: nothing to report, if (ds.checkNormal(fname) != null || ds.checkMerged(fname) != null) { try { - Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, baseRevNames, baseRevision); - if (origin != null) { - inspector.copied(getPathPool().mangle(origin), fname); - return; + // FIXME refactor, done numerous time e.g. in TestStatus#testStatusCommand with base = 3 + ArrayList<Nodeid> parents = new ArrayList<Nodeid>(2); + parents.add(ds.parents().first()); + parents.add(ds.parents().second()); + parents.remove(Nodeid.NULL); + // try either parent if file came through one of them, or both + for (Nodeid parent : parents) { + int csetIndex = repo.getChangelog().getRevisionIndex(parent); + Nodeid fileRev = repo.getManifest().getFileRevision(csetIndex, fname); + if (fileRev == null) { + continue; + } + // see if file revision known in this parent got copied from one of baseRevNames + Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, fileRev, baseRevNames, baseRevision); + if (origin != null) { + inspector.copied(getPathPool().mangle(origin), fname); + return; + } } // fall-through, report as added } catch (HgInvalidFileException ex) {