[Pkg-ocaml-maint-commits] r5882 - /trunk/tools/svn2git/glondu_svn2git.py
glondu-guest at users.alioth.debian.org
glondu-guest at users.alioth.debian.org
Thu Jul 24 10:30:39 UTC 2008
Author: glondu-guest
Date: Thu Jul 24 10:30:39 2008
New Revision: 5882
URL: http://svn.debian.org/wsvn/?sc=1&rev=5882
Log:
Approx-specific stuff
This is just for the record...
Modified:
trunk/tools/svn2git/glondu_svn2git.py
Modified: trunk/tools/svn2git/glondu_svn2git.py
URL: http://svn.debian.org/wsvn/trunk/tools/svn2git/glondu_svn2git.py?rev=5882&op=diff
==============================================================================
--- trunk/tools/svn2git/glondu_svn2git.py (original)
+++ trunk/tools/svn2git/glondu_svn2git.py Thu Jul 24 10:30:39 2008
@@ -21,7 +21,7 @@
svntag_re = re.compile(r"^\[svn-buildpackage\][^(]+\(([^)]+)\)$")
# Extract tag name from path
-svntag_path_re = r"^/(packages/%(pkg)s/tags|tags/packages/%(pkg)s)/([^/]+)"
+svntag_path_re = r"^/((packages|projects)/%(pkg)s/tags|tags/(packages|projects)/%(pkg)s)/([^/]+)"
# Extract local tarball path
svntgz_re = r"^/(packages/%(pkg)s/trunk|trunk/packages/%(pkg)s)/((upstream/|tarballs/|).*)$"
@@ -293,7 +293,7 @@
if action == "A":
m = svntag_path_re.match(file)
if m:
- tag_name = m.group(2)
+ tag_name = m.group(4)
if copyfrom:
rev = int(copyfrom.split("@")[1])
if parent_rev == None:
@@ -341,6 +341,69 @@
f.close()
print "OK!"
os.chdir("..")
+
+
+class GitCommitApprox(GitCommit):
+
+ prefixes = (
+ ("/packages/approx/trunk/", ""),
+ ("/projects/approx/trunk/", ""),
+ ("/trunk/projects/approx/trunk/", "trunk/"),
+ ("/trunk/projects/approx/", ""))
+
+
+ def export_sh(self):
+ print "echo Importing svn revision %d into git" % self.rev
+ print "( cd svn && svn update -r%d )" % self.rev
+ print "pushd git"
+ self.export_git_environment()
+ nb_upstream = 0
+ nb_debian = 0
+ working_dir = ""
+ for (action, file, copyfrom) in self.files:
+ if copyfrom:
+ print "# copyfrom %s to (%s) %s" % (copyfrom, action, file)
+ md = False
+ mu = False
+ for (prefix, wdir) in self.prefixes:
+ md = file.startswith(prefix + "debian/")
+ if not md:
+ mu = file.startswith(prefix)
+ if (md or mu) and action in ("M", "A", "R"):
+ if working_dir and working_dir != wdir:
+ print "# duplicate working dir for (%s) %s" % (action, file)
+ else:
+ working_dir = wdir
+ break
+ if "branch" in file:
+ print "# branch, take care: (%s) %s" % (action, file)
+ if md:
+ nb_debian += 1
+ elif mu:
+ nb_upstream += 1
+ else:
+ print "# do not know what to do with (%s) %s" % (action, file)
+ print "#- %d changes in upstream, %d changes in debian/" % (nb_upstream, nb_debian)
+ if nb_upstream:
+ print "git checkout upstream"
+ print "rsync -a --exclude=.svn --exclude='*.tar.gz' --exclude=debian --delete ../svn/%s ." % working_dir
+ print "git add ."
+ print "git add -u"
+ print ("git commit -m " + escape_for_shell(self.msg)).encode("utf-8")
+ if nb_debian:
+ print "git checkout master"
+ if nb_upstream:
+ print "git merge --no-commit upstream"
+ print "rsync -a --exclude=.svn --exclude='*.tar.gz' --delete ../svn/%sdebian ." % working_dir
+ print "git add ."
+ print "git add -u"
+ print ("git commit -m " + escape_for_shell(self.msg)).encode("utf-8")
+ if not (nb_upstream or nb_debian):
+ print "# nothing to commit"
+ for (action, file, x) in self.files:
+ print "# %s %s" % (action, file)
+ print ("# git commit -m " + escape_for_shell(self.msg).replace("\n", "\n# ")).encode("utf-8")
+ print "popd\n"
class Svn2Git:
@@ -426,6 +489,19 @@
dico.setdefault(svn, [])
dico[svn].append(git)
+ if xml and package_name == "approx":
+ print "# Needs manual tuning"
+ print "exit 3"
+ xml = parse(xml)
+ logentries = xml.getElementsByTagName("logentry")
+ for x in logentries:
+ commit = GitCommitApprox(x, None)
+ if dict_mode:
+ commit.find_commit()
+ else:
+ commit.export_sh()
+ sys.exit(0)
+
if xml:
xml = parse(xml)
logentries = xml.getElementsByTagName("logentry")
More information about the Pkg-ocaml-maint-commits
mailing list