Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/henon/GitSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
slluis committed Sep 1, 2010
2 parents 7fc563c + fed9535 commit dbd1326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 50 deletions.
17 changes: 3 additions & 14 deletions GitSharp.Core/GitSharp.Core.csproj
Expand Up @@ -19,23 +19,17 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\build\mono-2.0-debug\bin</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\GitSharp.Core.XML</DocumentationFile> <DocumentationFile>bin\Debug\GitSharp.Core.XML</DocumentationFile>
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
<CustomCommands>
<CustomCommands>
<Command type="BeforeBuild" command="nant -D:project.sources.path=${ProjectDir} init create-assembly-info" workingdir="${SolutionDir}" externalConsole="true" />
<Command type="AfterBuild" command="nant -D:project.sources.path=${ProjectDir} init cleanup-assembly-info" workingdir="${SolutionDir}" externalConsole="true" />
</CustomCommands>
</CustomCommands>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\build\mono-2.0-debug\bin</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
Expand All @@ -55,10 +49,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Tamir.SharpSSH.dll</HintPath> <HintPath>..\lib\Tamir.SharpSSH.dll</HintPath>
</Reference> </Reference>
<Reference Include="Winterdom.IO.FileMap, Version=2.0.2.0, Culture=neutral, PublicKeyToken=4982617362e1edb5">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Winterdom.IO.FileMap.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AbbreviatedObjectId.cs" /> <Compile Include="AbbreviatedObjectId.cs" />
Expand Down Expand Up @@ -379,7 +369,6 @@
<Compile Include="Util\RawCharSequence.cs" /> <Compile Include="Util\RawCharSequence.cs" />
<Compile Include="Util\RawSubstringPattern.cs" /> <Compile Include="Util\RawSubstringPattern.cs" />
<Compile Include="Util\TemporaryBuffer.cs" /> <Compile Include="Util\TemporaryBuffer.cs" />
<Compile Include="VersionAssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CachedObjectDirectory.cs" /> <Compile Include="CachedObjectDirectory.cs" />
Expand Down Expand Up @@ -442,4 +431,4 @@
</MonoDevelop> </MonoDevelop>
<VisualStudio /> <VisualStudio />
</ProjectExtensions> </ProjectExtensions>
</Project> </Project>
44 changes: 8 additions & 36 deletions GitSharp.Core/PackFile.cs
Expand Up @@ -46,7 +46,6 @@
using System.Linq; using System.Linq;
using GitSharp.Core.Exceptions; using GitSharp.Core.Exceptions;
using GitSharp.Core.Util; using GitSharp.Core.Util;
using Winterdom.IO.FileMap;


namespace GitSharp.Core namespace GitSharp.Core
{ {
Expand Down Expand Up @@ -470,43 +469,16 @@ internal ByteArrayWindow Read(long pos, int size)
IO.ReadFully(_fd, pos, buf, 0, size); IO.ReadFully(_fd, pos, buf, 0, size);
return new ByteArrayWindow(this, pos, buf); return new ByteArrayWindow(this, pos, buf);
} }


// Note: For now we are going to remove the dependency on Winterdom.IO.FileMap,
// since this isn't our default way of packing a file and there isn't any
// reason to invest in developing a cross-platform replacement. We're leaving
// the rest of the logic in place in case we decide to invest in
// this in the future. This was never tested thoroughly and caused
// tests to fail when it did run.
internal ByteWindow MemoryMappedByteWindow(long pos, int size) internal ByteWindow MemoryMappedByteWindow(long pos, int size)
{ {
if (Length < pos + size) throw new NotImplementedException();
{
size = (int) (Length - pos);
}

Stream map;

using (var _fdMap = MemoryMappedFile.Create(File.FullName, MapProtection.PageReadOnly))
{
try
{
map = _fdMap.MapView(MapAccess.FileMapRead, pos, size);
// was: map = _fd.map(MapMode.READ_ONLY, pos, size);
}
catch (IOException)
{
// The most likely reason this failed is the process has run out
// of virtual memory. We need to discard quickly, and try to
// force the GC to finalize and release any existing mappings.
//
GC.Collect();
GC.WaitForPendingFinalizers();
map = _fdMap.MapView(MapAccess.FileMapRead, pos, size);
}

byte[] mapArray = map != null ? map.toArray() : new byte[0];

if (mapArray.Length > 0)
{
return new ByteArrayWindow(this, pos, mapArray);
}
}

return new ByteBufferWindow(this, pos, map);
} }


private void OnOpenPack() private void OnOpenPack()
Expand Down

0 comments on commit dbd1326

Please sign in to comment.