Show More
@@ -11,7 +11,6 from mercurial.i18n import _ | |||||
11 | from mercurial import ( |
|
11 | from mercurial import ( | |
12 | error, |
|
12 | error, | |
13 | match as matchmod, |
|
13 | match as matchmod, | |
14 | narrowspec, |
|
|||
15 | ) |
|
14 | ) | |
16 |
|
15 | |||
17 | def wrapdirstate(repo, dirstate): |
|
16 | def wrapdirstate(repo, dirstate): | |
@@ -28,10 +27,6 def wrapdirstate(repo, dirstate): | |||||
28 | return fn(self, *args) |
|
27 | return fn(self, *args) | |
29 | return _wrapper |
|
28 | return _wrapper | |
30 |
|
29 | |||
31 | def _narrowbackupname(backupname): |
|
|||
32 | assert 'dirstate' in backupname |
|
|||
33 | return backupname.replace('dirstate', narrowspec.FILENAME) |
|
|||
34 |
|
||||
35 | class narrowdirstate(dirstate.__class__): |
|
30 | class narrowdirstate(dirstate.__class__): | |
36 | def walk(self, match, subrepos, unknown, ignored, full=True, |
|
31 | def walk(self, match, subrepos, unknown, ignored, full=True, | |
37 | narrowonly=True): |
|
32 | narrowonly=True): | |
@@ -77,18 +72,5 def wrapdirstate(repo, dirstate): | |||||
77 | allfiles = [f for f in allfiles if repo.narrowmatch()(f)] |
|
72 | allfiles = [f for f in allfiles if repo.narrowmatch()(f)] | |
78 | super(narrowdirstate, self).rebuild(parent, allfiles, changedfiles) |
|
73 | super(narrowdirstate, self).rebuild(parent, allfiles, changedfiles) | |
79 |
|
74 | |||
80 | def restorebackup(self, tr, backupname): |
|
|||
81 | narrowspec.restorebackup(self._opener, |
|
|||
82 | _narrowbackupname(backupname)) |
|
|||
83 | super(narrowdirstate, self).restorebackup(tr, backupname) |
|
|||
84 |
|
||||
85 | def savebackup(self, tr, backupname): |
|
|||
86 | super(narrowdirstate, self).savebackup(tr, backupname) |
|
|||
87 | narrowspec.savebackup(self._opener, _narrowbackupname(backupname)) |
|
|||
88 |
|
||||
89 | def clearbackup(self, tr, backupname): |
|
|||
90 | super(narrowdirstate, self).clearbackup(tr, backupname) |
|
|||
91 | narrowspec.clearbackup(self._opener, _narrowbackupname(backupname)) |
|
|||
92 |
|
||||
93 | dirstate.__class__ = narrowdirstate |
|
75 | dirstate.__class__ = narrowdirstate | |
94 | return dirstate |
|
76 | return dirstate |
@@ -41,6 +41,7 from mercurial import ( | |||||
41 | lock as lockmod, |
|
41 | lock as lockmod, | |
42 | mdiff, |
|
42 | mdiff, | |
43 | merge, |
|
43 | merge, | |
|
44 | narrowspec, | |||
44 | node as nodemod, |
|
45 | node as nodemod, | |
45 | patch, |
|
46 | patch, | |
46 | phases, |
|
47 | phases, | |
@@ -314,10 +315,13 def _aborttransaction(repo): | |||||
314 | '''Abort current transaction for shelve/unshelve, but keep dirstate |
|
315 | '''Abort current transaction for shelve/unshelve, but keep dirstate | |
315 | ''' |
|
316 | ''' | |
316 | tr = repo.currenttransaction() |
|
317 | tr = repo.currenttransaction() | |
317 | backupname = 'dirstate.shelve' |
|
318 | dirstatebackupname = 'dirstate.shelve' | |
318 | repo.dirstate.savebackup(tr, backupname) |
|
319 | narrowspecbackupname = 'narrowspec.shelve' | |
|
320 | repo.dirstate.savebackup(tr, dirstatebackupname) | |||
|
321 | narrowspec.savebackup(repo, narrowspecbackupname) | |||
319 | tr.abort() |
|
322 | tr.abort() | |
320 |
|
|
323 | narrowspec.restorebackup(repo, narrowspecbackupname) | |
|
324 | repo.dirstate.restorebackup(None, dirstatebackupname) | |||
321 |
|
325 | |||
322 | def createcmd(ui, repo, pats, opts): |
|
326 | def createcmd(ui, repo, pats, opts): | |
323 | """subcommand that creates a new shelve""" |
|
327 | """subcommand that creates a new shelve""" |
@@ -11,6 +11,7 from .i18n import _ | |||||
11 |
|
11 | |||
12 | from . import ( |
|
12 | from . import ( | |
13 | error, |
|
13 | error, | |
|
14 | narrowspec, | |||
14 | util, |
|
15 | util, | |
15 | ) |
|
16 | ) | |
16 |
|
17 | |||
@@ -33,7 +34,10 class dirstateguard(util.transactional): | |||||
33 | self._active = False |
|
34 | self._active = False | |
34 | self._closed = False |
|
35 | self._closed = False | |
35 | self._backupname = 'dirstate.backup.%s.%d' % (name, id(self)) |
|
36 | self._backupname = 'dirstate.backup.%s.%d' % (name, id(self)) | |
|
37 | self._narrowspecbackupname = ('narrowspec.backup.%s.%d' % | |||
|
38 | (name, id(self))) | |||
36 | repo.dirstate.savebackup(repo.currenttransaction(), self._backupname) |
|
39 | repo.dirstate.savebackup(repo.currenttransaction(), self._backupname) | |
|
40 | narrowspec.savebackup(repo, self._narrowspecbackupname) | |||
37 | self._active = True |
|
41 | self._active = True | |
38 |
|
42 | |||
39 | def __del__(self): |
|
43 | def __del__(self): | |
@@ -52,10 +56,12 class dirstateguard(util.transactional): | |||||
52 |
|
56 | |||
53 | self._repo.dirstate.clearbackup(self._repo.currenttransaction(), |
|
57 | self._repo.dirstate.clearbackup(self._repo.currenttransaction(), | |
54 | self._backupname) |
|
58 | self._backupname) | |
|
59 | narrowspec.clearbackup(self._repo, self._narrowspecbackupname) | |||
55 | self._active = False |
|
60 | self._active = False | |
56 | self._closed = True |
|
61 | self._closed = True | |
57 |
|
62 | |||
58 | def _abort(self): |
|
63 | def _abort(self): | |
|
64 | narrowspec.restorebackup(self._repo, self._narrowspecbackupname) | |||
59 | self._repo.dirstate.restorebackup(self._repo.currenttransaction(), |
|
65 | self._repo.dirstate.restorebackup(self._repo.currenttransaction(), | |
60 | self._backupname) |
|
66 | self._backupname) | |
61 | self._active = False |
|
67 | self._active = False |
@@ -1373,6 +1373,7 class localrepository(object): | |||||
1373 | else: |
|
1373 | else: | |
1374 | # discard all changes (including ones already written |
|
1374 | # discard all changes (including ones already written | |
1375 | # out) in this transaction |
|
1375 | # out) in this transaction | |
|
1376 | narrowspec.restorebackup(self, 'journal.narrowspec') | |||
1376 | repo.dirstate.restorebackup(None, 'journal.dirstate') |
|
1377 | repo.dirstate.restorebackup(None, 'journal.dirstate') | |
1377 |
|
1378 | |||
1378 | repo.invalidate(clearfilecache=True) |
|
1379 | repo.invalidate(clearfilecache=True) | |
@@ -1461,6 +1462,7 class localrepository(object): | |||||
1461 | @unfilteredmethod |
|
1462 | @unfilteredmethod | |
1462 | def _writejournal(self, desc): |
|
1463 | def _writejournal(self, desc): | |
1463 | self.dirstate.savebackup(None, 'journal.dirstate') |
|
1464 | self.dirstate.savebackup(None, 'journal.dirstate') | |
|
1465 | narrowspec.savebackup(self, 'journal.narrowspec') | |||
1464 | self.vfs.write("journal.branch", |
|
1466 | self.vfs.write("journal.branch", | |
1465 | encoding.fromlocal(self.dirstate.branch())) |
|
1467 | encoding.fromlocal(self.dirstate.branch())) | |
1466 | self.vfs.write("journal.desc", |
|
1468 | self.vfs.write("journal.desc", | |
@@ -1548,6 +1550,7 class localrepository(object): | |||||
1548 | # prevent dirstateguard from overwriting already restored one |
|
1550 | # prevent dirstateguard from overwriting already restored one | |
1549 | dsguard.close() |
|
1551 | dsguard.close() | |
1550 |
|
1552 | |||
|
1553 | narrowspec.restorebackup(self, 'undo.narrowspec') | |||
1551 | self.dirstate.restorebackup(None, 'undo.dirstate') |
|
1554 | self.dirstate.restorebackup(None, 'undo.dirstate') | |
1552 | try: |
|
1555 | try: | |
1553 | branch = self.vfs.read('undo.branch') |
|
1556 | branch = self.vfs.read('undo.branch') |
@@ -13,6 +13,7 from .i18n import _ | |||||
13 | from . import ( |
|
13 | from . import ( | |
14 | error, |
|
14 | error, | |
15 | match as matchmod, |
|
15 | match as matchmod, | |
|
16 | repository, | |||
16 | sparse, |
|
17 | sparse, | |
17 | util, |
|
18 | util, | |
18 | ) |
|
19 | ) | |
@@ -129,15 +130,22 def save(repo, includepats, excludepats) | |||||
129 | spec = format(includepats, excludepats) |
|
130 | spec = format(includepats, excludepats) | |
130 | repo.vfs.write(FILENAME, spec) |
|
131 | repo.vfs.write(FILENAME, spec) | |
131 |
|
132 | |||
132 |
def savebackup( |
|
133 | def savebackup(repo, backupname): | |
|
134 | if repository.NARROW_REQUIREMENT not in repo.requirements: | |||
|
135 | return | |||
|
136 | vfs = repo.vfs | |||
133 | vfs.tryunlink(backupname) |
|
137 | vfs.tryunlink(backupname) | |
134 | util.copyfile(vfs.join(FILENAME), vfs.join(backupname), hardlink=True) |
|
138 | util.copyfile(vfs.join(FILENAME), vfs.join(backupname), hardlink=True) | |
135 |
|
139 | |||
136 |
def restorebackup( |
|
140 | def restorebackup(repo, backupname): | |
137 | vfs.rename(backupname, FILENAME, checkambig=True) |
|
141 | if repository.NARROW_REQUIREMENT not in repo.requirements: | |
|
142 | return | |||
|
143 | repo.vfs.rename(backupname, FILENAME, checkambig=True) | |||
138 |
|
144 | |||
139 |
def clearbackup( |
|
145 | def clearbackup(repo, backupname): | |
140 | vfs.unlink(backupname) |
|
146 | if repository.NARROW_REQUIREMENT not in repo.requirements: | |
|
147 | return | |||
|
148 | repo.vfs.unlink(backupname) | |||
141 |
|
149 | |||
142 | def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): |
|
150 | def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): | |
143 | r""" Restricts the patterns according to repo settings, |
|
151 | r""" Restricts the patterns according to repo settings, |
General Comments 0
You need to be logged in to leave comments.
Login now