~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2007-06-10 17:55:08 UTC
  • mfrom: (531.2.2 bzrtools)
  • Revision ID: aaron.bentley@utoronto.ca-20070610175508-gex1oxvmfv0qoagi
Merge whitespace cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import bzrlib
27
27
import bzrlib.errors
28
28
from bzrlib.errors import (BzrCommandError, NotBranchError, NoSuchFile,
29
 
                           UnsupportedFormatError, TransportError, 
 
29
                           UnsupportedFormatError, TransportError,
30
30
                           NoWorkingTree, PermissionDenied)
31
31
from bzrlib.bzrdir import BzrDir, BzrDirFormat
32
32
 
99
99
    def __init__(self, rsync_name):
100
100
        Exception.__init__(self, "%s not found." % rsync_name)
101
101
 
102
 
def rsync(source, target, ssh=False, excludes=(), silent=False, 
 
102
def rsync(source, target, ssh=False, excludes=(), silent=False,
103
103
          rsync_name="rsync"):
104
104
    """
105
105
    >>> new_dir = tempfile.mkdtemp()
134
134
    except OSError, e:
135
135
        if e.errno == errno.ENOENT:
136
136
            raise NoRsync(rsync_name)
137
 
            
 
137
 
138
138
    proc.stdin.write('\n'.join(excludes)+'\n')
139
139
    proc.stdin.close()
140
140
    if silent:
176
176
        raise RsyncUnknownStatus(proc.returncode)
177
177
    return [l.split(' ')[-1].rstrip('\n') for l in result.splitlines(True)]
178
178
 
179
 
exclusions = ('.bzr/x-push-data', '.bzr/branch/x-push/data', '.bzr/parent', 
 
179
exclusions = ('.bzr/x-push-data', '.bzr/branch/x-push/data', '.bzr/parent',
180
180
              '.bzr/branch/parent', '.bzr/x-pull-data', '.bzr/x-pull',
181
181
              '.bzr/pull', '.bzr/stat-cache', '.bzr/x-rsync-data',
182
182
              '.bzr/basis-inventory', '.bzr/inventory.backup.weave')
216
216
        return False
217
217
    for local, remote in zip(remote_history, local_history):
218
218
        if local != remote:
219
 
            return False 
 
219
            return False
220
220
    return True
221
221
 
222
222
def empty_or_absent(location):
232
232
        if not location.endswith('/'):
233
233
            location += '/'
234
234
        push_location = location
235
 
    
 
235
 
236
236
    if push_location is None:
237
237
        raise BzrCommandError("No rspush location known or specified.")
238
238
 
275
275
                " specified location.  Please ensure that"
276
276
                ' "%s" is of the form "machine:/path".' % push_location)
277
277
    print "Pushing to %s" % push_location
278
 
    rsync(tree.basedir+'/', push_location, ssh=usessh, 
 
278
    rsync(tree.basedir+'/', push_location, ssh=usessh,
279
279
          excludes=final_exclusions)
280
280
 
281
281
    set_push_data(tree, push_location)
354
354
    except (NoSuchFile, PermissionDenied, TransportError):
355
355
        pass
356
356
 
357
 
    
 
357
 
358
358
def bzrdir_from_transport(t):
359
359
    """Open a bzrdir from a transport (not a location)"""
360
360
    format = BzrDirFormat.find_format(t)