Show More
@@ -36,6 +36,22 b' def _getfsnow(vfs):' | |||
|
36 | 36 | os.close(tmpfd) |
|
37 | 37 | vfs.unlink(tmpname) |
|
38 | 38 | |
|
39 | def _trypending(root, vfs, filename): | |
|
40 | '''Open file to be read according to HG_PENDING environment variable | |
|
41 | ||
|
42 | This opens '.pending' of specified 'filename' only when HG_PENDING | |
|
43 | is equal to 'root'. | |
|
44 | ||
|
45 | This returns '(fp, is_pending_opened)' tuple. | |
|
46 | ''' | |
|
47 | if root == os.environ.get('HG_PENDING'): | |
|
48 | try: | |
|
49 | return (vfs('%s.pending' % filename), True) | |
|
50 | except IOError as inst: | |
|
51 | if inst.errno != errno.ENOENT: | |
|
52 | raise | |
|
53 | return (vfs(filename), False) | |
|
54 | ||
|
39 | 55 | class dirstate(object): |
|
40 | 56 | |
|
41 | 57 | def __init__(self, opener, ui, root, validate): |
@@ -64,6 +80,9 b' class dirstate(object):' | |||
|
64 | 80 | self._filename = 'dirstate' |
|
65 | 81 | self._pendingfilename = '%s.pending' % self._filename |
|
66 | 82 | |
|
83 | # for consitent view between _pl() and _read() invocations | |
|
84 | self._pendingmode = None | |
|
85 | ||
|
67 | 86 | def beginparentchange(self): |
|
68 | 87 | '''Marks the beginning of a set of changes that involve changing |
|
69 | 88 | the dirstate parents. If there is an exception during this time, |
@@ -137,7 +156,7 b' class dirstate(object):' | |||
|
137 | 156 | @propertycache |
|
138 | 157 | def _pl(self): |
|
139 | 158 | try: |
|
140 |
fp = self._open |
|
|
159 | fp = self._opendirstatefile() | |
|
141 | 160 | st = fp.read(40) |
|
142 | 161 | fp.close() |
|
143 | 162 | l = len(st) |
@@ -342,11 +361,20 b' class dirstate(object):' | |||
|
342 | 361 | f.discard() |
|
343 | 362 | raise |
|
344 | 363 | |
|
364 | def _opendirstatefile(self): | |
|
365 | fp, mode = _trypending(self._root, self._opener, self._filename) | |
|
366 | if self._pendingmode is not None and self._pendingmode != mode: | |
|
367 | fp.close() | |
|
368 | raise error.Abort(_('working directory state may be ' | |
|
369 | 'changed parallelly')) | |
|
370 | self._pendingmode = mode | |
|
371 | return fp | |
|
372 | ||
|
345 | 373 | def _read(self): |
|
346 | 374 | self._map = {} |
|
347 | 375 | self._copymap = {} |
|
348 | 376 | try: |
|
349 |
fp = self._open |
|
|
377 | fp = self._opendirstatefile() | |
|
350 | 378 | try: |
|
351 | 379 | st = fp.read() |
|
352 | 380 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now