Mercurial > hgsubversion
changeset 250:79349fd04836
utils: standardizing imported name to hgutil, our_util to util
author | Daniel Tang <dytang@cs.purdue.edu> |
---|---|
date | Fri, 10 Apr 2009 13:43:44 -0400 |
parents | a065bf61caa1 |
children | 23b02f892d9b |
files | hg_delta_editor.py svnexternals.py util.py utility_commands.py |
diffstat | 4 files changed, 30 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -8,14 +8,14 @@ import traceback from mercurial import context from mercurial import hg from mercurial import ui -from mercurial import util +from mercurial import util as hgutil from mercurial import revlog from mercurial import node from svn import delta from svn import core import svnexternals -import util as our_util +import util def pickle_atomic(data, file_path, dir=None): """pickle some data to a path atomically. @@ -31,7 +31,7 @@ def pickle_atomic(data, file_path, dir=N except: #pragma: no cover raise else: - util.rename(path, file_path) + hgutil.rename(path, file_path) def stash_exception_on_self(fn): """Stash any exception raised in the method on self. @@ -100,7 +100,7 @@ class HgChangeReceiver(delta.Editor): self.subdir = self.subdir[1:] self.revmap = {} if os.path.exists(self.revmap_file): - self.revmap = our_util.parse_revmap(self.revmap_file) + self.revmap = util.parse_revmap(self.revmap_file) self.branches = {} if os.path.exists(self.branch_info_file): f = open(self.branch_info_file) @@ -160,7 +160,7 @@ class HgChangeReceiver(delta.Editor): self.repo = hg.repository(self.ui, repo_path, create=True) os.makedirs(os.path.dirname(self.uuid_file)) f = open(self.revmap_file, 'w') - f.write('%s\n' % our_util.REVMAP_FILE_VERSION) + f.write('%s\n' % util.REVMAP_FILE_VERSION) f.flush() f.close() @@ -634,9 +634,9 @@ class HgChangeReceiver(delta.Editor): if parents[0] in closed_revs and branch in self.branches_to_delete: continue # TODO this needs to be fixed with the new revmap - extra = our_util.build_extra(rev.revnum, branch, - open(self.uuid_file).read(), - self.subdir) + extra = util.build_extra(rev.revnum, branch, + open(self.uuid_file).read(), + self.subdir) if branch is not None: if (branch not in self.branches and branch not in self.repo.branchtags()): @@ -676,7 +676,7 @@ class HgChangeReceiver(delta.Editor): date, extra) new_hash = self.repo.commitctx(current_ctx) - our_util.describe_commit(self.ui, new_hash, branch) + util.describe_commit(self.ui, new_hash, branch) if (rev.revnum, branch) not in self.revmap: self.add_to_revmap(rev.revnum, branch, new_hash) # now we handle branches that need to be committed without any files @@ -689,9 +689,9 @@ class HgChangeReceiver(delta.Editor): raise IOError # True here meant nuke all files, shouldn't happen with branch closing if self.commit_branches_empty[branch]: #pragma: no cover - raise util.Abort('Empty commit to an open branch attempted. ' - 'Please report this issue.') - extra = our_util.build_extra(rev.revnum, branch, + raise hgutil.Abort('Empty commit to an open branch attempted. ' + 'Please report this issue.') + extra = util.build_extra(rev.revnum, branch, open(self.uuid_file).read(), self.subdir) current_ctx = context.memctx(self.repo, @@ -703,7 +703,7 @@ class HgChangeReceiver(delta.Editor): date, extra) new_hash = self.repo.commitctx(current_ctx) - our_util.describe_commit(self.ui, new_hash, branch) + util.describe_commit(self.ui, new_hash, branch) if (rev.revnum, branch) not in self.revmap: self.add_to_revmap(rev.revnum, branch, new_hash) self._save_metadata() @@ -856,7 +856,7 @@ class HgChangeReceiver(delta.Editor): self.externals[path] = None map(self.delete_file, [pat for pat in self.current_files.iterkeys() if pat.startswith(path+'/')]) - for f in ctx.walk(our_util.PrefixMatch(br_path2)): + for f in ctx.walk(util.PrefixMatch(br_path2)): f_p = '%s/%s' % (path, f[len(br_path2):]) if f_p not in self.current_files: self.delete_file(f_p) @@ -1055,8 +1055,8 @@ class HgChangeReceiver(delta.Editor): handler, baton = delta.svn_txdelta_apply(source, target, None) if not callable(handler): #pragma: no cover - raise util.Abort('Error in Subversion bindings: ' - 'cannot call handler!') + raise hgutil.Abort('Error in Subversion bindings: ' + 'cannot call handler!') def txdelt_window(window): try: if not self._is_path_valid(self.current_file): @@ -1069,7 +1069,7 @@ class HgChangeReceiver(delta.Editor): if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA: self.missing_plaintexts.add(self.current_file) else: #pragma: no cover - raise util.Abort(*e.args) + raise hgutil.Abort(*e.args) except: #pragma: no cover print len(base), self.current_file self._exception_info = sys.exc_info()
--- a/svnexternals.py +++ b/svnexternals.py @@ -1,6 +1,6 @@ import cStringIO -from mercurial import util as merc_util +from mercurial import util as hgutil class externalsfile(dict): """Map svn directories to lists of externals entries. @@ -24,7 +24,7 @@ class externalsfile(dict): def write(self): fp = cStringIO.StringIO() - for target in merc_util.sort(self): + for target in hgutil.sort(self): lines = self[target] if not lines: continue @@ -47,7 +47,7 @@ class externalsfile(dict): if line.startswith('['): line = line.strip() if line[-1] != ']': - raise merc_util.Abort('invalid externals section name: %s' % line) + raise hgutil.Abort('invalid externals section name: %s' % line) target = line[1:-1] if target == '.': target = ''
--- a/util.py +++ b/util.py @@ -3,7 +3,7 @@ import shutil from mercurial import hg from mercurial import node -from mercurial import util +from mercurial import util as hgutil svn_subcommands = { } def register_subcommand(name): @@ -96,7 +96,7 @@ def outgoing_revisions(ui, repo, hg_edit outgoing_rev_hashes.append(sourcerev.node()) sourcerev = sourcerev.parents() if len(sourcerev) != 1: - raise util.Abort("Sorry, can't find svn parent of a merge revision.") + raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.") sourcerev = sourcerev[0] if sourcerev.node() != node.nullid: return outgoing_rev_hashes @@ -144,6 +144,6 @@ def swap_out_encoding(new_encoding="UTF- old = encoding.encoding encoding.encoding = new_encoding except ImportError: - old = util._encoding - util._encoding = new_encoding + old = hgutil._encoding + hgutil._encoding = new_encoding return old
--- a/utility_commands.py +++ b/utility_commands.py @@ -3,7 +3,7 @@ import os import mercurial from mercurial import cmdutil from mercurial import node -from mercurial import util as mutil +from mercurial import util as hgutil from hgext import rebase import svnwrap @@ -34,7 +34,7 @@ def generate_ignore(ui, repo, hg_repo_pa """ ignpath = os.path.join(hg_repo_path, '.hgignore') if not force and os.path.exists(ignpath): - raise mutil.Abort('not overwriting existing .hgignore, try --force?') + raise hgutil.Abort('not overwriting existing .hgignore, try --force?') ignorefile = open(ignpath, 'w') ignorefile.write('.hgignore\nsyntax:glob\n') hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, @@ -50,7 +50,7 @@ def generate_ignore(ui, repo, hg_repo_pa url = hge.url if url[-1] == '/': url = url[:-1] - user = opts.get('username', mutil.getuser()) + user = opts.get('username', hgutil.getuser()) passwd = opts.get('passwd', '') svn = svnwrap.SubversionRepo(url, user, passwd) dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] @@ -108,8 +108,8 @@ Last Changed Date: %(date)s\n''' % 'author': author, 'revision': r, # TODO I'd like to format this to the user's local TZ if possible - 'date': mutil.datestr(parent.date(), - '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') + 'date': hgutil.datestr(parent.date(), + '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') }) run_svn_info = util.register_subcommand('info')(run_svn_info) @@ -221,7 +221,7 @@ list_authors = util.command_needs_no_url def version(ui, **opts): """Show current version of hg and hgsubversion. """ - ui.status('hg: %s\n' % mutil.version()) + ui.status('hg: %s\n' % hgutil.version()) ui.status('svn bindings: %s\n' % svnwrap.version()) ui.status('hgsubversion: %s\n' % util.version(ui)) version = util.register_subcommand('version')(version)