In my concept every FreeCAD file has its own branch. It uses the python library dulwich, which implements the handling of git objects. The source is available at https://gist.github.com/5263/0f1554decb1cd329f4ee
Code: Select all
import zip2git
#create a new file and save it once using the gui to set the path
>>> App.getDocument("Unnamed2").saveAs("/home/username/freecad/newfile1.fcstd")
>>> zip2git.saveandcommit(FreeCAD.ActiveDocument,'../freecad')
#../freecad is the path to an existing (empty) git repo
Code: Select all
$ git log --pretty=fuller --stat newfile1
commit 42a602c2724028a66eb2ff929d274d7bea403aec
Author: unkown <unknown>
AuthorDate: Wed Dec 3 18:46:10 2014 +0000
Commit: shoogen <shoogen@forum.freecadweb.org>
CommitDate: Wed Dec 3 17:46:10 2014 +0000
New FreeCAD Document newfile1
UUID: ed7d9934-eb2d-4b80-aeca-98be58cc6bb2
CreationDate: Wed Dec 3 18:43:54 2014
FileName: /home/username/freecad/newfile1.fcstd
Label: newfile1
LastModifiedDate: Wed Dec 3 18:46:10 2014
License: CC-BY 3.0
LicenseURL: http://creativecommons.org/licenses/by/3.0/
DiffuseColor | Bin 0 -> 8 bytes
Document.xml | 79 +++++++++++++++
GuiDocument.xml | 64 +++++++++++++
PartShape.brp | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 430 insertions(+)
Code: Select all
>>> zip2git.saveandcommit(FreeCAD.ActiveDocument,'../freecad')
Code: Select all
commit af3187c35e728a48dd9782847bb349c4eee9fa1a
Author: shoogen <unknown>
AuthorDate: Wed Dec 3 19:00:57 2014 +0000
Commit: shoogen <shoogen@forum.freecadweb.org>
CommitDate: Wed Dec 3 18:00:57 2014 +0000
Updated FreeCAD Document newfile1
UUID: ed7d9934-eb2d-4b80-aeca-98be58cc6bb2
Comment: it's a box 10mm x 10mm x 10 mm
Company: ACME Inc.
CreatedBy: shoogen
CreationDate: Wed Dec 3 18:43:54 2014
FileName: /home/username/freecad/newfile1.fcstd
Label: newfile1
LastModifiedBy: shoogen
LastModifiedDate: Wed Dec 3 19:00:57 2014
License: MIT License
LicenseURL: http://opensource.org/licenses/MIT
Document.xml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
commit 42a602c2724028a66eb2ff929d274d7bea403aec
[...]
Next i just changed the placement of the first PartFeature
Code: Select all
$ git show --pretty=short --stat newfile1
commit 22596a24022a487df8d3c859c2eb7a75bc3d5c77
Author: shoogen <unknown>
Updated FreeCAD Document newfile1
Document.xml | 4 ++--
PartShape.brp | 18 +++++++++---------
2 files changed, 11 insertions(+), 11 deletions(-)
To load the latest version form the repo use
Code: Select all
>>> zip2git.checkoutandload('newfile1','../freecad')
Of course the files could be extracted by any git tool and assembled to a FCStd file using the ProjectUtility in FreeCAD.