gracinet created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Whatever the implementation in hg-core, it's simpler to test
  for this condition in the bindings because the core methods take
  `impl IntoIterator`, and don't have this `is_empty` at disposal.
  
  As of this writing the core `add_common_revisions` can take non
  trivial time on an empty list.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  rust/hg-cpython/src/discovery.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -73,10 +73,14 @@
             }
         }
         let mut inner = self.inner(py).borrow_mut();
-        inner.add_common_revisions(common)
-            .map_err(|e| GraphError::pynew(py, e))?;
-        inner.add_missing_revisions(missing)
-            .map_err(|e| GraphError::pynew(py, e))?;
+        if !common.is_empty() {
+            inner.add_common_revisions(common)
+                .map_err(|e| GraphError::pynew(py, e))?;
+        }
+        if !missing.is_empty() {
+            inner.add_missing_revisions(missing)
+                .map_err(|e| GraphError::pynew(py, e))?;
+        }
         Ok(py.None())
     }
 



To: gracinet, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to