~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2007-06-09 14:05:42 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20070609140542-z4i71q3ubwmywno7
Don't squawk when bzrlib is the next dev version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Aaron Bentley
2
 
# <aaron.bentley@utoronto.ca>
 
1
# Copyright (C) 2005, 2006, 2007 Aaron Bentley <aaron.bentley@utoronto.ca>
 
2
# Copyright (C) 2007 John Arbash Meinel
3
3
#
4
4
#    This program is free software; you can redistribute it and/or modify
5
5
#    it under the terms of the GNU General Public License as published by
40
40
def is_clean(cur_tree):
41
41
    """
42
42
    Return true if no files are modifed or unknown
43
 
    >>> import bzrlib.add
44
 
    >>> tree = temp_tree()
45
 
    >>> is_clean(tree)
46
 
    (True, [])
47
 
    >>> fooname = os.path.join(tree.basedir, "foo")
48
 
    >>> file(fooname, "wb").write("bar")
49
 
    >>> is_clean(tree)
50
 
    (True, [u'foo'])
51
 
    >>> bzrlib.add.smart_add_tree(tree, [tree.basedir])
52
 
    ([u'foo'], {})
53
 
    >>> is_clean(tree)
54
 
    (False, [])
55
 
    >>> tree.commit("added file", rev_id='commit-id')
56
 
    'commit-id'
57
 
    >>> is_clean(tree)
58
 
    (True, [])
59
 
    >>> rm_tree(tree)
60
43
    """
61
 
    from bzrlib.diff import compare_trees
62
44
    old_tree = cur_tree.basis_tree()
63
45
    new_tree = cur_tree
64
46
    non_source = []
65
 
    for path, file_class, kind, file_id, entry in new_tree.list_files():
66
 
        if file_class in ('?', 'I'):
67
 
            non_source.append(path)
68
 
    delta = compare_trees(old_tree, new_tree, want_unchanged=False)
 
47
    new_tree.lock_read()
 
48
    try:
 
49
        for path, file_class, kind, file_id, entry in new_tree.list_files():
 
50
            if file_class in ('?', 'I'):
 
51
                non_source.append(path)
 
52
        delta = new_tree.changes_from(old_tree, want_unchanged=False)
 
53
    finally:
 
54
        new_tree.unlock()
69
55
    return not delta.has_changed(), non_source
70
56
 
71
57
def set_push_data(tree, location):
250
236
    if push_location is None:
251
237
        raise BzrCommandError("No rspush location known or specified.")
252
238
 
 
239
    if (push_location.find('::') != -1):
 
240
        usessh=False
 
241
    else:
 
242
        usessh=True
 
243
 
253
244
    if (push_location.find('://') != -1 or
254
245
        push_location.find(':') == -1):
255
246
        raise BzrCommandError("Invalid rsync path %r." % push_location)
284
275
                " specified location.  Please ensure that"
285
276
                ' "%s" is of the form "machine:/path".' % push_location)
286
277
    print "Pushing to %s" % push_location
287
 
    rsync(tree.basedir+'/', push_location, ssh=True, 
 
278
    rsync(tree.basedir+'/', push_location, ssh=usessh, 
288
279
          excludes=final_exclusions)
289
280
 
290
281
    set_push_data(tree, push_location)