Augie Fackler avatar Augie Fackler committed ea8ef4d Merge

Merge with stable.

Comments (0)

Files changed (3)

hgsubversion/svnmeta.py

         self.revmap = maps.RevMap(repo)
 
         author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
-        authors = self.ui.config('hgsubversion', 'authormap')
+        authors = util.configpath(self.ui, 'authormap')
         tag_locations = self.ui.configlist('hgsubversion', 'tagpaths', ['tags'])
         self.usebranchnames = self.ui.configbool('hgsubversion',
                                                  'usebranchnames', True)
-        branchmap = self.ui.config('hgsubversion', 'branchmap')
-        tagmap = self.ui.config('hgsubversion', 'tagmap')
-        filemap = self.ui.config('hgsubversion', 'filemap')
+        branchmap = util.configpath(self.ui, 'branchmap')
+        tagmap = util.configpath(self.ui, 'tagmap')
+        filemap = util.configpath(self.ui, 'filemap')
 
         self.branches = {}
         if os.path.exists(self.branch_info_file):

hgsubversion/util.py

         return '\t(working copy)'
     return '\t(revision %d)' % rev
 
+def configpath(ui, name):
+    path = ui.config('hgsubversion', name)
+    return path and hgutil.expandpath(path)
 
 def filterdiff(diff, oldrev, newrev):
     diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n'
             return cache[args]
 
     return f
+
+def parse_revnum(svnrepo, r):
+    try:
+        return int(r or 0)
+    except ValueError:
+        if isinstance(r, str) and r.lower() in ('head', 'tip'):
+            return svnrepo.last_changed_rev
+        else:
+            # TODO: use error.RepoLookupError when we drop 1.3?
+            raise hgutil.Abort("unknown Subversion revision %r" % r)

hgsubversion/wrappers.py

     old_encoding = util.swap_out_encoding()
     total = None
     try:
-        try:
-            stopat_rev = int(checkout or 0)
-        except ValueError:
-            raise hgutil.Abort('unrecognised Subversion revision %s: '
-                               'only numbers work.' % checkout)
-
         have_replay = not repo.ui.configbool('hgsubversion', 'stupid')
         if not have_replay:
             repo.ui.note('fetching stupidly...\n')
         svn = source.svn
         meta = repo.svnmeta(svn.uuid, svn.subdir)
 
+        stopat_rev = util.parse_revnum(svn, checkout)
+
         layout = repo.ui.config('hgsubversion', 'layout', 'auto')
         if layout == 'auto':
             try:
 
         if start <= 0:
             # we are initializing a new repository
-            start = repo.ui.config('hgsubversion', 'startrev', 0)
-            if isinstance(start, str) and start.upper() == 'HEAD':
-                start = svn.last_changed_rev
-            else:
-                start = int(start)
+            start = util.parse_revnum(svn, repo.ui.config('hgsubversion',
+                                                          'startrev', 0))
 
             if start > 0:
                 if layout == 'standard':
                 start = 0
 
         skiprevs = repo.ui.configlist('hgsubversion', 'unsafeskip', '')
-        try:
-            skiprevs = set(map(int, skiprevs))
-        except ValueError:
-            raise hgutil.Abort('unrecognised Subversion revisions %r: '
-                               'only numbers work.' % checkout)
+        skiprevs = set(util.parse_revnum(svn, r) for r in skiprevs)
 
         oldrevisions = len(meta.revmap)
         if stopat_rev:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.