~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockable_files.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
from cStringIO import StringIO
18
18
import codecs
19
19
#import traceback
20
 
from warnings import warn
21
20
 
22
21
import bzrlib
23
22
from bzrlib.decorators import (needs_read_lock,
105
104
 
106
105
    def __del__(self):
107
106
        if self.is_locked():
108
 
            # do not automatically unlock; there should have been a
109
 
            # try/finally to unlock this.
110
 
            warn("%r was gc'd while locked" % self)
 
107
            # XXX: This should show something every time, and be suitable for
 
108
            # headless operation and embedding
 
109
            from warnings import warn
 
110
            warn("file group %r was not explicitly unlocked" % self)
 
111
            self._lock.unlock()
111
112
 
112
113
    def break_lock(self):
113
114
        """Break the lock of this lockable files group if it is held.