Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/DataAccessProvider.java @ 584:ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 25 Apr 2013 16:08:17 +0200 |
| parents | dd4f6311af52 |
| children | 5daa42067e7c |
comparison
equal
deleted
inserted
replaced
| 583:47dfa0ec7e35 | 584:ed243b668502 |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010-2012 TMate Software Ltd | 2 * Copyright (c) 2010-2013 TMate Software Ltd |
| 3 * | 3 * |
| 4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
| 5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
| 6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
| 7 * | 7 * |
| 52 private static final int DEFAULT_MAPIO_BUFFER = DEFAULT_MAPIO_LIMIT; // same as default boundary | 52 private static final int DEFAULT_MAPIO_BUFFER = DEFAULT_MAPIO_LIMIT; // same as default boundary |
| 53 | 53 |
| 54 private final int mapioMagicBoundary; | 54 private final int mapioMagicBoundary; |
| 55 private final int bufferSize, mapioBufSize; | 55 private final int bufferSize, mapioBufSize; |
| 56 private final SessionContext context; | 56 private final SessionContext context; |
| 57 | 57 // not the right place for the property, but DAP is the only place currently available to RevlogStream to get the value |
| 58 private final boolean shallMergePatches; | |
| 59 | |
| 58 public DataAccessProvider(SessionContext ctx) { | 60 public DataAccessProvider(SessionContext ctx) { |
| 59 context = ctx; | 61 context = ctx; |
| 60 PropertyMarshal pm = new PropertyMarshal(ctx); | 62 PropertyMarshal pm = new PropertyMarshal(ctx); |
| 61 mapioMagicBoundary = mapioBoundaryValue(pm.getInt(CFG_PROPERTY_MAPIO_LIMIT, DEFAULT_MAPIO_LIMIT)); | 63 mapioMagicBoundary = mapioBoundaryValue(pm.getInt(CFG_PROPERTY_MAPIO_LIMIT, DEFAULT_MAPIO_LIMIT)); |
| 62 bufferSize = pm.getInt(CFG_PROPERTY_FILE_BUFFER_SIZE, DEFAULT_FILE_BUFFER); | 64 bufferSize = pm.getInt(CFG_PROPERTY_FILE_BUFFER_SIZE, DEFAULT_FILE_BUFFER); |
| 63 mapioBufSize = pm.getInt(CFG_PROPERTY_MAPIO_BUFFER_SIZE, DEFAULT_MAPIO_BUFFER); | 65 mapioBufSize = pm.getInt(CFG_PROPERTY_MAPIO_BUFFER_SIZE, DEFAULT_MAPIO_BUFFER); |
| 66 shallMergePatches = pm.getBoolean(Internals.CFG_PROPERTY_PATCH_MERGE, false); | |
| 64 } | 67 } |
| 65 | 68 |
| 66 public DataAccessProvider(SessionContext ctx, int mapioBoundary, int regularBufferSize, int mapioBufferSize) { | 69 public DataAccessProvider(SessionContext ctx, int mapioBoundary, int regularBufferSize, int mapioBufferSize) { |
| 67 context = ctx; | 70 context = ctx; |
| 68 mapioMagicBoundary = mapioBoundaryValue(mapioBoundary); | 71 mapioMagicBoundary = mapioBoundaryValue(mapioBoundary); |
| 69 bufferSize = regularBufferSize; | 72 bufferSize = regularBufferSize; |
| 70 mapioBufSize = mapioBufferSize; | 73 mapioBufSize = mapioBufferSize; |
| 74 shallMergePatches = new PropertyMarshal(ctx).getBoolean(Internals.CFG_PROPERTY_PATCH_MERGE, false); | |
| 75 } | |
| 76 | |
| 77 // TODO [post-1.1] find a better place for this option, it's unrelated to the DAP | |
| 78 public boolean shallMergePatches() { | |
| 79 return shallMergePatches; | |
| 71 } | 80 } |
| 72 | 81 |
| 73 // ensure contract of CFG_PROPERTY_MAPIO_LIMIT, for mapioBoundary == 0 use MAX_VALUE so that no file is memmap-ed | 82 // ensure contract of CFG_PROPERTY_MAPIO_LIMIT, for mapioBoundary == 0 use MAX_VALUE so that no file is memmap-ed |
| 74 private static int mapioBoundaryValue(int mapioBoundary) { | 83 private static int mapioBoundaryValue(int mapioBoundary) { |
| 75 return mapioBoundary == 0 ? Integer.MAX_VALUE : mapioBoundary; | 84 return mapioBoundary == 0 ? Integer.MAX_VALUE : mapioBoundary; |
