~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzr-pull

  • Committer: abentley
  • Date: 2005-05-01 12:36:53 UTC
  • Revision ID: abentley@lappy-20050501123653-744e6a1b9c19b316
Finished implementing bzr-pull

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from bzrlib import Branch
20
20
from bzrlib.diff import diff_trees
21
21
import sys
 
22
import os
22
23
import scriptlib
23
24
bzrlib.trace.create_tracefile([])
24
25
 
25
26
cur_branch = Branch(".")
 
27
pull_location, pull_revision = scriptlib.get_pull_data(cur_branch)
 
28
if pull_location is not None:
 
29
    if cur_branch.last_patch() != pull_revision:
 
30
        print "Aborting: This branch has had commits, so pull would lose data."
 
31
        sys.exit(1)
 
32
if len(sys.argv) > 1:
 
33
    pull_location = sys.argv[1] 
 
34
    if not pull_location.endswith('/'):
 
35
        pull_location.append('/')
 
36
 
 
37
if pull_location is None:
 
38
    print "No pull location saved.  Please specify one on the command line."
 
39
    sys.exit(1)
26
40
 
27
41
if not scriptlib.is_clean(cur_branch):
28
42
    print "Error: This tree has uncommitted changes or unknown (?) files."
29
43
    sys.exit(1)
30
 
location = cur_branch.controlfilename("pull-location")
 
44
 
 
45
print "Synchronizing with %s" % pull_location
 
46
args = " ".join(("rsync", "-av", "--delete", pull_location, cur_branch.base))
 
47
os.system(args)
 
48
 
 
49
scriptlib.set_pull_data(cur_branch, pull_location, cur_branch.last_patch())