Show More
@@ -7,11 +7,13 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | import os | |||
10 | from .i18n import _ |
|
11 | from .i18n import _ | |
11 |
|
12 | |||
12 | from . import ( |
|
13 | from . import ( | |
13 | error, |
|
14 | error, | |
14 | narrowspec, |
|
15 | narrowspec, | |
|
16 | requirements, | |||
15 | util, |
|
17 | util, | |
16 | ) |
|
18 | ) | |
17 |
|
19 | |||
@@ -34,12 +36,21 b' class dirstateguard(util.transactional):' | |||||
34 | self._repo = repo |
|
36 | self._repo = repo | |
35 | self._active = False |
|
37 | self._active = False | |
36 | self._closed = False |
|
38 | self._closed = False | |
37 | self._backupname = b'dirstate.backup.%s.%d' % (name, id(self)) |
|
39 | ||
38 | self._narrowspecbackupname = b'narrowspec.backup.%s.%d' % ( |
|
40 | def getname(prefix): | |
39 | name, |
|
41 | fd, fname = repo.vfs.mkstemp(prefix=prefix) | |
40 |
|
|
42 | os.close(fd) | |
|
43 | return fname | |||
|
44 | ||||
|
45 | self._backupname = getname(b'dirstate.backup.%s.' % name) | |||
|
46 | repo.dirstate.savebackup(repo.currenttransaction(), self._backupname) | |||
|
47 | # Don't make this the empty string, things may join it with stuff and | |||
|
48 | # blindly try to unlink it, which could be bad. | |||
|
49 | self._narrowspecbackupname = None | |||
|
50 | if requirements.NARROW_REQUIREMENT in repo.requirements: | |||
|
51 | self._narrowspecbackupname = getname( | |||
|
52 | b'narrowspec.backup.%s.' % name | |||
41 | ) |
|
53 | ) | |
42 | repo.dirstate.savebackup(repo.currenttransaction(), self._backupname) |
|
|||
43 | narrowspec.savewcbackup(repo, self._narrowspecbackupname) |
|
54 | narrowspec.savewcbackup(repo, self._narrowspecbackupname) | |
44 | self._active = True |
|
55 | self._active = True | |
45 |
|
56 | |||
@@ -62,11 +73,13 b' class dirstateguard(util.transactional):' | |||||
62 | self._repo.dirstate.clearbackup( |
|
73 | self._repo.dirstate.clearbackup( | |
63 | self._repo.currenttransaction(), self._backupname |
|
74 | self._repo.currenttransaction(), self._backupname | |
64 | ) |
|
75 | ) | |
|
76 | if self._narrowspecbackupname: | |||
65 | narrowspec.clearwcbackup(self._repo, self._narrowspecbackupname) |
|
77 | narrowspec.clearwcbackup(self._repo, self._narrowspecbackupname) | |
66 | self._active = False |
|
78 | self._active = False | |
67 | self._closed = True |
|
79 | self._closed = True | |
68 |
|
80 | |||
69 | def _abort(self): |
|
81 | def _abort(self): | |
|
82 | if self._narrowspecbackupname: | |||
70 | narrowspec.restorewcbackup(self._repo, self._narrowspecbackupname) |
|
83 | narrowspec.restorewcbackup(self._repo, self._narrowspecbackupname) | |
71 | self._repo.dirstate.restorebackup( |
|
84 | self._repo.dirstate.restorebackup( | |
72 | self._repo.currenttransaction(), self._backupname |
|
85 | self._repo.currenttransaction(), self._backupname |
General Comments 0
You need to be logged in to leave comments.
Login now