Skip to contentSkip to conversation

git-p4: add support for large file systems

PATCH Superseded [email protected] 2 participants 7 messages Jun 15, 2016 Documentation

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover git-p4: add support for large file systems

From: Lars Schneider <[email protected]>

Diff to v2:
* add proper commit messages
* split commits into generic large file system and GitLFS implementation
* improve docs, mention clean/smduge filter and add example for clean checkout
* fix spelling
* add option to push large files to server
* use ValueError for gitConfigInt exception
* assert required functions for large file system classes
* rename LFS to GitLFS
* add Python docs for GitLFS class
* move generic code from GitLFS class to git-p4 main code
* make variable that keeps large files for .gitattributes creation a set() to avoid duplicated entries
* sort large files in .gitattirubutes to minimize diffs between commits

Thanks to Luke and Junio for feedback!

One thing I don't like about the current implementation is that I don't see a way to test the "git-p4.pushLargeFiles" config. I could start a git lfs server locally but that seems a bit too much, no?

Thanks,
Lars

Lars Schneider (5):
git-p4: add optional type specifier to gitConfig reader
git-p4: add gitConfigInt reader
git-p4: return an empty list if a list config has no values
git-p4: add support for large file systems
git-p4: add Git LFS backend for large file system

 Documentation/git-p4.txt |  28 +++++
 git-p4.py                | 187 ++++++++++++++++++++++++++++++---
 t/t9823-git-p4-lfs.sh    | 263 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 465 insertions(+), 13 deletions(-)
 create mode 100755 t/t9823-git-p4-lfs.sh

--
2.5.1

#1 lore raw

PATCH v3 1/5 git-p4: add optional type specifier to gitConfig reader

From: Lars Schneider <[email protected]>

The functions “gitConfig” and “gitConfigBool” are almost identical. Make “gitConfig” more generic by adding an optional type specifier. Use the type specifier “—bool” with “gitConfig” to implement “gitConfigBool. This prepares the implementation of other type specifiers such as “—int”.

---
 git-p4.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
git-p4.py +6 -6
index 073f87b..c139cab 100755
@@ -604,9 +604,12 @@ def gitBranchExists(branch):
 
 _gitConfig = {}
 
-def gitConfig(key):
+def gitConfig(key, typeSpecifier=None):
     if not _gitConfig.has_key(key):
-        cmd = [ "git", "config", key ]
+        cmd = [ "git", "config" ]
+        if typeSpecifier:
+            cmd += [ typeSpecifier ]
+        cmd += [ key ]
         s = read_pipe(cmd, ignore_error=True)
         _gitConfig[key] = s.strip()
     return _gitConfig[key]
@@ -617,10 +620,7 @@ def gitConfigBool(key):
        in the config."""
 
     if not _gitConfig.has_key(key):
-        cmd = [ "git", "config", "--bool", key ]
-        s = read_pipe(cmd, ignore_error=True)
-        v = s.strip()
-        _gitConfig[key] = v == "true"
+        _gitConfig[key] = gitConfig(key, '--bool') == "true"
     return _gitConfig[key]
 
 def gitConfigList(key):
Signature · 1 line
2.5.1
#2 lore raw

PATCH v3 2/5 git-p4: add gitConfigInt reader

In reply to [email protected]

From: Lars Schneider <[email protected]>

Add a git config reader for integer variables. Please note that the git config implementation automatically supports k, m, and g suffixes.

---
 git-p4.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
git-p4.py +11 -0
index c139cab..40ad4ae 100755
@@ -623,6 +623,17 @@ def gitConfigBool(key):
         _gitConfig[key] = gitConfig(key, '--bool') == "true"
     return _gitConfig[key]
 
+def gitConfigInt(key):
+    if not _gitConfig.has_key(key):
+        cmd = [ "git", "config", "--int", key ]
+        s = read_pipe(cmd, ignore_error=True)
+        v = s.strip()
+        try:
+            _gitConfig[key] = int(gitConfig(key, '--int'))
+        except ValueError:
+            _gitConfig[key] = None
+    return _gitConfig[key]
+
 def gitConfigList(key):
     if not _gitConfig.has_key(key):
         s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)
Signature · 1 line
2.5.1
#3 lore raw

PATCH v3 3/5 git-p4: return an empty list if a list config has no values

In reply to [email protected]

From: Lars Schneider <[email protected]>

---
 git-p4.py | 2 ++
 1 file changed, 2 insertions(+)
git-p4.py +2 -0
index 40ad4ae..90d3b90 100755
@@ -638,6 +638,8 @@ def gitConfigList(key):
     if not _gitConfig.has_key(key):
         s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)
         _gitConfig[key] = s.strip().split(os.linesep)
+        if _gitConfig[key] == ['']:
+            _gitConfig[key] = []
     return _gitConfig[key]
 
 def p4BranchesInGit(branchesAreInRemotes=True):
Signature · 1 line
2.5.1
#4 lore raw

PATCH v3 4/5 git-p4: add support for large file systems

In reply to [email protected]

From: Lars Schneider <[email protected]>

Perforce repositories can contain large (binary) files. Migrating these repositories to Git generates very large local clones. External storage systems such as Git LFS [1], Git Fat [2], or Git Media [2] try to address this problem.

Add a generic mechanism to detect large files based on extension, uncompressed size, and/or compressed size.

[1] https://git-lfs.github.com/
[2] https://github.com/jedbrown/git-fat
[3] https://github.com/alebedev/git-media

---
 Documentation/git-p4.txt |  26 +++++++++++
 git-p4.py                | 114 +++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 131 insertions(+), 9 deletions(-)
Documentation/git-p4.txt +26 -0
index 82aa5d6..e0d0239 100644
@@ -510,6 +510,32 @@ git-p4.useClientSpec::
 	option '--use-client-spec'.  See the "CLIENT SPEC" section above.
 	This variable is a boolean, not the name of a p4 client.
 
+git-p4.largeFileSystem::
+	Specify the system that is used used for large (binary) files.
+	Please note that most of these large file systems depend on the
+	Git clean/smudge filters. These filters are not applied through
+	git-p4. You need to create a fresh clone of the repository after
+	running git-p4.
+
+git-p4.largeFileExtensions::
+	All files matching a file extension in the list will be processed
+	by the large file system. Do not prefix the extensions with '.'.
+
+git-p4.largeFileThreshold::
+	All files with an uncompressed size exceeding the threshold will be
+	processed by the large file system. By default the threshold is
+	defined in bytes. Add the suffix k, m, or g to change the unit.
+
+git-p4.largeFileCompressedThreshold::
+	All files with a compressed size exceeding the threshold will be
+	processed by the large file system. This option might significantly
+	slow down your clone/sync process. By default the threshold is
+	defined in bytes. Add the suffix k, m, or g to change the unit.
+
+git-p4.pushLargeFiles::
+	Boolean variable which defines if large files are automatically
+	pushed to a server.
+
 Submit variables
 ~~~~~~~~~~~~~~~~
 git-p4.detectRenames::
git-p4.py +105 -9

152 lines not on this page · raw message

Signature · 1 line
2.5.1
#5 lore raw

PATCH v3 5/5 git-p4: add Git LFS backend for large file system

In reply to [email protected]

From: Lars Schneider <[email protected]>

Add example implementation including test cases for the large file system using Git LFS.

Pushing files to the Git LFS server is not tested.

---
 Documentation/git-p4.txt |   4 +-
 git-p4.py                |  52 ++++++++++
 t/t9823-git-p4-lfs.sh    | 263 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 318 insertions(+), 1 deletion(-)
 create mode 100755 t/t9823-git-p4-lfs.sh
Documentation/git-p4.txt +3 -1
index e0d0239..3168a64 100644
@@ -515,7 +515,9 @@ git-p4.largeFileSystem::
 	Please note that most of these large file systems depend on the
 	Git clean/smudge filters. These filters are not applied through
 	git-p4. You need to create a fresh clone of the repository after
-	running git-p4.
+	running git-p4. Only Git LFS [1] is supported right now. Download
+	and install the Git LFS command line extension to use this option.
+	[1] https://git-lfs.github.com/
 
 git-p4.largeFileExtensions::
 	All files matching a file extension in the list will be processed
git-p4.py +52 -0

58 lines not on this page · raw message

t/t9823-git-p4-lfs.sh new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
2.5.1
#6 lore raw
In reply to [email protected]
Quoted 5 lines · On 7 September 2015 at 13:21, <[email protected]> wrote:

From: Lars Schneider <[email protected]>

One thing I don't like about the current implementation is that I don't see a way to test the "git-p4.pushLargeFiles" config. I could start a git lfs server locally but that seems a bit too much, no?

Perhaps add a trivial large-file derived class that just does enough to show that it's all working. Then the final bit of pushing the large files to LFS would remain forever untested, but it would be small enough and simple enough not to be a real problem. If it ever broke, it would indicate that either the trivial test class was a bit too trivial, or that the abstraction was not abstract enough and there's too much common-code in the derived classes.

Luke