diff --git a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php --- a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php +++ b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php @@ -188,7 +188,7 @@ if ($this_version) { $this_version = (int)$this_version->getRepositoryVersion(); } else { - $this_version = -1; + $this_version = null; } if ($versions) { @@ -197,7 +197,7 @@ // leader, we want to fetch from a leader and then update our version. $max_version = (int)max(mpull($versions, 'getRepositoryVersion')); - if ($max_version > $this_version) { + if (($this_version === null) || ($max_version > $this_version)) { if ($repository->isHosted()) { $fetchable = array(); foreach ($versions as $version) { @@ -206,6 +206,7 @@ } } + $this->synchronizeWorkingCopyFromDevices( $fetchable, $this_version, @@ -445,10 +446,10 @@ if ($this_version) { $this_version = (int)$this_version->getRepositoryVersion(); } else { - $this_version = -1; + $this_version = null; } - if ($new_version > $this_version) { + if (($this_version === null) || ($new_version > $this_version)) { PhabricatorRepositoryWorkingCopyVersion::updateVersion( $repository_phid, $device_phid,