~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-03-25 06:08:01 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060325060801-eb4909f92e6e9adc
Tweakage of the apache scraper

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)
60
59
    """
 
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 = new_tree.changes_from(old_tree, want_unchanged=False)
 
67
    delta = compare_trees(old_tree, new_tree, want_unchanged=False)
68
68
    return not delta.has_changed(), non_source
69
69
 
70
70
def set_push_data(tree, location):
71
 
    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)
72
73
 
73
74
def get_push_data(tree):
74
75
    """
77
78
    True
78
79
    >>> set_push_data(tree, 'http://somewhere')
79
80
    >>> get_push_data(tree)
80
 
    u'http://somewhere'
 
81
    'http://somewhere'
81
82
    >>> rm_tree(tree)
82
83
    """
83
 
    try:
84
 
        location = tree.branch.control_files.get_utf8('x-push-data').read()
85
 
    except NoSuchFile:
 
84
    filename = tree.branch.control_files.controlfilename("x-push-data")
 
85
    if not os.path.exists(filename):
86
86
        return None
87
 
    return location.rstrip('\n')
 
87
    push_file = file (filename, "rb")
 
88
    (location,) = [f.rstrip('\n') for f in push_file]
 
89
    return location
88
90
 
89
91
"""
90
92
>>> shell_escape('hello')
239
241
    except RsyncNoFile:
240
242
        return True
241
243
 
242
 
def rspush(tree, location=None, overwrite=False, working_tree=True):
 
244
def push(tree, location=None, overwrite=False, working_tree=True):
243
245
    push_location = get_push_data(tree)
244
246
    if location is not None:
245
247
        if not location.endswith('/'):
247
249
        push_location = location
248
250
    
249
251
    if push_location is None:
250
 
        raise BzrCommandError("No rspush location known or specified.")
251
 
 
252
 
    if (push_location.find('://') != -1 or
253
 
        push_location.find(':') == -1):
254
 
        raise BzrCommandError("Invalid rsync path %r." % push_location)
 
252
        if tree.branch.get_push_location() is None:
 
253
            raise BzrCommandError("No push location known or specified.")
 
254
        else:
 
255
            raise bzrlib.errors.MustUseDecorated
 
256
 
 
257
    if push_location.find('://') != -1:
 
258
        raise bzrlib.errors.MustUseDecorated
 
259
 
 
260
    if push_location.find(':') == -1:
 
261
        raise bzrlib.errors.MustUseDecorated
255
262
 
256
263
    if working_tree:
257
264
        clean, non_source = is_clean(tree)