diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -14,6 +14,12 @@ import cStringIO _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 @@ class dirstate(object): f['.'] = '.' # prevents useless util.fspath() invocation return f - @propertycache + @repocache('branch') def _branch(self): try: return self._opener.read("branch").strip() or "default" diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py --- a/tests/test-commandserver.py +++ b/tests/test-commandserver.py @@ -212,6 +212,13 @@ def rollback(server): 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 @@ if __name__ == '__main__': check(tagscache) check(setphase) check(rollback) + check(branch) diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out --- a/tests/test-commandserver.py.out +++ b/tests/test-commandserver.py.out @@ -145,3 +145,14 @@ repository tip rolled back to revision 3 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?)