mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
fix message stripping and malformed user info
This commit is contained in:
parent
3a40638749
commit
d92e94dad8
3
TODO.txt
3
TODO.txt
@ -4,13 +4,12 @@ GENERAL
|
||||
- hg push git@...
|
||||
- hg fetch [remote] (remote is url, hg alias or hg-git remote)
|
||||
- hg clone url
|
||||
|
||||
* file:/// support
|
||||
* work fine with eclipse plugin or tortoise-hg
|
||||
|
||||
MAPPING ISSUES
|
||||
==============
|
||||
* work in Git on a named branch created in Hg is forward-ported to be named branch commits in Hg and stripped back out if re-exported
|
||||
* timezone issues (?)
|
||||
|
||||
|
||||
REMOTE/BRANCH STUFF
|
||||
|
@ -1,4 +1,4 @@
|
||||
import os, errno, sys, time, datetime, pickle, copy, math, urllib
|
||||
import os, errno, sys, time, datetime, pickle, copy, math, urllib, re
|
||||
import toposort
|
||||
import dulwich
|
||||
from dulwich.repo import Repo
|
||||
@ -255,7 +255,20 @@ class GitHandler(object):
|
||||
|
||||
# hg authors might not have emails
|
||||
author = ctx.user()
|
||||
if not '>' in author:
|
||||
|
||||
# check for git author pattern compliance
|
||||
regex = re.compile('^(.*?) \<(.*?)\>(.*)$')
|
||||
a = regex.match(author)
|
||||
|
||||
if a:
|
||||
name = a.group(1)
|
||||
email = a.group(2)
|
||||
if len(a.group(3)) > 0:
|
||||
name += ' ext:(' + urllib.quote(a.group(3)) + ')'
|
||||
author = name + ' <' + email + '>'
|
||||
print "AUTHOR"
|
||||
print author
|
||||
else:
|
||||
author = author + ' <none@none>'
|
||||
commit['author'] = author + ' ' + str(int(time)) + ' ' + format_timezone(-timezone)
|
||||
message = ctx.description()
|
||||
@ -722,6 +735,16 @@ class GitHandler(object):
|
||||
|
||||
author = commit.author
|
||||
|
||||
# convert extra data back to the end
|
||||
if ' ext:' in commit.author:
|
||||
regex = re.compile('^(.*?)\ ext:\((.*)\) <(.*)\>$')
|
||||
m = regex.match(commit.author)
|
||||
if m:
|
||||
name = m.group(1)
|
||||
ex = urllib.unquote(m.group(2))
|
||||
email = m.group(3)
|
||||
author = name + ' <' + email + '>' + ex
|
||||
|
||||
if ' <none@none>' in commit.author:
|
||||
author = commit.author[:-12]
|
||||
|
||||
|
14
hgrepo.py
14
hgrepo.py
@ -91,13 +91,13 @@ class hgrepo(localrepo.localrepository):
|
||||
mn = self.manifest.add(m1, trp, linkrev, c1[0], c2[0],
|
||||
(new, removed1))
|
||||
|
||||
lines = [line.rstrip() for line in text.rstrip().splitlines()]
|
||||
while lines and not lines[0]:
|
||||
del lines[0]
|
||||
if not lines and use_dirstate:
|
||||
raise util.Abort(_("empty commit message"))
|
||||
text = '\n'.join(lines)
|
||||
|
||||
#lines = [line.rstrip() for line in text.rstrip().splitlines()]
|
||||
#while lines and not lines[0]:
|
||||
# del lines[0]
|
||||
#text = '\n'.join(lines)
|
||||
if text[-1] == "\n":
|
||||
text = text[:-1]
|
||||
|
||||
file_list = []
|
||||
if force_files == False:
|
||||
file_list = []
|
||||
|
Loading…
Reference in New Issue
Block a user