##// END OF EJS Templates
dirstate: introduce a check_invalidated decorator...
marmoute -
r51398:65943224 default
parent child Browse files
Show More
@@ -65,18 +65,33 b' class rootcache(filecache):'
65 return obj._join(fname)
65 return obj._join(fname)
66
66
67
67
68 def check_invalidated(func):
69 """check we func is called a non-invalidated dirstate
70
71 The dirstate is in an "invalidated state" after an error occured during its
72 modification and remains so until we exited the top level scope that framed
73 such change.
74 """
75
76 def wrap(self, *args, **kwargs):
77 if self._invalidated_context:
78 msg = 'calling `%s` after the dirstate was invalidated'
79 msg %= func.__name__
80 raise error.ProgrammingError(msg)
81 return func(self, *args, **kwargs)
82
83 return wrap
84
85
68 def requires_changing_parents(func):
86 def requires_changing_parents(func):
69 def wrap(self, *args, **kwargs):
87 def wrap(self, *args, **kwargs):
70 if not self.is_changing_parents:
88 if not self.is_changing_parents:
71 msg = 'calling `%s` outside of a changing_parents context'
89 msg = 'calling `%s` outside of a changing_parents context'
72 msg %= func.__name__
90 msg %= func.__name__
73 raise error.ProgrammingError(msg)
91 raise error.ProgrammingError(msg)
74 if self._invalidated_context:
75 msg = 'calling `%s` after the dirstate was invalidated'
76 raise error.ProgrammingError(msg)
77 return func(self, *args, **kwargs)
92 return func(self, *args, **kwargs)
78
93
79 return wrap
94 return check_invalidated(wrap)
80
95
81
96
82 def requires_changing_files(func):
97 def requires_changing_files(func):
@@ -87,7 +102,7 b' def requires_changing_files(func):'
87 raise error.ProgrammingError(msg)
102 raise error.ProgrammingError(msg)
88 return func(self, *args, **kwargs)
103 return func(self, *args, **kwargs)
89
104
90 return wrap
105 return check_invalidated(wrap)
91
106
92
107
93 def requires_changing_any(func):
108 def requires_changing_any(func):
@@ -96,12 +111,9 b' def requires_changing_any(func):'
96 msg = 'calling `%s` outside of a changing context'
111 msg = 'calling `%s` outside of a changing context'
97 msg %= func.__name__
112 msg %= func.__name__
98 raise error.ProgrammingError(msg)
113 raise error.ProgrammingError(msg)
99 if self._invalidated_context:
100 msg = 'calling `%s` after the dirstate was invalidated'
101 raise error.ProgrammingError(msg)
102 return func(self, *args, **kwargs)
114 return func(self, *args, **kwargs)
103
115
104 return wrap
116 return check_invalidated(wrap)
105
117
106
118
107 def requires_not_changing_parents(func):
119 def requires_not_changing_parents(func):
@@ -112,7 +124,7 b' def requires_not_changing_parents(func):'
112 raise error.ProgrammingError(msg)
124 raise error.ProgrammingError(msg)
113 return func(self, *args, **kwargs)
125 return func(self, *args, **kwargs)
114
126
115 return wrap
127 return check_invalidated(wrap)
116
128
117
129
118 CHANGE_TYPE_PARENTS = "parents"
130 CHANGE_TYPE_PARENTS = "parents"
General Comments 0
You need to be logged in to leave comments. Login now