Updated equality check for CommandInfo.

Review: https://reviews.apache.org/r/24658


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/30fdabe1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/30fdabe1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/30fdabe1

Branch: refs/heads/master
Commit: 30fdabe1a22dc1cf3f6d11a8161b4add47df02cf
Parents: 31a744e
Author: Jie Yu <yujie....@gmail.com>
Authored: Wed Aug 13 10:47:29 2014 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Wed Aug 13 11:33:36 2014 -0700

----------------------------------------------------------------------
 src/common/type_utils.cpp | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/30fdabe1/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index c8fc7b3..78bfa94 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -56,9 +56,9 @@ bool operator == (const CommandInfo& left, const CommandInfo& 
right)
     return false;
   }
 
-  for (int i=0; i<left.uris().size(); i++) {
+  for (int i = 0; i < left.uris().size(); i++) {
     bool found = false;
-    for (int j=0; j<right.uris().size(); j++) {
+    for (int j = 0; j < right.uris().size(); j++) {
       if (left.uris().Get(i) == right.uris().Get(j)) {
         found = true;
         break;
@@ -69,9 +69,23 @@ bool operator == (const CommandInfo& left, const 
CommandInfo& right)
     }
   }
 
+  if (left.argv().size() != right.argv().size()) {
+    return false;
+  }
+
+  // The order of argv is important.
+  for (int i = 0; i < left.argv().size(); i++) {
+    if (left.argv().Get(i) != right.argv().Get(i)) {
+      return false;
+    }
+  }
+
   return left.has_environment() == right.has_environment() &&
     (!left.has_environment() || (left.environment() == right.environment())) &&
-    left.value() == right.value();
+    left.has_value() == right.has_value() &&
+    (!left.has_value() || (left.value() == right.value())) &&
+    left.has_shell() == right.has_shell() &&
+    (!left.has_shell() || (left.shell() == right.shell()));
 }
 
 

Reply via email to