~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2005-09-10 21:49:22 UTC
  • mfrom: (0.7.2)
  • mto: (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: aaron.bentley@utoronto.ca-20050910214922-36c6341e698259df
merged John's latest stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
 
67
67
    If --verbose, renames will be given as an 'add + delete' style patch.
 
68
    If --revision is given, it has several states:
 
69
        --revision A..B A is chosen as the base and B is chosen as the target
 
70
        --revision A    A is chosen as the target, and the base is it's primary parent
 
71
        --revision ..B  B is chosen as the target, and the base is it's primary parent
 
72
        --revision A..  ???
68
73
    """
69
 
    takes_options = ['verbose']
 
74
    takes_options = ['verbose', 'revision']
70
75
    takes_args = ['base?', 'target?', 'starting-rev-id?']
71
76
    aliases = ['cset']
72
77
 
73
 
    def run(self, base=None, target=None, starting_rev_id=None, verbose=False):
 
78
    def run(self, base=None, target=None, starting_rev_id=None, verbose=False, revision=None):
74
79
        from bzrlib.branch import find_branch
75
80
        from bzrlib.commands import parse_spec
76
81
        from bzrlib.errors import BzrCommandError
79
84
        import sys
80
85
        import codecs
81
86
 
82
 
        if target is None:
83
 
            target = './@'
84
 
        b_target_path, target_revno = parse_spec(target)
85
 
        target_branch = find_branch(b_target_path)
86
 
        if target_revno is None or target_revno == -1:
87
 
            target_rev_id = target_branch.last_patch()
88
 
        else:
89
 
            target_rev_id = target_branch.lookup_revision(target_revno)
 
87
        if revision is not None:
 
88
            if (target is not None or base is not None):
 
89
                raise BzrCommandError('--revision superceeds base and target')
 
90
            if len(revision) == 1:
 
91
                target_info = revision[0]
 
92
                base_info = None
 
93
            elif len(revision) == 2:
 
94
                target_info = revision[1]
 
95
                base_info = revision[0]
 
96
            else:
 
97
                raise BzrCommandError('--revision can take at most 2 arguments')
90
98
 
91
 
        if base is None:
 
99
            target_branch = find_branch('.')
 
100
            target_rev_id = target_branch.lookup_revision(target_info)
92
101
            base_branch = target_branch
93
 
            target_rev = target_branch.get_revision(target_rev_id)
94
 
            base_rev_id = target_rev.parents[0].revision_id
 
102
            if base_info is not None:
 
103
                base_rev_id = target_branch.lookup_revision(base_info)
 
104
            else:
 
105
                target_rev = target_branch.get_revision(target_rev_id)
 
106
                base_rev_id = target_rev.parents[0].revision_id
95
107
        else:
96
 
            base_path, base_revno = parse_spec(base)
97
 
            base_branch = find_branch(base_path)
98
 
            if base_revno is None or base_revno == -1:
99
 
                base_rev_id = base_branch.last_patch()
100
 
            else:
101
 
                base_rev_id = base_branch.lookup_revision(base_revno)
 
108
            if target is None:
 
109
                target = './@'
 
110
            b_target_path, target_revno = parse_spec(target)
 
111
            target_branch = find_branch(b_target_path)
 
112
            if target_revno is None or target_revno == -1:
 
113
                target_rev_id = target_branch.last_patch()
 
114
            else:
 
115
                target_rev_id = target_branch.lookup_revision(target_revno)
 
116
 
 
117
            if base is None:
 
118
                base_branch = target_branch
 
119
                target_rev = target_branch.get_revision(target_rev_id)
 
120
                base_rev_id = target_rev.parents[0].revision_id
 
121
            else:
 
122
                base_path, base_revno = parse_spec(base)
 
123
                base_branch = find_branch(base_path)
 
124
                if base_revno is None or base_revno == -1:
 
125
                    base_rev_id = base_branch.last_patch()
 
126
                else:
 
127
                    base_rev_id = base_branch.lookup_revision(base_revno)
102
128
 
103
129
        # outf = codecs.getwriter(user_encoding)(sys.stdout,
104
130
        #         errors='replace')