Mercurial > hgsubversion
comparison utility_commands.py @ 331:75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
The 'hg svn url' command has been killed; the replacement is
'.hg/hgrc'. More stuff related to its disappearance has been stripped,
including two tests.
HgChangeReceiver now takes a UUID argument, which it uses to ensure
that remote repositories remain unchanged. This is a temporary
solution, and I'm not entirely satisfied with how it's done either.
Access to the UUID file has been isolated in a HgChangeReceiver
property.
Some more tests have been updated to use ui.pushbuffer()/popbuffer(),
and to pass through the Mercurial API.
Moved the arguments to wrappers.pull() to the UI configuration.
Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames'
instance & configuration variable. The name is taken from the
ConvertExtension.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Fri, 15 May 2009 19:18:43 +0200 |
| parents | 1d48d9a34c19 |
| children |
comparison
equal
deleted
inserted
replaced
| 330:5f8f2fd4fd54 | 331:75f082b5897e |
|---|---|
| 5 import svnwrap | 5 import svnwrap |
| 6 import cmdutil | 6 import cmdutil |
| 7 import util | 7 import util |
| 8 import hg_delta_editor | 8 import hg_delta_editor |
| 9 | 9 |
| 10 def url(ui, repo, hg_repo_path, **opts): | |
| 11 """show the location (URL) of the Subversion repository | |
| 12 """ | |
| 13 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | |
| 14 ui_=ui) | |
| 15 ui.status(hge.url, '\n') | |
| 16 | |
| 17 | |
| 18 def genignore(ui, repo, hg_repo_path, force=False, **opts): | 10 def genignore(ui, repo, hg_repo_path, force=False, **opts): |
| 19 """generate .hgignore from svn:ignore properties. | 11 """generate .hgignore from svn:ignore properties. |
| 20 """ | 12 """ |
| 21 ignpath = os.path.join(hg_repo_path, '.hgignore') | 13 ignpath = os.path.join(hg_repo_path, '.hgignore') |
| 22 if not force and os.path.exists(ignpath): | 14 if not force and os.path.exists(ignpath): |
| 23 raise hgutil.Abort('not overwriting existing .hgignore, try --force?') | 15 raise hgutil.Abort('not overwriting existing .hgignore, try --force?') |
| 24 ignorefile = open(ignpath, 'w') | 16 ignorefile = open(ignpath, 'w') |
| 25 ignorefile.write('.hgignore\nsyntax:glob\n') | 17 ignorefile.write('.hgignore\nsyntax:glob\n') |
| 26 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 18 url = util.normalize_url(repo.ui.config('paths', 'default')) |
| 27 ui_=ui) | 19 user, passwd = util.getuserpass(opts) |
| 20 svn = svnwrap.SubversionRepo(url, user, passwd) | |
| 21 hge = hg_delta_editor.HgChangeReceiver(path=hg_repo_path, repo=repo, | |
| 22 ui_=ui, uuid=svn.uuid) | |
| 28 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 23 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
| 29 hge.revmap.iterkeys())) | 24 hge.revmap.iterkeys())) |
| 30 parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) | 25 parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) |
| 31 r, br = svn_commit_hashes[parent.node()] | 26 r, br = svn_commit_hashes[parent.node()] |
| 32 if br == None: | 27 if br == None: |
| 33 branchpath = 'trunk' | 28 branchpath = 'trunk' |
| 34 else: | 29 else: |
| 35 branchpath = 'branches/%s' % br | 30 branchpath = 'branches/%s' % br |
| 36 url = hge.url | |
| 37 if url[-1] == '/': | 31 if url[-1] == '/': |
| 38 url = url[:-1] | 32 url = url[:-1] |
| 39 user, passwd = util.getuserpass(opts) | |
| 40 svn = svnwrap.SubversionRepo(url, user, passwd) | |
| 41 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] | 33 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] |
| 42 for dir in dirs: | 34 for dir in dirs: |
| 43 props = svn.list_props('%s/%s/' % (branchpath,dir), r) | 35 props = svn.list_props('%s/%s/' % (branchpath,dir), r) |
| 44 if 'svn:ignore' in props: | 36 if 'svn:ignore' in props: |
| 45 lines = props['svn:ignore'].strip().split('\n') | 37 lines = props['svn:ignore'].strip().split('\n') |
| 51 | 43 |
| 52 | 44 |
| 53 def info(ui, repo, hg_repo_path, **opts): | 45 def info(ui, repo, hg_repo_path, **opts): |
| 54 """show Subversion details similar to `svn info' | 46 """show Subversion details similar to `svn info' |
| 55 """ | 47 """ |
| 56 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, | 48 url = util.normalize_url(repo.ui.config('paths', 'default')) |
| 57 ui_=ui) | 49 user, passwd = util.getuserpass(opts) |
| 50 svn = svnwrap.SubversionRepo(url, user, passwd) | |
| 51 hge = hg_delta_editor.HgChangeReceiver(path=hg_repo_path, repo=repo, | |
| 52 ui_=ui, uuid=svn.uuid) | |
| 58 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 53 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
| 59 hge.revmap.iterkeys())) | 54 hge.revmap.iterkeys())) |
| 60 parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) | 55 parent = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) |
| 61 pn = parent.node() | 56 pn = parent.node() |
| 62 if pn not in svn_commit_hashes: | 57 if pn not in svn_commit_hashes: |
| 69 elif br.startswith('../'): | 64 elif br.startswith('../'): |
| 70 branchpath = '/%s' % br[3:] | 65 branchpath = '/%s' % br[3:] |
| 71 subdir = subdir.replace('branches/../', '') | 66 subdir = subdir.replace('branches/../', '') |
| 72 else: | 67 else: |
| 73 branchpath = '/branches/%s' % br | 68 branchpath = '/branches/%s' % br |
| 74 url = hge.url | 69 url = util.normalize_url(repo.ui.config('paths', 'default')) |
| 75 if url[-1] == '/': | 70 if url[-1] == '/': |
| 76 url = url[:-1] | 71 url = url[:-1] |
| 77 url = '%s%s' % (url, branchpath) | 72 url = '%s%s' % (url, branchpath) |
| 78 author = hge.authors.reverselookup(parent.user()) | 73 author = hge.authors.reverselookup(parent.user()) |
| 79 # cleverly figure out repo root w/o actually contacting the server | 74 # cleverly figure out repo root w/o actually contacting the server |
| 85 Node Kind: directory | 80 Node Kind: directory |
| 86 Last Changed Author: %(author)s | 81 Last Changed Author: %(author)s |
| 87 Last Changed Rev: %(revision)s | 82 Last Changed Rev: %(revision)s |
| 88 Last Changed Date: %(date)s\n''' % | 83 Last Changed Date: %(date)s\n''' % |
| 89 {'reporoot': reporoot, | 84 {'reporoot': reporoot, |
| 90 'uuid': open(hge.uuid_file).read(), | 85 'uuid': hge.uuid, |
| 91 'url': url, | 86 'url': url, |
| 92 'author': author, | 87 'author': author, |
| 93 'revision': r, | 88 'revision': r, |
| 94 # TODO I'd like to format this to the user's local TZ if possible | 89 # TODO I'd like to format this to the user's local TZ if possible |
| 95 'date': hgutil.datestr(parent.date(), | 90 'date': hgutil.datestr(parent.date(), |
| 123 ui.status('hgsubversion: %s\n' % util.version(ui)) | 118 ui.status('hgsubversion: %s\n' % util.version(ui)) |
| 124 | 119 |
| 125 | 120 |
| 126 nourl = ['version', 'listauthors'] | 121 nourl = ['version', 'listauthors'] |
| 127 table = { | 122 table = { |
| 128 'url': url, | |
| 129 'genignore': genignore, | 123 'genignore': genignore, |
| 130 'info': info, | 124 'info': info, |
| 131 'listauthors': listauthors, | 125 'listauthors': listauthors, |
| 132 'version': version, | 126 'version': version, |
| 133 } | 127 } |
