equal
deleted
inserted
replaced
80 except (IOError, OSError, util.Abort), inst: |
80 except (IOError, OSError, util.Abort), inst: |
81 # only pure backup file remains, it is sage to ignore any error |
81 # only pure backup file remains, it is sage to ignore any error |
82 pass |
82 pass |
83 |
83 |
84 class transaction(object): |
84 class transaction(object): |
85 def __init__(self, report, opener, vfsmap, journal, after=None, |
85 def __init__(self, report, opener, vfsmap, journalname, after=None, |
86 createmode=None): |
86 createmode=None): |
87 """Begin a new transaction |
87 """Begin a new transaction |
88 |
88 |
89 Begins a new transaction that allows rolling back writes in the event of |
89 Begins a new transaction that allows rolling back writes in the event of |
90 an exception. |
90 an exception. |
102 vfsmap[''] = opener # set default value |
102 vfsmap[''] = opener # set default value |
103 self._vfsmap = vfsmap |
103 self._vfsmap = vfsmap |
104 self.after = after |
104 self.after = after |
105 self.entries = [] |
105 self.entries = [] |
106 self.map = {} |
106 self.map = {} |
107 self.journal = journal |
107 self.journal = journalname |
108 self._queue = [] |
108 self._queue = [] |
109 # a dict of arguments to be passed to hooks |
109 # a dict of arguments to be passed to hooks |
110 self.hookargs = {} |
110 self.hookargs = {} |
111 self.file = opener.open(self.journal, "w") |
111 self.file = opener.open(self.journal, "w") |
112 |
112 |
116 # - if 'location' is not empty, the path is outside main opener reach. |
116 # - if 'location' is not empty, the path is outside main opener reach. |
117 # use 'location' value as a key in a vfsmap to find the right 'vfs' |
117 # use 'location' value as a key in a vfsmap to find the right 'vfs' |
118 # (cache is currently unused) |
118 # (cache is currently unused) |
119 self._backupentries = [] |
119 self._backupentries = [] |
120 self._backupmap = {} |
120 self._backupmap = {} |
121 self._backupjournal = "%s.backupfiles" % journal |
121 self._backupjournal = "%s.backupfiles" % self.journal |
122 self._backupsfile = opener.open(self._backupjournal, 'w') |
122 self._backupsfile = opener.open(self._backupjournal, 'w') |
123 self._backupsfile.write('%d\n' % version) |
123 self._backupsfile.write('%d\n' % version) |
124 |
124 |
125 if createmode is not None: |
125 if createmode is not None: |
126 opener.chmod(self.journal, createmode & 0666) |
126 opener.chmod(self.journal, createmode & 0666) |