rust/hg-core/src/dirstate/parsers.rs
changeset 45648 1efbc787334c
parent 45613 496537c9c1b4
child 46507 68a15b5a7e58
equal deleted inserted replaced
45647:7baf5f798ba9 45648:1efbc787334c
   105         })
   105         })
   106         .sum();
   106         .sum();
   107     let expected_size = expected_size + PARENT_SIZE * 2;
   107     let expected_size = expected_size + PARENT_SIZE * 2;
   108 
   108 
   109     let mut packed = Vec::with_capacity(expected_size);
   109     let mut packed = Vec::with_capacity(expected_size);
   110     let mut new_state_map = vec![];
       
   111 
   110 
   112     packed.extend(&parents.p1);
   111     packed.extend(&parents.p1);
   113     packed.extend(&parents.p2);
   112     packed.extend(&parents.p2);
   114 
   113 
   115     for (filename, entry) in state_map.iter() {
   114     for (filename, entry) in state_map.iter_mut() {
   116         let new_filename = filename.to_owned();
   115         let new_filename = filename.to_owned();
   117         let mut new_mtime: i32 = entry.mtime;
   116         let mut new_mtime: i32 = entry.mtime;
   118         if entry.state == EntryState::Normal && entry.mtime == now {
   117         if entry.state == EntryState::Normal && entry.mtime == now {
   119             // The file was last modified "simultaneously" with the current
   118             // The file was last modified "simultaneously" with the current
   120             // write to dirstate (i.e. within the same second for file-
   119             // write to dirstate (i.e. within the same second for file-
   124             // within the same second. Invalidate the file's mtime in
   123             // within the same second. Invalidate the file's mtime in
   125             // dirstate, forcing future 'status' calls to compare the
   124             // dirstate, forcing future 'status' calls to compare the
   126             // contents of the file if the size is the same. This prevents
   125             // contents of the file if the size is the same. This prevents
   127             // mistakenly treating such files as clean.
   126             // mistakenly treating such files as clean.
   128             new_mtime = -1;
   127             new_mtime = -1;
   129             new_state_map.push((
   128             *entry = DirstateEntry {
   130                 filename.to_owned(),
   129                 mtime: new_mtime,
   131                 DirstateEntry {
   130                 ..*entry
   132                     mtime: new_mtime,
   131             };
   133                     ..*entry
       
   134                 },
       
   135             ));
       
   136         }
   132         }
   137         let mut new_filename = new_filename.into_vec();
   133         let mut new_filename = new_filename.into_vec();
   138         if let Some(copy) = copy_map.get(filename) {
   134         if let Some(copy) = copy_map.get(filename) {
   139             new_filename.push(b'\0');
   135             new_filename.push(b'\0');
   140             new_filename.extend(copy.bytes());
   136             new_filename.extend(copy.bytes());
   149     }
   145     }
   150 
   146 
   151     if packed.len() != expected_size {
   147     if packed.len() != expected_size {
   152         return Err(DirstatePackError::BadSize(expected_size, packed.len()));
   148         return Err(DirstatePackError::BadSize(expected_size, packed.len()));
   153     }
   149     }
   154 
       
   155     state_map.extend(new_state_map);
       
   156 
   150 
   157     Ok(packed)
   151     Ok(packed)
   158 }
   152 }
   159 /// `now` is the duration in seconds since the Unix epoch
   153 /// `now` is the duration in seconds since the Unix epoch
   160 #[cfg(feature = "dirstate-tree")]
   154 #[cfg(feature = "dirstate-tree")]