mercurial/cext/parsers.c
changeset 48261 1730b2fceaa1
parent 48244 f7fd629ffb98
child 48263 602c8e8411f5
equal deleted inserted replaced
48260:e9faae0f445c 48261:1730b2fceaa1
   137 	return (self->flags & dirstate_flag_wc_tracked);
   137 	return (self->flags & dirstate_flag_wc_tracked);
   138 }
   138 }
   139 
   139 
   140 static inline bool dirstate_item_c_any_tracked(dirstateItemObject *self)
   140 static inline bool dirstate_item_c_any_tracked(dirstateItemObject *self)
   141 {
   141 {
   142 	const unsigned char mask = dirstate_flag_wc_tracked |
   142 	const int mask = dirstate_flag_wc_tracked | dirstate_flag_p1_tracked |
   143 	                           dirstate_flag_p1_tracked |
   143 	                 dirstate_flag_p2_info;
   144 	                           dirstate_flag_p2_info;
       
   145 	return (self->flags & mask);
   144 	return (self->flags & mask);
   146 }
   145 }
   147 
   146 
   148 static inline bool dirstate_item_c_added(dirstateItemObject *self)
   147 static inline bool dirstate_item_c_added(dirstateItemObject *self)
   149 {
   148 {
   150 	const unsigned char mask =
   149 	const int mask = (dirstate_flag_wc_tracked | dirstate_flag_p1_tracked |
   151 	    (dirstate_flag_wc_tracked | dirstate_flag_p1_tracked |
   150 	                  dirstate_flag_p2_info);
   152 	     dirstate_flag_p2_info);
   151 	const int target = dirstate_flag_wc_tracked;
   153 	const unsigned char target = dirstate_flag_wc_tracked;
       
   154 	return (self->flags & mask) == target;
   152 	return (self->flags & mask) == target;
   155 }
   153 }
   156 
   154 
   157 static inline bool dirstate_item_c_removed(dirstateItemObject *self)
   155 static inline bool dirstate_item_c_removed(dirstateItemObject *self)
   158 {
   156 {
   235 	}
   233 	}
   236 }
   234 }
   237 
   235 
   238 static PyObject *dirstate_item_v2_data(dirstateItemObject *self)
   236 static PyObject *dirstate_item_v2_data(dirstateItemObject *self)
   239 {
   237 {
   240 	unsigned char flags = self->flags;
   238 	int flags = self->flags;
   241 	int mode = dirstate_item_c_v1_mode(self);
   239 	int mode = dirstate_item_c_v1_mode(self);
   242 	if ((mode & S_IXUSR) != 0) {
   240 	if ((mode & S_IXUSR) != 0) {
   243 		flags |= dirstate_flag_mode_exec_perm;
   241 		flags |= dirstate_flag_mode_exec_perm;
   244 	} else {
   242 	} else {
   245 		flags &= ~dirstate_flag_mode_exec_perm;
   243 		flags &= ~dirstate_flag_mode_exec_perm;
   247 	if (S_ISLNK(mode)) {
   245 	if (S_ISLNK(mode)) {
   248 		flags |= dirstate_flag_mode_is_symlink;
   246 		flags |= dirstate_flag_mode_is_symlink;
   249 	} else {
   247 	} else {
   250 		flags &= ~dirstate_flag_mode_is_symlink;
   248 		flags &= ~dirstate_flag_mode_is_symlink;
   251 	}
   249 	}
   252 	return Py_BuildValue("Bii", flags, self->size, self->mtime);
   250 	return Py_BuildValue("iii", flags, self->size, self->mtime);
   253 };
   251 };
   254 
   252 
   255 static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
   253 static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
   256 {
   254 {
   257 	char state = dirstate_item_c_v1_state(self);
   255 	char state = dirstate_item_c_v1_state(self);
   370 	dirstateItemObject *t =
   368 	dirstateItemObject *t =
   371 	    PyObject_New(dirstateItemObject, &dirstateItemType);
   369 	    PyObject_New(dirstateItemObject, &dirstateItemType);
   372 	if (!t) {
   370 	if (!t) {
   373 		return NULL;
   371 		return NULL;
   374 	}
   372 	}
   375 	if (!PyArg_ParseTuple(args, "bii", &t->flags, &t->size, &t->mtime)) {
   373 	if (!PyArg_ParseTuple(args, "iii", &t->flags, &t->size, &t->mtime)) {
   376 		return NULL;
   374 		return NULL;
       
   375 	}
       
   376 	if (t->flags & dirstate_flag_expected_state_is_modified) {
       
   377 		t->flags &= ~(dirstate_flag_expected_state_is_modified |
       
   378 		              dirstate_flag_has_meaningful_data |
       
   379 		              dirstate_flag_has_file_mtime);
   377 	}
   380 	}
   378 	t->mode = 0;
   381 	t->mode = 0;
   379 	if (t->flags & dirstate_flag_has_meaningful_data) {
   382 	if (t->flags & dirstate_flag_has_meaningful_data) {
   380 		if (t->flags & dirstate_flag_mode_exec_perm) {
   383 		if (t->flags & dirstate_flag_mode_exec_perm) {
   381 			t->mode = 0755;
   384 			t->mode = 0755;