Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/localrepo.py @ 4370:4ddc6d374265
localrepository.status: only acquire wlock if actually needed.
This speeds up the common case of not needing to update the dirstate,
and avoids the need to reload and parse the dirstate "just in case".
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 24 Apr 2007 11:05:39 -0700 |
parents | 1cc5fc1d0994 |
children | 109077e7048d |
comparison
equal
deleted
inserted
replaced
4369:d7ad1e42a368 | 4370:4ddc6d374265 |
---|---|
917 # read the manifest from node1 before the manifest from node2, | 917 # read the manifest from node1 before the manifest from node2, |
918 # so that we'll hit the manifest cache if we're going through | 918 # so that we'll hit the manifest cache if we're going through |
919 # all the revisions in parent->child order. | 919 # all the revisions in parent->child order. |
920 mf1 = mfmatches(node1) | 920 mf1 = mfmatches(node1) |
921 | 921 |
922 mywlock = False | |
923 | |
922 # are we comparing the working directory? | 924 # are we comparing the working directory? |
923 if not node2: | 925 if not node2: |
924 if not wlock: | |
925 try: | |
926 wlock = self.wlock(wait=0) | |
927 except lock.LockException: | |
928 wlock = None | |
929 (lookup, modified, added, removed, deleted, unknown, | 926 (lookup, modified, added, removed, deleted, unknown, |
930 ignored, clean) = self.dirstate.status(files, match, | 927 ignored, clean) = self.dirstate.status(files, match, |
931 list_ignored, list_clean) | 928 list_ignored, list_clean) |
932 | 929 |
933 # are we comparing working dir against its parent? | 930 # are we comparing working dir against its parent? |
940 for f in lookup: | 937 for f in lookup: |
941 if fcmp(f, getnode): | 938 if fcmp(f, getnode): |
942 modified.append(f) | 939 modified.append(f) |
943 else: | 940 else: |
944 clean.append(f) | 941 clean.append(f) |
945 if wlock is not None: | 942 if not wlock and not mywlock: |
943 mywlock = True | |
944 try: | |
945 wlock = self.wlock(wait=0) | |
946 except lock.LockException: | |
947 pass | |
948 if wlock: | |
946 self.dirstate.update([f], "n") | 949 self.dirstate.update([f], "n") |
947 else: | 950 else: |
948 # we are comparing working dir against non-parent | 951 # we are comparing working dir against non-parent |
949 # generate a pseudo-manifest for the working dir | 952 # generate a pseudo-manifest for the working dir |
950 # XXX: create it in dirstate.py ? | 953 # XXX: create it in dirstate.py ? |
955 mf2[f] = "" | 958 mf2[f] = "" |
956 mf2.set(f, is_exec(f), is_link(f)) | 959 mf2.set(f, is_exec(f), is_link(f)) |
957 for f in removed: | 960 for f in removed: |
958 if f in mf2: | 961 if f in mf2: |
959 del mf2[f] | 962 del mf2[f] |
963 | |
964 if mywlock and wlock: | |
965 wlock.release() | |
960 else: | 966 else: |
961 # we are comparing two revisions | 967 # we are comparing two revisions |
962 mf2 = mfmatches(node2) | 968 mf2 = mfmatches(node2) |
963 | 969 |
964 if not compareworking: | 970 if not compareworking: |