~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-05-18 16:36:49 UTC
  • Revision ID: abentley@panoramicfeedback.com-20060518163649-f37d1b11e4eac43e
Handle adds and removes efficiently

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", rev_id='commit-id')
56
 
    'commit-id'
 
55
    >>> tree.commit("added file")
57
56
    >>> is_clean(tree)
58
57
    (True, [])
59
58
    >>> rm_tree(tree)
69
68
    return not delta.has_changed(), non_source
70
69
 
71
70
def set_push_data(tree, location):
72
 
    tree.branch.control_files.put_utf8("x-push-data", "%s\n" % location)
 
71
    push_file = file (tree.branch.control_files.controlfilename("x-push-data"), "wb")
 
72
    push_file.write("%s\n" % location)
73
73
 
74
74
def get_push_data(tree):
75
75
    """
78
78
    True
79
79
    >>> set_push_data(tree, 'http://somewhere')
80
80
    >>> get_push_data(tree)
81
 
    u'http://somewhere'
 
81
    'http://somewhere'
82
82
    >>> rm_tree(tree)
83
83
    """
84
 
    try:
85
 
        location = tree.branch.control_files.get_utf8('x-push-data').read()
86
 
    except NoSuchFile:
 
84
    filename = tree.branch.control_files.controlfilename("x-push-data")
 
85
    if not os.path.exists(filename):
87
86
        return None
88
 
    return location.rstrip('\n')
 
87
    push_file = file (filename, "rb")
 
88
    (location,) = [f.rstrip('\n') for f in push_file]
 
89
    return location
89
90
 
90
91
"""
91
92
>>> shell_escape('hello')