# HG changeset patch # User Idan Kamara # Date 1330616569 -7200 # Node ID fb7c4c14223fce0b8e8c782f3f29eac53e75afed # Parent 9d4a2942a732ee2d8453d1fc4a81ae5683247762 dirstate: filecacheify _branch The opener is relative to .hg, use it in a subclass of filecache to compute the final path. diff -r 9d4a2942a732 -r fb7c4c14223f mercurial/dirstate.py --- a/mercurial/dirstate.py Thu Mar 01 17:39:58 2012 +0200 +++ b/mercurial/dirstate.py Thu Mar 01 17:42:49 2012 +0200 @@ -14,6 +14,12 @@ _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) def _finddirs(path): pos = path.rfind('/') @@ -78,7 +84,7 @@ f['.'] = '.' # prevents useless util.fspath() invocation return f - @propertycache + @repocache('branch') def _branch(self): try: return self._opener.read("branch").strip() or "default" diff -r 9d4a2942a732 -r fb7c4c14223f tests/test-commandserver.py --- a/tests/test-commandserver.py Thu Mar 01 17:39:58 2012 +0200 +++ b/tests/test-commandserver.py Thu Mar 01 17:42:49 2012 +0200 @@ -212,6 +212,13 @@ 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') + if __name__ == '__main__': os.system('hg init') @@ -232,3 +239,4 @@ check(tagscache) check(setphase) check(rollback) + check(branch) diff -r 9d4a2942a732 -r fb7c4c14223f tests/test-commandserver.py.out --- a/tests/test-commandserver.py.out Thu Mar 01 17:39:58 2012 +0200 +++ b/tests/test-commandserver.py.out Thu Mar 01 17:42:49 2012 +0200 @@ -145,3 +145,14 @@ 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?)