~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz2bzr

  • Committer: Aaron Bentley
  • Date: 2005-06-08 15:02:28 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050608150228-4d9daad616b1213e
Continued symlink fix, cleaned up merge, error message

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
    ancestors.reverse()
173
173
    return ancestors
174
174
 
 
175
def get_last_revision(branch):
 
176
    last_patch = branch.last_patch()
 
177
    try:
 
178
        return arch_revision(last_patch)
 
179
    except NotArchRevision:
 
180
        raise UserError(
 
181
            "Directory \"%s\" already exists, and the last revision is not"
 
182
            " an Arch revision (%s)" % (output_dir, last_patch))
 
183
 
 
184
 
175
185
def get_remaining_revisions(output_dir, version):
176
186
    last_patch = None
177
187
    old_revno = None
179
189
        # We are starting from an existing directory, figure out what
180
190
        # the current version is
181
191
        branch = bzrlib.Branch(output_dir)
182
 
        last_patch = branch.last_patch()
183
 
        try:
184
 
            last_patch = arch_revision(last_patch)
185
 
        except NotArchRevision:
186
 
            raise UserError(
187
 
                "Directory \"%s\" already exists, and the last revision is not"
188
 
                " an Arch revision (%s)" % (output_dir, last_patch))
 
192
        last_patch = get_last_revision(branch)
189
193
        if version is None:
190
194
            version = last_patch.version
191
195
    elif version is None:
224
228
    """
225
229
    ancestors, old_revno = get_remaining_revisions(output_dir, version)
226
230
    if len(ancestors) == 0:
227
 
        print '* Tree is up-to-date with %s' % last_patch
 
231
        last_revision = get_last_revision(bzrlib.Branch(output_dir))
 
232
        print '* Tree is up-to-date with %s' % last_revision
228
233
        return 0
229
234
 
230
235
    progress_bar = ProgressBar()
256
261
            try:
257
262
                # bzrlib.merge that exists in mainline does not have a this_dir component,
258
263
                # so we have to work in the local directory
259
 
                try:
260
 
                    pwd = os.getcwd()
261
 
                    os.chdir(output_dir)
262
 
                    bzrlib.merge.merge(('.', -1), ('.', old_revno))
263
 
                finally:
264
 
                    os.chdir(pwd)
 
264
                bzrlib.merge.merge(('.', -1), ('.', old_revno), 
 
265
                                   check_clean=False, this_dir=output_dir, 
 
266
                                   ignore_zero=True)
265
267
            except:
266
268
                # If something failed, move back the original bzr directory
267
269
                os.rename(bzr_dir, new_bzr_dir)
516
518
        
517
519
        import_version(output_dir, version,
518
520
            verbose=opts.verbose, fast=opts.fast,
519
 
            fancy=opts.fancy, dry_run=opts.dry_run,
520
 
            max_count=opts.max_count, skip_symlinks=opts.skip_symlinks)
 
521
            dry_run=opts.dry_run, max_count=opts.max_count,
 
522
            skip_symlinks=opts.skip_symlinks)
521
523
        return 0
522
524
    except UserError, e:
523
525
        print e