--- a/.hgsigs Thu Mar 01 17:35:12 2012 +0100
+++ b/.hgsigs Fri Mar 02 09:54:45 2012 +0100
@@ -49,3 +49,4 @@
6344043924497cd06d781d9014c66802285072e4 0 iD8DBQBPALgmywK+sNU5EO8RAlfhAJ9nYOdWnhfVDHYtDTJAyJtXBAQS9wCgnefoSQt7QABkbGxM+Q85UYEBuD0=
db33555eafeaf9df1e18950e29439eaa706d399b 0 iD8DBQBPGdzxywK+sNU5EO8RAppkAJ9jOXhUVE/97CPgiMA0pMGiIYnesQCfengAszcBiSiKGugiI8Okc9ghU+Y=
2aa5b51f310fb3befd26bed99c02267f5c12c734 0 iD8DBQBPKZ9bywK+sNU5EO8RAt1TAJ45r1eJ0YqSkInzrrayg4TVCh0SnQCgm0GA/Ua74jnnDwVQ60lAwROuz1Q=
+53e2cd303ecf8ca7c7eeebd785c34e5ed6b0f4a4 0 iD8DBQBPT/fvywK+sNU5EO8RAnfYAKCn7d0vwqIb100YfWm1F7nFD5B+FACeM02YHpQLSNsztrBCObtqcnfod7Q=
--- a/.hgtags Thu Mar 01 17:35:12 2012 +0100
+++ b/.hgtags Fri Mar 02 09:54:45 2012 +0100
@@ -61,3 +61,4 @@
6344043924497cd06d781d9014c66802285072e4 2.0.2
db33555eafeaf9df1e18950e29439eaa706d399b 2.1-rc
2aa5b51f310fb3befd26bed99c02267f5c12c734 2.1
+53e2cd303ecf8ca7c7eeebd785c34e5ed6b0f4a4 2.1.1
--- a/mercurial/dirstate.py Thu Mar 01 17:35:12 2012 +0100
+++ b/mercurial/dirstate.py Fri Mar 02 09:54:45 2012 +0100
@@ -14,6 +14,17 @@
_format = ">cllll"
propertycache = util.propertycache
+filecache = scmutil.filecache
+
+class repocache(filecache):
+ """filecache for files in .hg/"""
+ def join(self, obj, fname):
+ return obj._opener.join(fname)
+
+class rootcache(filecache):
+ """filecache for files in the repository root"""
+ def join(self, obj, fname):
+ return obj._join(fname)
def _finddirs(path):
pos = path.rfind('/')
@@ -52,6 +63,7 @@
self._dirtypl = False
self._lastnormaltime = 0
self._ui = ui
+ self._filecache = {}
@propertycache
def _map(self):
@@ -77,7 +89,7 @@
f['.'] = '.' # prevents useless util.fspath() invocation
return f
- @propertycache
+ @repocache('branch')
def _branch(self):
try:
return self._opener.read("branch").strip() or "default"
@@ -113,7 +125,7 @@
def dirs(self):
return self._dirs
- @propertycache
+ @rootcache('.hgignore')
def _ignore(self):
files = [self._join('.hgignore')]
for name, path in self._ui.configitems("ui"):
--- a/mercurial/localrepo.py Thu Mar 01 17:35:12 2012 +0100
+++ b/mercurial/localrepo.py Fri Mar 02 09:54:45 2012 +0100
@@ -19,6 +19,11 @@
propertycache = util.propertycache
filecache = scmutil.filecache
+class storecache(filecache):
+ """filecache for files in the store"""
+ def join(self, obj, fname):
+ return obj.sjoin(fname)
+
class localrepository(repo.repository):
capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey',
'known', 'getbundle'))
@@ -176,7 +181,7 @@
def _writebookmarks(self, marks):
bookmarks.write(self)
- @filecache('phaseroots', True)
+ @storecache('phaseroots')
def _phaseroots(self):
self._dirtyphases = False
phaseroots = phases.readroots(self)
@@ -195,7 +200,7 @@
cache[rev] = phase
return cache
- @filecache('00changelog.i', True)
+ @storecache('00changelog.i')
def changelog(self):
c = changelog.changelog(self.sopener)
if 'HG_PENDING' in os.environ:
@@ -204,7 +209,7 @@
c.readpending('00changelog.i.a')
return c
- @filecache('00manifest.i', True)
+ @storecache('00manifest.i')
def manifest(self):
return manifest.manifest(self.sopener)
@@ -896,10 +901,13 @@
rereads the dirstate. Use dirstate.invalidate() if you want to
explicitly read the dirstate again (i.e. restoring it to a previous
known good state).'''
- try:
+ if 'dirstate' in self.__dict__:
+ for k in self.dirstate._filecache:
+ try:
+ delattr(self.dirstate, k)
+ except AttributeError:
+ pass
delattr(self, 'dirstate')
- except AttributeError:
- pass
def invalidate(self):
for k in self._filecache:
--- a/mercurial/scmutil.py Thu Mar 01 17:35:12 2012 +0100
+++ b/mercurial/scmutil.py Fri Mar 02 09:54:45 2012 +0100
@@ -211,7 +211,7 @@
if r:
raise util.Abort("%s: %r" % (r, path))
self.auditor(path)
- f = os.path.join(self.base, path)
+ f = self.join(path)
if not text and "b" not in mode:
mode += "b" # for that other OS
@@ -255,7 +255,7 @@
def symlink(self, src, dst):
self.auditor(dst)
- linkname = os.path.join(self.base, dst)
+ linkname = self.join(dst)
try:
os.unlink(linkname)
except OSError:
@@ -280,6 +280,9 @@
def audit(self, path):
self.auditor(path)
+ def join(self, path):
+ return os.path.join(self.base, path)
+
class filteropener(abstractopener):
'''Wrapper opener for filtering filenames with a function.'''
@@ -793,9 +796,17 @@
to tell us if a file has been replaced. If it can't, we fallback to
recreating the object on every call (essentially the same behaviour as
propertycache).'''
- def __init__(self, path, instore=False):
+ def __init__(self, path):
self.path = path
- self.instore = instore
+
+ def join(self, obj, fname):
+ """Used to compute the runtime path of the cached file.
+
+ Users should subclass filecache and provide their own version of this
+ function to call the appropriate join function on 'obj' (an instance
+ of the class that its member function was decorated).
+ """
+ return obj.join(fname)
def __call__(self, func):
self.func = func
@@ -813,7 +824,7 @@
if entry.changed():
entry.obj = self.func(obj)
else:
- path = self.instore and obj.sjoin(self.path) or obj.join(self.path)
+ path = self.join(obj, self.path)
# We stat -before- creating the object so our cache doesn't lie if
# a writer modified between the time we read and stat
--- a/tests/test-commandserver.py Thu Mar 01 17:35:12 2012 +0100
+++ b/tests/test-commandserver.py Fri Mar 02 09:54:45 2012 +0100
@@ -212,6 +212,27 @@
runcommand(server, ['rollback'])
runcommand(server, ['phase', '-r', '.'])
+def branch(server):
+ readchannel(server)
+ runcommand(server, ['branch'])
+ os.system('hg branch foo')
+ runcommand(server, ['branch'])
+ os.system('hg branch default')
+
+def hgignore(server):
+ readchannel(server)
+ f = open('.hgignore', 'ab')
+ f.write('')
+ f.close()
+ runcommand(server, ['commit', '-Am.'])
+ f = open('ignored-file', 'ab')
+ f.write('')
+ f.close()
+ f = open('.hgignore', 'ab')
+ f.write('ignored-file')
+ f.close()
+ runcommand(server, ['status', '-i', '-u'])
+
if __name__ == '__main__':
os.system('hg init')
@@ -232,3 +253,5 @@
check(tagscache)
check(setphase)
check(rollback)
+ check(branch)
+ check(hgignore)
--- a/tests/test-commandserver.py.out Thu Mar 01 17:35:12 2012 +0100
+++ b/tests/test-commandserver.py.out Fri Mar 02 09:54:45 2012 +0100
@@ -145,3 +145,21 @@
working directory now based on revision 3
runcommand phase -r .
3: public
+
+testing branch:
+
+ runcommand branch
+default
+marked working directory as branch foo
+(branches are permanent and global, did you want a bookmark?)
+ runcommand branch
+foo
+marked working directory as branch default
+(branches are permanent and global, did you want a bookmark?)
+
+testing hgignore:
+
+ runcommand commit -Am.
+adding .hgignore
+ runcommand status -i -u
+I ignored-file