From 29d184dfcbd75a20a63b462b4a3a011470fe7fcf Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Wed, 27 Nov 2013 11:07:35 -0500 Subject: [PATCH] Let ssh figure out port/user if not specified so we don't override .ssh/config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified by Jonas Borgström: - Added CHANGES entry - Fixed broken unit test --- CHANGES | 7 +++++++ attic/helpers.py | 4 +--- attic/remote.py | 9 ++++++++- attic/testsuite/helpers.py | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index fc4bc7b59..83a9c80a3 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,13 @@ Attic Changelog Here you can see the full list of changes between each Attic release. +Version 0.9 +----------- + +(feature release, released on X) + +- Let ssh figure out port/user if not specified so we don't override .ssh/config (#9) + Version 0.8.1 ------------- diff --git a/attic/helpers.py b/attic/helpers.py index 2af7b6a21..94dd54048 100644 --- a/attic/helpers.py +++ b/attic/helpers.py @@ -285,7 +285,7 @@ class Location: self.proto = m.group('proto') self.user = m.group('user') self.host = m.group('host') - self.port = m.group('port') and int(m.group('port')) or 22 + self.port = m.group('port') and int(m.group('port')) or None self.path = m.group('path') self.archive = m.group('archive') return True @@ -302,8 +302,6 @@ class Location: self.path = m.group('path') self.archive = m.group('archive') self.proto = self.host and 'ssh' or 'file' - if self.proto == 'ssh': - self.port = 22 return True return False diff --git a/attic/remote.py b/attic/remote.py index 0ea984351..2eb384100 100644 --- a/attic/remote.py +++ b/attic/remote.py @@ -83,7 +83,14 @@ class RemoteRepository(object): if location.host == '__testsuite__': args = [sys.executable, '-m', 'attic.archiver', 'serve'] else: - args = ['ssh', '-p', str(location.port), '%s@%s' % (location.user or getpass.getuser(), location.host), 'attic', 'serve'] + args = ['ssh',] + if location.port: + args += ['-p', str(location.port)] + if location.user: + args.append('%s@%s' % (location.user, location.host)) + else: + args.append('%s' % location.host) + args += ['attic', 'serve'] self.p = Popen(args, bufsize=0, stdin=PIPE, stdout=PIPE) self.stdin_fd = self.p.stdin.fileno() self.stdout_fd = self.p.stdout.fileno() diff --git a/attic/testsuite/helpers.py b/attic/testsuite/helpers.py index 892eb8e13..0adc4339c 100644 --- a/attic/testsuite/helpers.py +++ b/attic/testsuite/helpers.py @@ -16,7 +16,7 @@ class LocationTestCase(AtticTestCase): ) self.assert_equal( repr(Location('user@host:/some/path::archive')), - "Location(proto='ssh', user='user', host='host', port=22, path='/some/path', archive='archive')" + "Location(proto='ssh', user='user', host='host', port=None, path='/some/path', archive='archive')" ) self.assert_equal( repr(Location('mybackup.attic::archive')),