# HG changeset patch # User Augie Fackler # Date 1521925459 14400 # Node ID ae572c9be4e618023cb7c95d1e2fec447b2e98a2 # Parent dd409375c26193407b96f3b26aec79aeae066417 cleanup: remove lots of dead imports and code found by pyflakes diff --git a/hgsubversion/__init__.py b/hgsubversion/__init__.py --- a/hgsubversion/__init__.py +++ b/hgsubversion/__init__.py @@ -18,8 +18,6 @@ For more information and instructions, s testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4' import os -import sys -import traceback from mercurial import commands try: @@ -368,23 +366,3 @@ def svnuuidkw(**args): return _templatehelper(args['ctx'], 'svnuuid') loadkeyword(templatekeyword) - -def listsvnkeys(repo): - keys = {} - repo = repo.local() - metadir = os.path.join(repo.path, 'svn') - - if util.subversionmetaexists(repo.path): - w = repo.wlock() - try: - for key in util.pushkeyfiles: - fullpath = os.path.join(metadir, key) - if os.path.isfile(fullpath): - data = open(fullpath).read() - - # Some of the files could be large, but also quite compressible - keys[key] = base85.b85encode(zlib.compress(data)) - finally: - w.release() - - return keys diff --git a/hgsubversion/editor.py b/hgsubversion/editor.py --- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -633,7 +633,7 @@ class HgEditor(svnwrap.Editor): nodes = {} for path, copy in self._svncopies.iteritems(): nodes.setdefault(copy.node, []).append((path, copy)) - for node, copies in nodes.iteritems(): + for unused_node, copies in nodes.iteritems(): for path, copy in copies: data, isexec, islink, copied = copy.resolve(self._getctx) self.current.set(path, data, isexec, islink, copied) diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -7,7 +7,6 @@ import os import re import sqlite3 import sys -import weakref from mercurial import error from mercurial import util as hgutil from mercurial.node import bin, hex, nullid diff --git a/hgsubversion/pushmod.py b/hgsubversion/pushmod.py --- a/hgsubversion/pushmod.py +++ b/hgsubversion/pushmod.py @@ -142,7 +142,6 @@ def commit(ui, repo, rev_ctx, meta, base props.setdefault(file, {}).update(autoprops) action = 'add' - dirname = '/'.join(file.split('/')[:-1] + ['']) else: base_data = parent.filectx(file).data() if ('x' in parent.filectx(file).flags() diff --git a/hgsubversion/replay.py b/hgsubversion/replay.py --- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -5,7 +5,6 @@ from mercurial import error as hgerror from mercurial import revlog from mercurial import node from mercurial import context -from mercurial import util as hgutil import compathacks import svnexternals @@ -212,7 +211,6 @@ def _convert_rev(ui, meta, svn, r, tbdel if ha == node.nullid: continue - parent_ctx = meta.repo.changectx(ha) files = [] def del_all_files(*args): raise IOError(errno.ENOENT, 'deleting all files') diff --git a/hgsubversion/stupid.py b/hgsubversion/stupid.py --- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -7,7 +7,6 @@ from mercurial import error as hgerror from mercurial import node from mercurial import patch from mercurial import revlog -from mercurial import util as hgutil import compathacks import svnwrap @@ -645,14 +644,13 @@ def convert_rev(ui, meta, svn, r, tbdelt branches = branches_in_paths(meta, tbdelta, r.paths, r.revnum, svn.checkpath, svn.list_files, firstrun) - brpaths = branches.values() bad_branch_paths = {} for br, bp in branches.iteritems(): bad_branch_paths[br] = [] # This next block might be needed, but for now I'm omitting it until it # can be proven necessary. - # for bad in brpaths: + # for bad in branches.values(): # if bad.startswith(bp) and len(bad) > len(bp): # bad_branch_paths[br].append(bad[len(bp)+1:]) diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -1,8 +1,6 @@ import os -import posixpath import sys import traceback -import urlparse import errno from mercurial import commands @@ -11,8 +9,6 @@ from mercurial import node from mercurial import util as hgutil from mercurial import error -import layouts -import maps import svnwrap import svnrepo import util diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -1,6 +1,5 @@ import posixpath import os -import tempfile from mercurial import context from mercurial import error as hgerror @@ -903,8 +902,6 @@ class SVNMeta(object): self.ui.status('Marked branch %s as closed.\n' % bname) def delbranch(self, branch, node, rev): - pctx = self.repo[node] - files = pctx.manifest().keys() extra = self.genextra(rev.revnum, branch) self.mapbranch(extra, True) ctx = context.memctx(self.repo, @@ -915,5 +912,5 @@ class SVNMeta(object): util.forceutf8(self.authors[rev.author]), self.fixdate(rev.date), extra) - new = self.repo.svn_commitctx(ctx) + self.repo.svn_commitctx(ctx) self.ui.status('Marked branch %s as closed.\n' % (branch or 'default')) diff --git a/hgsubversion/svnrepo.py b/hgsubversion/svnrepo.py --- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -38,7 +38,6 @@ try: except ImportError: phases = None -import re import util import wrappers import svnwrap diff --git a/hgsubversion/util.py b/hgsubversion/util.py --- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -1,23 +1,16 @@ import compathacks -import errno import re import os import urllib import json import gc -from mercurial import cmdutil from mercurial import error from mercurial import hg from mercurial import node from mercurial import repair from mercurial import util as hgutil -try: - from collections import deque -except: - from mercurial.util import deque - try: from mercurial import revset except ImportError: @@ -29,8 +22,6 @@ try: except ImportError: smartset = None -import maps - ignoredfiles = set(['.hgtags', '.hgsvnexternals', '.hgsub', '.hgsubstate']) b_re = re.compile(r'^\+\+\+ b\/([^\n]*)', re.MULTILINE) @@ -348,7 +339,7 @@ def revset_fromsvn(repo, subset, x): '''``fromsvn()`` Select changesets that originate from Subversion. ''' - args = revset.getargs(x, 0, 0, "fromsvn takes no arguments") + revset.getargs(x, 0, 0, "fromsvn takes no arguments") meta = repo.svnmeta(skiperrorcheck=True) if not meta.revmapexists: diff --git a/hgsubversion/verify.py b/hgsubversion/verify.py --- a/hgsubversion/verify.py +++ b/hgsubversion/verify.py @@ -1,14 +1,12 @@ import difflib import posixpath -from mercurial import util as hgutil from mercurial import error from mercurial import worker import svnwrap import svnrepo import util -import editor def verify(ui, repo, args=None, **opts): '''verify current revision against Subversion repository diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -25,17 +25,12 @@ try: except ImportError: # hg 4.5 and earlier logcmdutil = None -from mercurial import repair -from mercurial import revset from mercurial import scmutil -import inspect -import layouts import replay import pushmod import stupid as stupidmod import svnwrap -import svnrepo import util try: