Skip to content

Instantly share code, notes, and snippets.

@undees
Created May 5, 2009 18:16
Show Gist options
  • Save undees/107094 to your computer and use it in GitHub Desktop.
Save undees/107094 to your computer and use it in GitHub Desktop.
# HG changeset patch
# User Ian Dees <[email protected]>
# Date 1241546103 25200
# Node ID 8ebccd5ebc948ea846a858755a96742661e84431
# Parent dce9bf3609fe5eea3085fbd0ee1a12717794dc9a
Tolerate some committer e-mail weirdness in original repo
diff --git a/git_handler.py b/git_handler.py
--- a/git_handler.py
+++ b/git_handler.py
@@ -1,4 +1,4 @@
-import os, errno, sys, time, datetime, pickle, copy
+import os, errno, sys, time, datetime, pickle, copy, string
import toposort
import dulwich
from dulwich.repo import Repo
@@ -6,7 +6,7 @@
from hgext import bookmarks
from mercurial.i18n import _
from mercurial.node import bin, hex, nullid
-from mercurial import hg, util, context, error
+from mercurial import hg, util, context, error, util
from dulwich.objects import (
Blob,
Commit,
@@ -539,7 +539,21 @@
date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S")
ctx = context.memctx(self.repo, (p1, p2), text, files, getfilectx,
commit.author, date, extra)
- a = self.repo.commitctx(ctx)
+
+ try:
+ self.repo.commitctx(ctx)
+ except util.Abort, e:
+ author = ''.join([s for s in commit.author if s in string.printable])
+
+ if author != commit.author:
+ print("Warning: commit aborted, possibly due to non-printing characters.")
+ print("Author name: " + commit.author)
+ print("Retrying with: " + author)
+ ctx = context.memctx(self.repo, (p1, p2), text, files, getfilectx,
+ author, date, extra)
+ self.repo.commitctx(ctx)
+ else:
+ raise
# get changeset id
p2 = hex(self.repo.changelog.tip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment