##// END OF EJS Templates
Optimize dirstate walking...
Optimize dirstate walking This generally cuts the time for hg status/diff in half, from 2s down to 1s. The main parts I'm trying to optimize are: 1) os.walk stats every file. dirstate.changes then stats every file again. 2) os.walk yields every file and subdir to dirstate.traverse who yields every file and everything in the dirstate map. dirstate.walk then filters this mass and yields every file to the caller. There should be fewer steps in here, and fewer duplicate strings yielded. 3) dirstate.walk runs util.unique on the results from dirstate.traverse, even though it is also passing things through dirstate.seen to look for duplicates. I've turned os.walk into something hg specific that takes all the dirstate ignore and matching rules into account. The new function also takes an function arg (statmatch()) the caller supplies to help filter out files it doesn't care about. dirstate.changes uses this to update state for each file, avoiding the second stat call. dirstate.walk is changed to turn the match function it is passed into a statmatch function. The only real difference is that a statmatch function takes the stat data as a second parameter. It now calls dirstate.walkhelper, who requires a statmatch function to be passed. This fails test-walk, but right now I think this is from a sorting error fixed by this patch. Index: crew/mercurial/dirstate.py ===================================================================

File last commit:

r1062:6d5a62a5 default
r1183:d9e85a75 default
Show More
lock.py
49 lines | 1.1 KiB | text/x-python | PythonLexer
mpm@selenic.com
Simply repository locking...
r161 # lock.py - simple locking scheme for mercurial
#
# Copyright 2005 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
import os, time
mpm@selenic.com
[PATCH] Enables lock work under the other 'OS'...
r422 import util
mpm@selenic.com
Simply repository locking...
r161
class LockHeld(Exception):
pass
class lock:
benoit.boissinot@ens-lyon.fr
pep-0008 cleanup...
r1062 def __init__(self, file, wait=1):
mpm@selenic.com
Simply repository locking...
r161 self.f = file
self.held = 0
self.wait = wait
self.lock()
def __del__(self):
self.release()
def lock(self):
while 1:
try:
self.trylock()
return 1
except LockHeld, inst:
if self.wait:
time.sleep(1)
continue
raise inst
mpm@selenic.com
Whitespace cleanups...
r515
mpm@selenic.com
Simply repository locking...
r161 def trylock(self):
pid = os.getpid()
try:
mpm@selenic.com
[PATCH] Enables lock work under the other 'OS'...
r422 util.makelock(str(pid), self.f)
mpm@selenic.com
Simply repository locking...
r161 self.held = 1
Thomas Arendsen Hein
Make makelock and readlock work on filesystems without symlink support....
r704 except (OSError, IOError):
mpm@selenic.com
[PATCH] Enables lock work under the other 'OS'...
r422 raise LockHeld(util.readlock(self.f))
mpm@selenic.com
Simply repository locking...
r161
def release(self):
if self.held:
self.held = 0
mpm@selenic.com
Fix troubles with clone and exception handling...
r503 try:
os.unlink(self.f)
except: pass
mpm@selenic.com
Simply repository locking...
r161