diff options
Diffstat (limited to 'hgext/convert/git.py')
-rw-r--r-- | hgext/convert/git.py | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/hgext/convert/git.py b/hgext/convert/git.py index 8058399..e35e128 100644 --- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -16,7 +16,7 @@ class convert_git(converter_source): # Windows does not support GIT_DIR= construct while other systems # cannot remove environment variable. Just assume none have # both issues. - if util.safehasattr(os, 'unsetenv'): + if hasattr(os, 'unsetenv'): def gitopen(self, s, noerr=False): prevgitdir = os.environ.get('GIT_DIR') os.environ['GIT_DIR'] = self.path @@ -69,7 +69,7 @@ class convert_git(converter_source): def catfile(self, rev, type): if rev == hex(nullid): - raise IOError + raise IOError() data, ret = self.gitread("git cat-file %s %s" % (type, rev)) if ret: raise util.Abort(_('cannot read %r object at %s') % (type, rev)) @@ -97,8 +97,6 @@ class convert_git(converter_source): seen.add(f) entry = entry.split() h = entry[3] - if entry[1] == '160000': - raise util.Abort('git submodules are not supported!') p = (entry[1] == "100755") s = (entry[1] == "120000") self.modecache[(f, h)] = (p and "x") or (s and "l") or "" @@ -145,30 +143,20 @@ class convert_git(converter_source): def gettags(self): tags = {} - alltags = {} fh = self.gitopen('git ls-remote --tags "%s"' % self.path) prefix = 'refs/tags/' - - # Build complete list of tags, both annotated and bare ones for line in fh: line = line.strip() + if not line.endswith("^{}"): + continue node, tag = line.split(None, 1) if not tag.startswith(prefix): continue - alltags[tag[len(prefix):]] = node + tag = tag[len(prefix):-3] + tags[tag] = node if fh.close(): raise util.Abort(_('cannot read tags from %s') % self.path) - # Filter out tag objects for annotated tag refs - for tag in alltags: - if tag.endswith('^{}'): - tags[tag[:-3]] = alltags[tag] - else: - if tag + '^{}' in alltags: - continue - else: - tags[tag] = alltags[tag] - return tags def getchangedfiles(self, version, i): @@ -181,8 +169,8 @@ class convert_git(converter_source): m, f = l[:-1].split("\t") changes.append(f) else: - fh = self.gitopen('git diff-tree --name-only --root -r %s ' - '"%s^%s" --' % (version, version, i + 1)) + fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --' + % (version, version, i + 1)) changes = [f.rstrip('\n') for f in fh] if fh.close(): raise util.Abort(_('cannot read changes in %s') % version) @@ -211,7 +199,7 @@ class convert_git(converter_source): continue name = '%s%s' % (reftype, name[prefixlen:]) bookmarks[name] = rev - except Exception: + except: pass return bookmarks |