Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 608:e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 07 May 2013 21:27:51 +0200 |
parents | 5a455624be4f |
children | f41dd9a3b8af |
comparison
equal
deleted
inserted
replaced
607:66f1cc23b906 | 608:e1b29756f901 |
---|---|
373 // flags modified, no need to do expensive content check | 373 // flags modified, no need to do expensive content check |
374 inspector.modified(fname); | 374 inspector.modified(fname); |
375 } else { | 375 } else { |
376 HgDataFile df = repo.getFileNode(fname); | 376 HgDataFile df = repo.getFileNode(fname); |
377 if (!df.exists()) { | 377 if (!df.exists()) { |
378 // TODO pass Internals right into HgWCSC cons | 378 Internals implRepo = repo.getImplHelper(); |
379 Internals implRepo = HgInternals.getImplementationRepo(repo); | |
380 String msg = String.format("File %s known as normal in dirstate (%d, %d), doesn't exist at %s", fname, r.modificationTime(), r.size(), implRepo.getStoragePath(df)); | 379 String msg = String.format("File %s known as normal in dirstate (%d, %d), doesn't exist at %s", fname, r.modificationTime(), r.size(), implRepo.getStoragePath(df)); |
381 throw new HgInvalidFileException(msg, null).setFileName(fname); | 380 throw new HgInvalidFileException(msg, null).setFileName(fname); |
382 } | 381 } |
383 Nodeid rev = getDirstateParentManifest().nodeid(fname); | 382 Nodeid rev = getDirstateParentManifest().nodeid(fname); |
384 // rev might be null here if fname comes to dirstate as a result of a merge operation | 383 // rev might be null here if fname comes to dirstate as a result of a merge operation |
494 baseRevNames.remove(fname); // consumed, processed, handled. | 493 baseRevNames.remove(fname); // consumed, processed, handled. |
495 } | 494 } |
496 // only those left in baseRevNames after processing are reported as removed | 495 // only those left in baseRevNames after processing are reported as removed |
497 } | 496 } |
498 | 497 |
499 // TODO think over if content comparison may be done more effectively by e.g. calculating nodeid for a local file and comparing it with nodeid from manifest | 498 // TODO [post-1.1] think over if content comparison may be done more effectively by e.g. calculating nodeid for a local file and comparing it with nodeid from manifest |
500 // we don't need to tell exact difference, hash should be enough to detect difference, and it doesn't involve reading historical file content, and it's relatively | 499 // we don't need to tell exact difference, hash should be enough to detect difference, and it doesn't involve reading historical file content, and it's relatively |
501 // cheap to calc hash on a file (no need to keep it completely in memory). OTOH, if I'm right that the next approach is used for nodeids: | 500 // cheap to calc hash on a file (no need to keep it completely in memory). OTOH, if I'm right that the next approach is used for nodeids: |
502 // changeset nodeid + hash(actual content) => entry (Nodeid) in the next Manifest | 501 // changeset nodeid + hash(actual content) => entry (Nodeid) in the next Manifest |
503 // then it's sufficient to check parents from dirstate, and if they do not match parents from file's baseRevision (non matching parents means different nodeids). | 502 // then it's sufficient to check parents from dirstate, and if they do not match parents from file's baseRevision (non matching parents means different nodeids). |
504 // The question is whether original Hg treats this case (same content, different parents and hence nodeids) as 'modified' or 'clean' | 503 // The question is whether original Hg treats this case (same content, different parents and hence nodeids) as 'modified' or 'clean' |
622 } | 621 } |
623 return same; | 622 return same; |
624 } | 623 } |
625 | 624 |
626 private boolean checkFlagsEqual(FileInfo f, int dirstateFileMode) { | 625 private boolean checkFlagsEqual(FileInfo f, int dirstateFileMode) { |
627 // source/include/linux/stat.h | 626 return checkFlagsEqual(f, HgManifest.Flags.parse(dirstateFileMode)); |
628 final int S_IFLNK = 0120000, S_IXUSR = 00100; | |
629 // TODO post-1.0 HgManifest.Flags.parse(int) | |
630 if ((dirstateFileMode & S_IFLNK) == S_IFLNK) { | |
631 return checkFlagsEqual(f, HgManifest.Flags.Link); | |
632 } | |
633 if ((dirstateFileMode & S_IXUSR) == S_IXUSR) { | |
634 return checkFlagsEqual(f, HgManifest.Flags.Exec); | |
635 } | |
636 return checkFlagsEqual(f, HgManifest.Flags.RegularFile); // no flags | |
637 } | 627 } |
638 | 628 |
639 /** | 629 /** |
640 * Configure status collector to consider only subset of a working copy tree. Tries to be as effective as possible, and to | 630 * Configure status collector to consider only subset of a working copy tree. Tries to be as effective as possible, and to |
641 * traverse only relevant part of working copy on the filesystem. | 631 * traverse only relevant part of working copy on the filesystem. |