Show More
@@ -36,6 +36,22 b' def _getfsnow(vfs):' | |||||
36 | os.close(tmpfd) |
|
36 | os.close(tmpfd) | |
37 | vfs.unlink(tmpname) |
|
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 | class dirstate(object): |
|
55 | class dirstate(object): | |
40 |
|
56 | |||
41 | def __init__(self, opener, ui, root, validate): |
|
57 | def __init__(self, opener, ui, root, validate): | |
@@ -64,6 +80,9 b' class dirstate(object):' | |||||
64 | self._filename = 'dirstate' |
|
80 | self._filename = 'dirstate' | |
65 | self._pendingfilename = '%s.pending' % self._filename |
|
81 | self._pendingfilename = '%s.pending' % self._filename | |
66 |
|
82 | |||
|
83 | # for consitent view between _pl() and _read() invocations | |||
|
84 | self._pendingmode = None | |||
|
85 | ||||
67 | def beginparentchange(self): |
|
86 | def beginparentchange(self): | |
68 | '''Marks the beginning of a set of changes that involve changing |
|
87 | '''Marks the beginning of a set of changes that involve changing | |
69 | the dirstate parents. If there is an exception during this time, |
|
88 | the dirstate parents. If there is an exception during this time, | |
@@ -137,7 +156,7 b' class dirstate(object):' | |||||
137 | @propertycache |
|
156 | @propertycache | |
138 | def _pl(self): |
|
157 | def _pl(self): | |
139 | try: |
|
158 | try: | |
140 |
fp = self._open |
|
159 | fp = self._opendirstatefile() | |
141 | st = fp.read(40) |
|
160 | st = fp.read(40) | |
142 | fp.close() |
|
161 | fp.close() | |
143 | l = len(st) |
|
162 | l = len(st) | |
@@ -342,11 +361,20 b' class dirstate(object):' | |||||
342 | f.discard() |
|
361 | f.discard() | |
343 | raise |
|
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 | def _read(self): |
|
373 | def _read(self): | |
346 | self._map = {} |
|
374 | self._map = {} | |
347 | self._copymap = {} |
|
375 | self._copymap = {} | |
348 | try: |
|
376 | try: | |
349 |
fp = self._open |
|
377 | fp = self._opendirstatefile() | |
350 | try: |
|
378 | try: | |
351 | st = fp.read() |
|
379 | st = fp.read() | |
352 | finally: |
|
380 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now