Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F169778
largefiles-ext.patch
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Dmitry.Sokolov
Jun 24 2014, 7:38 PM
2014-06-24 19:38:27 (UTC+0)
Size
4 KB
Referenced Files
None
Subscribers
None
largefiles-ext.patch
View Options
diff --git a/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php b/src/applications/diffusion/protocol/DiffusionMercurialWireProtocol.php
index 578196f..1964392 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/DiffusionSSHMercurialWireClientProtocolChannel.php b/src/applications/diffusion/ssh/DiffusionSSHMercurialWireClientProtocolChannel.php
index ab0a62b..9f78472 100644
--- a/src/applications/diffusion/ssh/DiffusionSSHMercurialWireClientProtocolChannel.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHMercurialWireClientProtocolChannel.php
@@ -84,6 +84,7 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
while (true) {
if ($this->state == 'command') {
+
$this->initializeState();
// We're reading a command. It looks like:
@@ -97,15 +98,25 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
$this->command = $line;
$this->state = 'arguments';
+
} else if ($this->state == 'arguments') {
// Check if we're still waiting for arguments.
$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:
//
@@ -138,6 +149,7 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
$this->state = 'argv';
}
}
+
} else if ($this->state == 'value' || $this->state == 'argv-value') {
// We're reading the value of an argument. We just need to wait for
@@ -156,7 +168,6 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
$this->state = 'arguments';
}
-
} else if ($this->state == 'argv') {
// We're reading a variable number of arguments. We need to wait for
@@ -179,7 +190,9 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
} else {
$this->state = 'arguments';
}
+
} else if ($this->state == 'data-length') {
+
$line = $this->readProtocolLine();
if ($line === null) {
break;
@@ -191,7 +204,9 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
} else {
$this->state = 'data-bytes';
}
+
} else if ($this->state == 'data-bytes') {
+
$bytes = substr($this->buffer, 0, $this->expectBytes);
$this->buffer = substr($this->buffer, strlen($bytes));
$this->expectBytes -= strlen($bytes);
@@ -206,6 +221,35 @@ final class DiffusionSSHMercurialWireClientProtocolChannel
// 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
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/ab/nv/a6gmuuswgzzvuumf
Default Alt Text
largefiles-ext.patch (4 KB)
Attached To
Mode
T5189: Can't push to a Mercurial repository hosted by Phabricator when the Lagrefiles extension is on.
Attached
Detach File
Event Timeline
Log In to Comment