# HG changeset patch # User Artem Tikhomirov # Date 1340044019 -7200 # Node ID 281cfb60e2ef8e87cedff623a0641950ee2554af # Parent 39fe00407937eeb193609f72e25208a061aaa35e Added option to turn detection of copied files off during status operation diff -r 39fe00407937 -r 281cfb60e2ef src/org/tmatesoft/hg/repo/HgStatusCollector.java --- a/src/org/tmatesoft/hg/repo/HgStatusCollector.java Fri Jun 08 17:55:00 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgStatusCollector.java Mon Jun 18 20:26:59 2012 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 TMate Software Ltd + * Copyright (c) 2011-2012 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,8 @@ private final Pool cacheFilenames; private final ManifestRevision emptyFakeState; private Path.Matcher scope = new Path.Matcher.Any(); + // @see #detectCopies() + private boolean detectCopies = true; public HgStatusCollector(HgRepository hgRepo) { @@ -184,6 +186,30 @@ // do not assign null, ever scope = scopeMatcher == null ? new Path.Matcher.Any() : scopeMatcher; } + + /** + * Select whether Collector shall tell "added-new" from "added-by-copy/rename" files. + * This is analogous to '-C' switch of 'hg status' command. + * + *

With copy detection turned off, files continue be reported as plain 'added' files. + * + *

By default, copy detection is on, as it's reasonably cheap. However, + * in certain scenarios it may be reasonable to turn it off, for example when it's a merge + * of two very different branches and there are a lot of files added/moved. + * + * Another legitimate reason to set detection to off if you're lazy to + * implement {@link HgStatusInspector#copied(Path, Path)} ;) + * + * @param detect true if copies detection is desirable + */ + public void detectCopies(boolean detect) { + // cpython, revision:72161, p1:72159, p2:72160 + // p2 comes from another branch with 321 file added (looks like copied/moved, however, the isCopy + // record present only for couple of them). With 2,5 ms per isCopy() operation, almost a second + // is spent detecting origins (according to Marc, of little use in this scenario, as it's second parent + // in the merge) - in fact, most of the time of the status operation + detectCopies = detect; + } // hg status --change public void change(int rev, HgStatusInspector inspector) throws /*FIXME HInvalidRevisionException,*/ HgInvalidControlFileException { @@ -264,7 +290,7 @@ } else { try { Path copyTarget = r2fname; - Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); + Path copyOrigin = detectCopies ? getOriginIfCopy(repo, copyTarget, r1Files, rev1) : null; if (copyOrigin != null) { inspector.copied(getPathPool().path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); } else {