mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
Add --username and --password options to all commands
This commit is contained in:
parent
8140653efb
commit
578aaf5fe9
@ -79,6 +79,8 @@ cmdtable = {
|
|||||||
('', 'filemap', '',
|
('', 'filemap', '',
|
||||||
'remap file to exclude paths or include only certain paths'),
|
'remap file to exclude paths or include only certain paths'),
|
||||||
('', 'force', False, 'force an operation to happen'),
|
('', 'force', False, 'force an operation to happen'),
|
||||||
|
('', 'username', '', 'username for authentication'),
|
||||||
|
('', 'password', '', 'password for authentication'),
|
||||||
],
|
],
|
||||||
svncommand.generate_help(),
|
svncommand.generate_help(),
|
||||||
),
|
),
|
||||||
@ -90,6 +92,8 @@ cmdtable = {
|
|||||||
('A', 'authors', '', 'username mapping filename'),
|
('A', 'authors', '', 'username mapping filename'),
|
||||||
('', 'filemap', '',
|
('', 'filemap', '',
|
||||||
'remap file to exclude paths or include only certain paths'),
|
'remap file to exclude paths or include only certain paths'),
|
||||||
|
('', 'username', '', 'username for authentication'),
|
||||||
|
('', 'password', '', 'password for authentication'),
|
||||||
],
|
],
|
||||||
'hg svnclone source [dest]'),
|
'hg svnclone source [dest]'),
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,9 @@ def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
|
|||||||
' of SWIG.\n')
|
' of SWIG.\n')
|
||||||
have_replay = False
|
have_replay = False
|
||||||
initializing_repo = False
|
initializing_repo = False
|
||||||
svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
|
user = opts.get('username', merc_util.getuser())
|
||||||
|
passwd = opts.get('password', '')
|
||||||
|
svn = svnwrap.SubversionRepo(svn_url, user, passwd)
|
||||||
author_host = "@%s" % svn.uuid
|
author_host = "@%s" % svn.uuid
|
||||||
tag_locations = tag_locations.split(',')
|
tag_locations = tag_locations.split(',')
|
||||||
hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
|
hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
|
||||||
|
13
push_cmd.py
13
push_cmd.py
@ -29,6 +29,8 @@ def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url,
|
|||||||
ui_=ui)
|
ui_=ui)
|
||||||
svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
|
svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
|
||||||
hge.revmap.iterkeys()))
|
hge.revmap.iterkeys()))
|
||||||
|
user = opts.get('username', merc_util.getuser())
|
||||||
|
passwd = opts.get('password', '')
|
||||||
# Strategy:
|
# Strategy:
|
||||||
# 1. Find all outgoing commits from this head
|
# 1. Find all outgoing commits from this head
|
||||||
if len(repo.parents()) != 1:
|
if len(repo.parents()) != 1:
|
||||||
@ -59,14 +61,16 @@ def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url,
|
|||||||
# 2. Commit oldest revision that needs to be pushed
|
# 2. Commit oldest revision that needs to be pushed
|
||||||
base_revision = svn_commit_hashes[base_n][0]
|
base_revision = svn_commit_hashes[base_n][0]
|
||||||
try:
|
try:
|
||||||
commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision)
|
commit_from_rev(ui, repo, old_ctx, hge, svn_url, base_revision,
|
||||||
|
user, passwd)
|
||||||
except NoFilesException:
|
except NoFilesException:
|
||||||
ui.warn("Could not push revision %s because it had no changes in svn.\n" %
|
ui.warn("Could not push revision %s because it had no changes in svn.\n" %
|
||||||
old_ctx)
|
old_ctx)
|
||||||
return 1
|
return 1
|
||||||
# 3. Fetch revisions from svn
|
# 3. Fetch revisions from svn
|
||||||
r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path,
|
r = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path,
|
||||||
stupid=stupid)
|
stupid=stupid, username=user,
|
||||||
|
password=passwd)
|
||||||
assert not r or r == 0
|
assert not r or r == 0
|
||||||
# 4. Find the new head of the target branch
|
# 4. Find the new head of the target branch
|
||||||
repo = hg.repository(ui, hge.path)
|
repo = hg.repository(ui, hge.path)
|
||||||
@ -182,11 +186,12 @@ def _externals(ctx):
|
|||||||
ext.read(ctx['.hgsvnexternals'].data())
|
ext.read(ctx['.hgsvnexternals'].data())
|
||||||
return ext
|
return ext
|
||||||
|
|
||||||
def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision):
|
def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision,
|
||||||
|
username, password):
|
||||||
"""Build and send a commit from Mercurial to Subversion.
|
"""Build and send a commit from Mercurial to Subversion.
|
||||||
"""
|
"""
|
||||||
file_data = {}
|
file_data = {}
|
||||||
svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
|
svn = svnwrap.SubversionRepo(svn_url, username, password)
|
||||||
parent = rev_ctx.parents()[0]
|
parent = rev_ctx.parents()[0]
|
||||||
parent_branch = rev_ctx.parents()[0].branch()
|
parent_branch = rev_ctx.parents()[0].branch()
|
||||||
branch_path = 'trunk'
|
branch_path = 'trunk'
|
||||||
|
@ -14,7 +14,9 @@ def rebuildmeta(ui, repo, hg_repo_path, args, **opts):
|
|||||||
raise mutil.Abort('You must pass the svn URI used to create this repo.')
|
raise mutil.Abort('You must pass the svn URI used to create this repo.')
|
||||||
uuid = None
|
uuid = None
|
||||||
url = args[0].rstrip('/')
|
url = args[0].rstrip('/')
|
||||||
svn = svnwrap.SubversionRepo(url=url)
|
user = opts.get('username', mutil.getuser())
|
||||||
|
passwd = opts.get('password', '')
|
||||||
|
svn = svnwrap.SubversionRepo(url, user, passwd)
|
||||||
subdir = svn.subdir
|
subdir = svn.subdir
|
||||||
svnmetadir = os.path.join(repo.path, 'svn')
|
svnmetadir = os.path.join(repo.path, 'svn')
|
||||||
if not os.path.exists(svnmetadir):
|
if not os.path.exists(svnmetadir):
|
||||||
|
@ -118,9 +118,10 @@ class SubversionRepo(object):
|
|||||||
This uses the SWIG Python bindings, and will only work on svn >= 1.4.
|
This uses the SWIG Python bindings, and will only work on svn >= 1.4.
|
||||||
It takes a required param, the URL.
|
It takes a required param, the URL.
|
||||||
"""
|
"""
|
||||||
def __init__(self, url='', username=''):
|
def __init__(self, url='', username='', password=''):
|
||||||
self.svn_url = url
|
self.svn_url = url
|
||||||
self.username = username
|
self.username = username
|
||||||
|
self.password = password
|
||||||
self.auth_baton_pool = core.Pool()
|
self.auth_baton_pool = core.Pool()
|
||||||
self.auth_baton = _create_auth_baton(self.auth_baton_pool)
|
self.auth_baton = _create_auth_baton(self.auth_baton_pool)
|
||||||
|
|
||||||
@ -143,6 +144,10 @@ class SubversionRepo(object):
|
|||||||
core.svn_auth_set_parameter(self.auth_baton,
|
core.svn_auth_set_parameter(self.auth_baton,
|
||||||
core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
|
core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
|
||||||
self.username)
|
self.username)
|
||||||
|
if self.password:
|
||||||
|
core.svn_auth_set_parameter(self.auth_baton,
|
||||||
|
core.SVN_AUTH_PARAM_DEFAULT_PASSWORD,
|
||||||
|
self.password)
|
||||||
self.client_context = client.create_context()
|
self.client_context = client.create_context()
|
||||||
|
|
||||||
self.client_context.auth_baton = self.auth_baton
|
self.client_context.auth_baton = self.auth_baton
|
||||||
|
@ -50,7 +50,9 @@ def generate_ignore(ui, repo, hg_repo_path, force=False, **opts):
|
|||||||
url = hge.url
|
url = hge.url
|
||||||
if url[-1] == '/':
|
if url[-1] == '/':
|
||||||
url = url[:-1]
|
url = url[:-1]
|
||||||
svn = svnwrap.SubversionRepo(url)
|
user = opts.get('username', mutil.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']
|
dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd']
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
props = svn.list_props('%s/%s/' % (branchpath,dir), r)
|
props = svn.list_props('%s/%s/' % (branchpath,dir), r)
|
||||||
|
Loading…
Reference in New Issue
Block a user