From 37ebbacd09145fa6bbaf54dac2a211a5d83f01a5 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Fri, 3 Jul 2015 15:05:03 +0100 Subject: Make branches and tags optional Some svn repos don't have a branches dir or a tags dir in their layout. This will for example allow us to lorry xmlto with the following lorry, { "xmlto": { "type": "svn", "url": "http://svn.fedorahosted.org/svn/xmlto", "layout": { "trunk": "." } } } Change-Id: I74c032ab7642f4b22ed0569b2a163c0b78cba658 --- README | 1 + lorry | 34 +++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README b/README index c9c116e..ad6cb9a 100644 --- a/README +++ b/README @@ -120,6 +120,7 @@ This is equivalent to Trunk is the path to the directory where the main branch is located. Branches and Tags are glob expressions to allow finer control over which paths are used. +Trunk is mandatory, but Branches and Tags are optional. Texlive keeps a lot of resources in their svn repository, we are only concerned with the source code, so this layout should select the correct subdirectory for each branch. diff --git a/lorry b/lorry index aa87d52..2759f54 100755 --- a/lorry +++ b/lorry @@ -436,15 +436,35 @@ class Lorry(cliapp.Application): # git-svn will convert branch, trunk and tag paths to allow this, # but it is simpler to disable it and do it manually self.run_program(['git', 'config', 'svn-remote.svn.fetch', - layout["trunk"]+':refs/heads/master'], - cwd=gitdir) - self.run_program(['git', 'config', 'svn-remote.svn.branches', - layout["branches"] + ':refs/heads/*'], - cwd=gitdir) - self.run_program(['git', 'config', 'svn-remote.svn.tags', - layout["tags"] + ':refs/tags/*'], + layout["trunk"] + ':refs/heads/master'], cwd=gitdir) + if 'branches' in layout: + self.run_program(['git', 'config', 'svn-remote.svn.branches', + layout["branches"] + ':refs/heads/*'], + cwd=gitdir) + else: + # try removing old config + try: + self.run_program(['git', 'config', '--unset', + 'svn-remote.svn.branches'], cwd=gitdir) + except Exception as e: + if '(exit code 5)' not in e.message: + raise + + if 'tags' in layout: + self.run_program(['git', 'config', 'svn-remote.svn.tags', + layout["tags"] + ':refs/tags/*'], + cwd=gitdir) + else: + # try removing old config + try: + self.run_program(['git', 'config', '--unset', + 'svn-remote.svn.tags'], cwd=gitdir) + except Exception as e: + if '(exit code 5)' not in e.message: + raise + # update the remote tracking branches self.run_program(['git', 'svn', 'fetch'], cwd=gitdir) -- cgit v1.2.1