~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-12-22 18:31:21 UTC
  • mto: (481.1.1 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: abentley@panoramicfeedback.com-20061222183121-fvvrasz8s2w6nbis
graph-ancestry can restrict the number of nodes shown by distance

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    ([u'foo'], {})
53
53
    >>> is_clean(tree)
54
54
    (False, [])
55
 
    >>> tree.commit("added file")
 
55
    >>> tree.commit("added file", rev_id='commit-id')
 
56
    'commit-id'
56
57
    >>> is_clean(tree)
57
58
    (True, [])
58
59
    >>> rm_tree(tree)
59
60
    """
60
 
    from bzrlib.diff import compare_trees
61
61
    old_tree = cur_tree.basis_tree()
62
62
    new_tree = cur_tree
63
63
    non_source = []
64
64
    for path, file_class, kind, file_id, entry in new_tree.list_files():
65
65
        if file_class in ('?', 'I'):
66
66
            non_source.append(path)
67
 
    delta = compare_trees(old_tree, new_tree, want_unchanged=False)
 
67
    delta = new_tree.changes_from(old_tree, want_unchanged=False)
68
68
    return not delta.has_changed(), non_source
69
69
 
70
70
def set_push_data(tree, location):
71
 
    push_file = file (tree.branch.control_files.controlfilename("x-push-data"), "wb")
72
 
    push_file.write("%s\n" % location)
 
71
    tree.branch.control_files.put_utf8("x-push-data", "%s\n" % location)
73
72
 
74
73
def get_push_data(tree):
75
74
    """
78
77
    True
79
78
    >>> set_push_data(tree, 'http://somewhere')
80
79
    >>> get_push_data(tree)
81
 
    'http://somewhere'
 
80
    u'http://somewhere'
82
81
    >>> rm_tree(tree)
83
82
    """
84
 
    filename = tree.branch.control_files.controlfilename("x-push-data")
85
 
    if not os.path.exists(filename):
 
83
    try:
 
84
        location = tree.branch.control_files.get_utf8('x-push-data').read()
 
85
    except NoSuchFile:
86
86
        return None
87
 
    push_file = file (filename, "rb")
88
 
    (location,) = [f.rstrip('\n') for f in push_file]
89
 
    return location
 
87
    return location.rstrip('\n')
90
88
 
91
89
"""
92
90
>>> shell_escape('hello')
251
249
    if push_location is None:
252
250
        raise BzrCommandError("No rspush location known or specified.")
253
251
 
 
252
    if (push_location.find('::') != -1):
 
253
        usessh=False
 
254
    else:
 
255
        usessh=True
 
256
 
254
257
    if (push_location.find('://') != -1 or
255
258
        push_location.find(':') == -1):
256
259
        raise BzrCommandError("Invalid rsync path %r." % push_location)
285
288
                " specified location.  Please ensure that"
286
289
                ' "%s" is of the form "machine:/path".' % push_location)
287
290
    print "Pushing to %s" % push_location
288
 
    rsync(tree.basedir+'/', push_location, ssh=True, 
 
291
    rsync(tree.basedir+'/', push_location, ssh=usessh, 
289
292
          excludes=final_exclusions)
290
293
 
291
294
    set_push_data(tree, push_location)