Skip to content

Commit

Permalink
Merge commit 'sinesignal/master'
Browse files Browse the repository at this point in the history
Conflicts:
	GitSharp.Core/GitSharp.Core.csproj
  • Loading branch information
henon committed Aug 31, 2010
2 parents 9f0756d + 12aaf54 commit 1d9a5fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 49 deletions.
16 changes: 3 additions & 13 deletions GitSharp.Core/GitSharp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,17 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\build\mono-2.0-debug\bin</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\GitSharp.Core.XML</DocumentationFile>
<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 Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\build\mono-2.0-debug\bin</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -55,10 +49,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Tamir.SharpSSH.dll</HintPath>
</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>
<Compile Include="AbbreviatedObjectId.cs" />
Expand Down Expand Up @@ -442,4 +432,4 @@
</MonoDevelop>
<VisualStudio />
</ProjectExtensions>
</Project>
</Project>
44 changes: 8 additions & 36 deletions GitSharp.Core/PackFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
using System.Linq;
using GitSharp.Core.Exceptions;
using GitSharp.Core.Util;
using Winterdom.IO.FileMap;

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);
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)
{
if (Length < pos + size)
{
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);
throw new NotImplementedException();
}

private void OnOpenPack()
Expand Down

0 comments on commit 1d9a5fc

Please sign in to comment.