]> xenbits.xensource.com Git - people/larsk/xenproject-org-gitdm.git/commitdiff
Added workaround for svn tags imported wrongly
authorGermán Póo-Caamaño <gpoo@gnome.org>
Thu, 23 Jun 2011 02:15:59 +0000 (19:15 -0700)
committerGermán Póo-Caamaño <gpoo@gnome.org>
Thu, 23 Jun 2011 02:27:47 +0000 (19:27 -0700)
When some projects have migrated from Subversion to Git, there
were several tags that were treated as new commits, which shows
a change in the whole project (code added/removed) when nothing
really happened.  For instance, in GNOME a lot svn tags were
catched during the migration, but not all of them.

svn tags in git repositories brings bad stats because double count
commits, and in project with a lot history it may may involve several thousands of source of lines of code.

Signed-off-by: Germán Póo-Caamaño <gpoo@gnome.org>
gitdm
patterns.py

diff --git a/gitdm b/gitdm
index fe5473c10eb9426d8065ebf0947f236370767ad3..28df3148ef1233bef11bc8603e49f0b56dcb6eed 100755 (executable)
--- a/gitdm
+++ b/gitdm
@@ -341,6 +341,22 @@ def ApplyFileFilter (line, ignore):
             return 0
     return ignore
 
+def is_svntag(logpatch):
+    """
+        This is a workaround for a bug on the migration to Git
+        from Subversion found in GNOME.  It may happen in other
+        repositories as well.
+    """
+
+    for Line in logpatch:
+        m = patterns['svn-tag'].match(Line.strip())
+        if m:
+            sys.stderr.write ('(W) detected a commit on a svn tag: %s\n' %
+                              (m.group (0),))
+            return True
+
+    return False
+
 #
 # If this patch is signed off by both Andrew Morton and Linus Torvalds,
 # remove the (redundant) Linus signoff.
@@ -384,6 +400,15 @@ for logpatch in patches:
     if (printcount % 50) == 0:
         print >> sys.stderr, 'Grabbing changesets...%d\r' % printcount,
     printcount += 1
+
+    # We want to ignore commits on svn tags since in Subversion
+    # thats mean a copy of the whole repository, which leads to
+    # wrong results.  Some migrations from Subversion to Git does
+    # not catch all this tags/copy and import them just as a new
+    # big changeset.
+    if is_svntag(logpatch):
+        continue
+
     p = grabpatch(logpatch)
     if not p:
         break
index b679049423d9bca4316a7932f78df62699376b30..803e532782c0aa6849ec7d5558b0cbe401be5879 100644 (file)
@@ -46,4 +46,6 @@ patterns = {
     # It implies --numstat
     'numstat': re.compile('^(\d+|-)\s+(\d+|-)\s+(.*)$'),
     'rename' : re.compile('(.*)\{(.*) => (.*)\}(.*)'),
+    # Detect errors on svn conversions
+    'svn-tag': re.compile("^svn path=/tags/(.*)/?; revision=([0-9]+)$"),
 }