~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-02-01 04:42:39 UTC
  • mfrom: (310 bzrtools)
  • mto: (147.4.30 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: aaron.bentley@utoronto.ca-20060201044239-7c17ea8d0a18eedb
Merge from bzrtools mainline

Show diffs side-by-side

added added

removed removed

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