Mercurial > hgsubversion
comparison utility_commands.py @ 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 | c34abd2448b7 |
| children | c3d5c4ae9c7c |
comparison
equal
deleted
inserted
replaced
| 249:a065bf61caa1 | 250:79349fd04836 |
|---|---|
| 1 import os | 1 import os |
| 2 | 2 |
| 3 import mercurial | 3 import mercurial |
| 4 from mercurial import cmdutil | 4 from mercurial import cmdutil |
| 5 from mercurial import node | 5 from mercurial import node |
| 6 from mercurial import util as mutil | 6 from mercurial import util as hgutil |
| 7 from hgext import rebase | 7 from hgext import rebase |
| 8 | 8 |
| 9 import svnwrap | 9 import svnwrap |
| 10 import util | 10 import util |
| 11 import hg_delta_editor | 11 import hg_delta_editor |
| 32 def generate_ignore(ui, repo, hg_repo_path, force=False, **opts): | 32 def generate_ignore(ui, repo, hg_repo_path, force=False, **opts): |
| 33 """generate .hgignore from svn:ignore properties. | 33 """generate .hgignore from svn:ignore properties. |
| 34 """ | 34 """ |
| 35 ignpath = os.path.join(hg_repo_path, '.hgignore') | 35 ignpath = os.path.join(hg_repo_path, '.hgignore') |
| 36 if not force and os.path.exists(ignpath): | 36 if not force and os.path.exists(ignpath): |
| 37 raise mutil.Abort('not overwriting existing .hgignore, try --force?') | 37 raise hgutil.Abort('not overwriting existing .hgignore, try --force?') |
| 38 ignorefile = open(ignpath, 'w') | 38 ignorefile = open(ignpath, 'w') |
| 39 ignorefile.write('.hgignore\nsyntax:glob\n') | 39 ignorefile.write('.hgignore\nsyntax:glob\n') |
| 40 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 40 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
| 41 ui_=ui) | 41 ui_=ui) |
| 42 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 42 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
| 48 else: | 48 else: |
| 49 branchpath = 'branches/%s' % br | 49 branchpath = 'branches/%s' % br |
| 50 url = hge.url | 50 url = hge.url |
| 51 if url[-1] == '/': | 51 if url[-1] == '/': |
| 52 url = url[:-1] | 52 url = url[:-1] |
| 53 user = opts.get('username', mutil.getuser()) | 53 user = opts.get('username', hgutil.getuser()) |
| 54 passwd = opts.get('passwd', '') | 54 passwd = opts.get('passwd', '') |
| 55 svn = svnwrap.SubversionRepo(url, user, passwd) | 55 svn = svnwrap.SubversionRepo(url, user, passwd) |
| 56 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] | 56 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] |
| 57 for dir in dirs: | 57 for dir in dirs: |
| 58 props = svn.list_props('%s/%s/' % (branchpath,dir), r) | 58 props = svn.list_props('%s/%s/' % (branchpath,dir), r) |
| 106 'uuid': open(hge.uuid_file).read(), | 106 'uuid': open(hge.uuid_file).read(), |
| 107 'url': url, | 107 'url': url, |
| 108 'author': author, | 108 'author': author, |
| 109 'revision': r, | 109 'revision': r, |
| 110 # TODO I'd like to format this to the user's local TZ if possible | 110 # TODO I'd like to format this to the user's local TZ if possible |
| 111 'date': mutil.datestr(parent.date(), | 111 'date': hgutil.datestr(parent.date(), |
| 112 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') | 112 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') |
| 113 }) | 113 }) |
| 114 run_svn_info = util.register_subcommand('info')(run_svn_info) | 114 run_svn_info = util.register_subcommand('info')(run_svn_info) |
| 115 | 115 |
| 116 | 116 |
| 117 def print_parent_revision(ui, repo, hg_repo_path, **opts): | 117 def print_parent_revision(ui, repo, hg_repo_path, **opts): |
| 219 | 219 |
| 220 | 220 |
| 221 def version(ui, **opts): | 221 def version(ui, **opts): |
| 222 """Show current version of hg and hgsubversion. | 222 """Show current version of hg and hgsubversion. |
| 223 """ | 223 """ |
| 224 ui.status('hg: %s\n' % mutil.version()) | 224 ui.status('hg: %s\n' % hgutil.version()) |
| 225 ui.status('svn bindings: %s\n' % svnwrap.version()) | 225 ui.status('svn bindings: %s\n' % svnwrap.version()) |
| 226 ui.status('hgsubversion: %s\n' % util.version(ui)) | 226 ui.status('hgsubversion: %s\n' % util.version(ui)) |
| 227 version = util.register_subcommand('version')(version) | 227 version = util.register_subcommand('version')(version) |
| 228 version = util.command_needs_no_url(version) | 228 version = util.command_needs_no_url(version) |
