Page MenuHomePhabricator
Authored By
argylelabcoat
Mar 24 2015, 2:38 AM
Size
3 KB
Referenced Files
None
Subscribers
None

largefiles-ext.patch

diff --git a/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php b/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
index 578196f..1ef5043 100644
--- a/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
+++ b/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
@@ -25,6 +25,9 @@ final class DiffusionMercurialWireProtocol {
'pushkey' => array('namespace', 'key', 'old', 'new'),
'stream_out' => array(''),
'unbundle' => array('heads'),
+ 'putlfile' => array('sha'),
+ 'getlfile' => array('sha'),
+ 'statlfile' => array('sha')
);
if (!isset($commands[$command])) {
@@ -50,6 +53,8 @@ final class DiffusionMercurialWireProtocol {
'listkeys' => true,
'lookup' => true,
'stream_out' => true,
+ 'getlfile' => true,
+ 'statlfile' => true
);
// Notably, the write commands are "pushkey" and "unbundle". The
diff --git a/src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php b/src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
index e82a62a..fd9cd4c 100644
--- a/src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
+++ b/src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
@@ -103,9 +103,18 @@ final class DiffusionMercurialWireClientSSHProtocolChannel
$args = DiffusionMercurialWireProtocol::getCommandArgs($this->command);
$have = array_select_keys($this->arguments, $args);
if (count($have) == count($args)) {
+
+ $command = $this->command;
+
// We have all the arguments. Emit a message and read the next
// command.
$messages[] = $this->newMessageAndResetState();
+
+ if ($command == 'putlfile') {
+ $this->command = '<raw-data>';
+ $this->state = 'large-file-length';
+ break;
+ }
} else {
// We're still reading arguments. They can either look like:
//
@@ -206,6 +215,33 @@ final class DiffusionMercurialWireClientSSHProtocolChannel
// to us so far.
break;
}
+ } else if ($this->state == 'large-file-length') {
+
+ // We're reading a file contents. It looks like:
+ //
+ // <length(value)>
+ // <value>
+ // ...
+ // <0>
+
+ $line = $this->readProtocolLine();
+ if ($line === null) {
+ break;
+ }
+ $this->expectBytes = (int)$line;
+ if (!$this->expectBytes) {
+ $messages[] = $this->newMessageAndResetState();
+ } else {
+ $this->state = 'large-file-bytes';
+ }
+
+ } else if ($this->state == 'large-file-bytes') {
+
+ $bytes = $this->readProtocolBytes();
+ if ($bytes === null) {
+ break;
+ }
+ $this->state = 'large-file-length';
} else {
throw new Exception("Bad parser state '{$this->state}'!");
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/2z/fa/rjb4ewbt3kcly7r2
Default Alt Text
largefiles-ext.patch (3 KB)

Event Timeline