# HG changeset patch # User Dirkjan Ochtman # Date 1244638526 -7200 # Node ID 28e4b47b21795ab86086e6d49fc6047472243473 # Parent 37c96b78b8c0768cd323596e3b560fc0245cc42e add a working incoming wrapper command diff --git a/hgsubversion/__init__.py b/hgsubversion/__init__.py --- a/hgsubversion/__init__.py +++ b/hgsubversion/__init__.py @@ -50,6 +50,7 @@ wrapcmds = { # cmd: generic, target, fix ]), 'pull': (True, 'sources', True, True, []), 'push': (True, 'destinations', True, True, []), + 'incoming': (False, 'sources', True, True, []), 'clone': (False, 'sources', True, True, [ ('T', 'tagpaths', '', 'list of paths to search for tags in Subversion repositories'), diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -13,48 +13,6 @@ import utility_commands import svnexternals -def incoming(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None, - tag_locations='tags', authors=None, filemap=None, **opts): - """show incoming revisions from Subversion - """ - svn_url = util.normalize_url(svn_url) - - initializing_repo = False - user, passwd = util.getuserpass(opts) - svn = svnwrap.SubversionRepo(svn_url, user, passwd) - author_host = ui.config('hgsubversion', 'defaulthost', svn.uuid) - tag_locations = tag_locations.split(',') - hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path, - ui_=ui, - subdir=svn.subdir, - author_host=author_host, - tag_locations=tag_locations, - authors=authors, - filemap=filemap, - uuid=svn.uuid) - start = max(hg_editor.last_known_revision(), skipto_rev) - initializing_repo = (hg_editor.last_known_revision() <= 0) - - if initializing_repo and start > 0: - raise hgutil.Abort('Revision skipping at repository initialization ' - 'remains unimplemented.') - - rev_stuff = (('revision', 'revnum'), - ('user', 'author'), - ('date', 'date'), - ('message', 'message') - ) - - ui.status('incoming changes from %s\n' % svn_url) - - for r in svn.revisions(start=start): - ui.status('\n') - for label, attr in rev_stuff: - l1 = label+':' - ui.status('%s%s\n' % (l1.ljust(13), - str(r.__getattribute__(attr)).strip(), )) - - def verify(ui, repo, *args, **opts): '''verify current revision against Subversion repository ''' @@ -249,7 +207,6 @@ table = { 'update': update, 'help': help, 'rebuildmeta': rebuildmeta, - 'incoming': incoming, 'updateexternals': svnexternals.updateexternals, 'verify': verify, } diff --git a/hgsubversion/svnrepo.py b/hgsubversion/svnrepo.py --- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -68,12 +68,6 @@ def generate_repo_class(ui, repo): def findoutgoing(self, remote, base=None, heads=None, force=False): return wrappers.outgoing(repo, remote, heads, force) - @remotesvn - def findcommonincoming(self, remote, base=None, heads=None, - force=False): - raise hgutil.Abort('cannot display incoming changes from ' - 'Subversion repositories, yet') - repo.__class__ = svnlocalrepo class svnremoterepo(mercurial.repo.repository): diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -24,6 +24,13 @@ pullfuns = { False: stupidmod.convert_rev, } +revmeta = [ + ('revision', 'revnum'), + ('user', 'author'), + ('date', 'date'), + ('message', 'message'), +] + def parents(orig, ui, repo, *args, **opts): """show Mercurial & Subversion parents of the working dir or revision """ @@ -40,6 +47,31 @@ def parents(orig, ui, repo, *args, **opt return 0 +def incoming(orig, ui, repo, source='default', **opts): + """show incoming revisions from Subversion + """ + + source, revs, checkout = hg.parseurl(ui.expandpath(source)) + other = hg.repository(ui, source) + if 'subversion' not in other.capabilities: + return orig(ui, repo, source, **opts) + + user, passwd = util.getuserpass(opts) + svn = svnwrap.SubversionRepo(other.svnurl, user, passwd) + hg_editor = hg_delta_editor.HgChangeReceiver(repo=repo) + start = hg_editor.last_known_revision() + + ui.status('incoming changes from %s\n' % other.svnurl) + for r in svn.revisions(start=start): + ui.status('\n') + for label, attr in revmeta: + l1 = label + ':' + val = str(getattr(r, attr)).strip() + if not ui.verbose: + val = val.split('\n')[0] + ui.status('%s%s\n' % (l1.ljust(13), val)) + + def outgoing(repo, dest=None, heads=None, force=False): """show changesets not found in the Subversion repository """