~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2005-12-06 20:41:00 UTC
  • Revision ID: abentley@panoramicfeedback.com-20051206204100-0b468f1764f2afb5
Updated graph-ancestry help

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    >>> is_clean(br)
46
46
    (True, [u'foo'])
47
47
    >>> bzrlib.add.smart_add_tree(br.working_tree(), [br.base])
48
 
    ([u'foo'], {})
 
48
    1
49
49
    >>> is_clean(br)
50
50
    (False, [])
51
51
    >>> br.working_tree().commit("added file")
63
63
    delta = compare_trees(old_tree, new_tree, want_unchanged=False)
64
64
    return not delta.has_changed(), non_source
65
65
 
 
66
def set_pull_data(br, location, rev_id):
 
67
    pull_file = file (br.controlfilename("x-pull-data"), "wb")
 
68
    pull_file.write("%s\n%s\n" % (location, rev_id))
 
69
 
 
70
def get_pull_data(br):
 
71
    """
 
72
    >>> br = temp_branch()
 
73
    >>> get_pull_data(br)
 
74
    (None, None)
 
75
    >>> set_pull_data(br, 'http://somewhere', '888-777')
 
76
    >>> get_pull_data(br)
 
77
    ('http://somewhere', '888-777')
 
78
    >>> rm_branch(br)
 
79
    """
 
80
    filename = br.controlfilename("x-pull-data")
 
81
    if not os.path.exists(filename):
 
82
        return (None, None)
 
83
    pull_file = file (filename, "rb")
 
84
    location, rev_id = [f.rstrip('\n') for f in pull_file]
 
85
    return location, rev_id
 
86
 
66
87
def set_push_data(br, location):
67
 
    push_file = file (br.control_files.controlfilename("x-push-data"), "wb")
 
88
    push_file = file (br.controlfilename("x-push-data"), "wb")
68
89
    push_file.write("%s\n" % location)
69
90
 
70
91
def get_push_data(br):
77
98
    'http://somewhere'
78
99
    >>> rm_branch(br)
79
100
    """
80
 
    filename = br.control_files.controlfilename("x-push-data")
 
101
    filename = br.controlfilename("x-push-data")
81
102
    if not os.path.exists(filename):
82
103
        return None
83
104
    push_file = file (filename, "rb")
227
248
    except RsyncNoFile:
228
249
        return True
229
250
 
230
 
def push(cur_branch, location=None, overwrite=False, working_tree=True):
 
251
def push(cur_branch, location=None, overwrite=False):
231
252
    push_location = get_push_data(cur_branch)
232
253
    if location is not None:
233
254
        if not location.endswith('/'):
248
269
        print """Error: This tree has uncommitted changes or unknown (?) files.
249
270
Use "bzr status" to list them."""
250
271
        sys.exit(1)
251
 
    if working_tree:
252
 
        final_exclusions = non_source[:]
253
 
    else:
254
 
        wt = cur_branch.working_tree()
255
 
        final_exclusions = []
256
 
        for path, status, kind, file_id, entry in wt.list_files():
257
 
            final_exclusions.append(path)
258
 
 
259
 
    final_exclusions.extend(exclusions)
 
272
    non_source.extend(exclusions)
260
273
    if not overwrite:
261
274
        try:
262
275
            if not history_subset(push_location, cur_branch):
273
286
                " specified location.  Please ensure that"
274
287
                ' "%s" is of the form "machine:/path".' % push_location)
275
288
    print "Pushing to %s" % push_location
276
 
    rsync(cur_branch.base+'/', push_location, ssh=True, 
277
 
          excludes=final_exclusions)
 
289
    rsync(cur_branch.base+'/', push_location, ssh=True, excludes=non_source)
278
290
 
279
291
    set_push_data(cur_branch, push_location)
280
292