Patchwork D9202: dirstate-tree: move a conditional in an explicit boolean

login
register
mail settings
Submitter phabricator
Date Oct. 13, 2020, 9:25 p.m.
Message ID <differential-rev-PHID-DREV-apxdnfzbt4246bo3rub2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47451/
State Superseded
Headers show

Comments

phabricator - Oct. 13, 2020, 9:25 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will help readability a bit and make the next change simpler to read.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9202

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_tree/node.rs

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/dirstate/dirstate_tree/node.rs b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
@@ -57,9 +57,11 @@ 
         let head = split.next().unwrap_or(b"");
         let tail = split.next().unwrap_or(b"");
 
+        // Are we're modifying the current file ? Is the the end of the path ?
+        let is_current_file = tail.is_empty() && head.is_empty();
+
         if let NodeKind::File(file) = &mut self.kind {
-            if tail.is_empty() && head.is_empty() {
-                // We're modifying the current file
+            if is_current_file {
                 let new = Self {
                     kind: NodeKind::File(File {
                         entry: new_entry,