def get_new_location_segments(parsed_original_mergeinfo, repo_root, wcpath, ctx): for path in parsed_original_mergeinfo: full_url = repo_root + path ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = core.svn_auth_open([ core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert), svn.client.get_simple_provider(), svn.client.get_username_provider() ]) try: ctx.config = core.svn_config_get_config(None) ra_session = ra.open(full_url, ra_callbacks, None, ctx.config) for revision_range in parsed_original_mergeinfo[path]: try: ra.get_location_segments(ra_session, "", revision_range.end, revision_range.end, revision_range.start + 1, location_segment_callback) except svn.core.SubversionException: sys.stderr.write(" Could not find location segments for %s \n" % path) except Exception, e: sys.stderr.write("")
def get_history_as_mergeinfo(self, ra_session, rel_path, rev, oldest_rev=core.SVN_INVALID_REVNUM): """Return the natural history of REL_PATH in REV, between OLDEST_REV and REV, as mergeinfo. If OLDEST_REV is core.SVN_INVALID_REVNUM, all of PATH's history prior to REV will be returned. REL_PATH is relative to the session URL of RA_SESSION. (Adapted from Subversion's svn_client__get_history_as_mergeinfo().)""" # Fetch the location segments in the history. location_segments = [] def _segment_receiver(segment, pool): location_segments.append(segment) ra.get_location_segments(ra_session, rel_path, rev, rev, oldest_rev, _segment_receiver) # Location segments come in youngest to oldest. But we rather # need oldest-to-youngest for proper revision range ordering. location_segments.sort(lambda a, b: cmp(a.range_start, b.range_start)) # Transform location segments into merge sources and ranges. mergeinfo = {} for segment in location_segments: if segment.path is None: continue source_path = '/' + segment.path path_ranges = mergeinfo.get(source_path, []) range = core.svn_merge_range_t() range.start = max(segment.range_start - 1, 0) range.end = segment.range_end range.inheritable = 1 path_ranges.append(range) mergeinfo[source_path] = path_ranges return mergeinfo
def get_new_location_segments(parsed_original_mergeinfo, repo_root, wcpath, ctx): for path in parsed_original_mergeinfo: full_url = repo_root + path ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = core.svn_auth_open([ core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider( prompt_func_ssl_unknown_cert), svn.client.get_simple_provider(), svn.client.get_username_provider() ]) try: ctx.config = core.svn_config_get_config(None) ra_session = ra.open(full_url, ra_callbacks, None, ctx.config) for revision_range in parsed_original_mergeinfo[path]: try: ra.get_location_segments(ra_session, "", revision_range.end, revision_range.end, revision_range.start + 1, location_segment_callback) except svn.core.SubversionException: sys.stderr.write( " Could not find location segments for %s \n" % path) except Exception, e: sys.stderr.write("")
def main(): try: url, peg_revision, start_revision, end_revision = parse_args( sys.argv[1:]) except Exception as e: sys.stderr.write("""Usage: %s URL[@PEG-REV] [START-REV[:END-REV]] Trace the history of URL@PEG-REV, printing the location(s) of its existence between START-REV and END-REV. If START-REV is not provided, the entire history of URL@PEG-REV back to its origin will be displayed. If provided, START-REV must not be younger than PEG-REV. If END-REV is provided, it must not be younger than START-REV. (This is a wrapper around Subversion's svn_ra_get_location_segments() API.) ERROR: %s """ % (os.path.basename(sys.argv[0]), str(e))) sys.exit(1) core.svn_config_ensure(None) ctx = client.svn_client_create_context() ctx.config = core.svn_config_get_config(None) # Make sure that these are at the start of the list, so passwords from # gnome-keyring / kwallet are checked before asking for new passwords. providers = core.svn_auth_get_platform_specific_client_providers( ctx.config['config'], None) providers.extend([ client.get_simple_provider(), core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider( prompt_func_ssl_unknown_cert), client.get_username_provider(), client.get_ssl_server_trust_file_provider(), client.get_ssl_client_cert_file_provider(), client.get_ssl_client_cert_pw_file_provider(), ]) ctx.auth_baton = core.svn_auth_open(providers) if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'): core.svn_auth_set_gnome_keyring_unlock_prompt_func( ctx.auth_baton, prompt_func_gnome_keyring_prompt) ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = ctx.auth_baton ra_session = ra.open(url, ra_callbacks, None, ctx.config) ra.get_location_segments(ra_session, "", peg_revision, start_revision, end_revision, printer)
def main(): try: url, peg_revision, start_revision, end_revision = parse_args(sys.argv[1:]) except Exception as e: sys.stderr.write("""Usage: %s URL[@PEG-REV] [START-REV[:END-REV]] Trace the history of URL@PEG-REV, printing the location(s) of its existence between START-REV and END-REV. If START-REV is not provided, the entire history of URL@PEG-REV back to its origin will be displayed. If provided, START-REV must not be younger than PEG-REV. If END-REV is provided, it must not be younger than START-REV. (This is a wrapper around Subversion's svn_ra_get_location_segments() API.) ERROR: %s """ % (os.path.basename(sys.argv[0]), str(e))) sys.exit(1) core.svn_config_ensure(None) ctx = client.svn_client_create_context() ctx.config = core.svn_config_get_config(None) # Make sure that these are at the start of the list, so passwords from # gnome-keyring / kwallet are checked before asking for new passwords. providers = core.svn_auth_get_platform_specific_client_providers(ctx.config['config'], None) providers.extend([ client.get_simple_provider(), core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert), client.get_username_provider(), client.get_ssl_server_trust_file_provider(), client.get_ssl_client_cert_file_provider(), client.get_ssl_client_cert_pw_file_provider(), ]) ctx.auth_baton = core.svn_auth_open(providers) if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'): core.svn_auth_set_gnome_keyring_unlock_prompt_func(ctx.auth_baton, prompt_func_gnome_keyring_prompt) ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = ctx.auth_baton ra_session = ra.open(url, ra_callbacks, None, ctx.config) ra.get_location_segments(ra_session, "", peg_revision, start_revision, end_revision, printer)
# gnome-keyring / kwallet are checked before asking for new passwords. providers = core.svn_auth_get_platform_specific_client_providers( ctx.config['config'], None) providers.extend([ client.get_simple_provider(), core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider( prompt_func_ssl_unknown_cert), client.get_username_provider(), client.get_ssl_server_trust_file_provider(), client.get_ssl_client_cert_file_provider(), client.get_ssl_client_cert_pw_file_provider(), ]) ctx.auth_baton = core.svn_auth_open(providers) if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'): core.svn_auth_set_gnome_keyring_unlock_prompt_func( ctx.auth_baton, prompt_func_gnome_keyring_prompt) ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = ctx.auth_baton ra_session = ra.open(url, ra_callbacks, None, ctx.config) ra.get_location_segments(ra_session, "", peg_revision, start_revision, end_revision, printer) if __name__ == "__main__": main()
ctx = client.svn_client_create_context() ctx.config = core.svn_config_get_config(None) # Make sure that these are at the start of the list, so passwords from # gnome-keyring / kwallet are checked before asking for new passwords. providers = core.svn_auth_get_platform_specific_client_providers(ctx.config['config'], None) providers.extend([ client.get_simple_provider(), core.svn_auth_get_ssl_server_trust_file_provider(), core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2), core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert), client.get_username_provider(), client.get_ssl_server_trust_file_provider(), client.get_ssl_client_cert_file_provider(), client.get_ssl_client_cert_pw_file_provider(), ]) ctx.auth_baton = core.svn_auth_open(providers) if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'): core.svn_auth_set_gnome_keyring_unlock_prompt_func(ctx.auth_baton, prompt_func_gnome_keyring_prompt) ra_callbacks = ra.callbacks_t() ra_callbacks.auth_baton = ctx.auth_baton ra_session = ra.open(url, ra_callbacks, None, ctx.config) ra.get_location_segments(ra_session, "", peg_revision, start_revision, end_revision, printer) if __name__ == "__main__": main()