comparison hgext/convert/common.py @ 19120:58e782f076e7

splicemap: improve error handling when source is hg (issue2084) 1. Introduced 2 levels of error handling for splicemap files a. Check the splicemap file for rules which are same across different types of source repos. This is done through enhancing parsesplicemap function b. Check revision string formats. Each repo may have their own format. This is done usign checkrevformat function c. Implemented the above two for hg
author Ben Goswami <bengoswami@fb.com>
date Thu, 25 Apr 2013 11:50:26 -0700
parents 61f1223ab358
children 83973dc1bfe9
comparison
equal deleted inserted replaced
19119:61f1223ab358 19120:58e782f076e7
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others 3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 import base64, errno, subprocess, os, datetime 8 import base64, errno, subprocess, os, datetime, re
9 import cPickle as pickle 9 import cPickle as pickle
10 from mercurial import util 10 from mercurial import util
11 from mercurial.i18n import _ 11 from mercurial.i18n import _
12 12
13 propertycache = util.propertycache 13 propertycache = util.propertycache
61 self.path = path 61 self.path = path
62 self.rev = rev 62 self.rev = rev
63 63
64 self.encoding = 'utf-8' 64 self.encoding = 'utf-8'
65 65
66 def checkhexformat(self, revstr):
67 """ fails if revstr is not a 40 byte hex. mercurial and git both uses
68 such format for their revision numbering
69 """
70 matchobj = re.match(r'[0-9a-fA-F]{40,40}$', revstr)
71 if matchobj is None:
72 raise util.Abort(_('splicemap entry %s is not a valid revision'
73 ' identifier') % revstr)
74
66 def before(self): 75 def before(self):
67 pass 76 pass
68 77
69 def after(self): 78 def after(self):
70 pass 79 pass
161 """Return the bookmarks as a dictionary of name: revision 170 """Return the bookmarks as a dictionary of name: revision
162 171
163 Bookmark names are to be UTF-8 strings. 172 Bookmark names are to be UTF-8 strings.
164 """ 173 """
165 return {} 174 return {}
175
176 def checkrevformat(self, revstr):
177 """revstr is a string that describes a revision in the given
178 source control system. Return true if revstr has correct
179 format.
180 """
181 return True
166 182
167 class converter_sink(object): 183 class converter_sink(object):
168 """Conversion sink (target) interface""" 184 """Conversion sink (target) interface"""
169 185
170 def __init__(self, ui, path): 186 def __init__(self, ui, path):