~jelmer/brz-debian/swap-arguments

« back to all changes in this revision

Viewing changes to util.py

  • Committer: Jelmer Vernooij
  • Date: 2017-11-14 04:33:50 UTC
  • Revision ID: jelmer@jelmer.uk-20171114043350-e8kd31e7pmz33a0j
Swap arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from __future__ import absolute_import
22
22
 
 
23
import errno
23
24
try:
24
25
    import hashlib as md5
25
26
except ImportError:
187
188
            # If it is a "top_level" package and debian is a symlink to
188
189
            # "." then it will have found debian/changelog. Try and detect
189
190
            # this.
190
 
            debian_file_id = t.path2id('debian')
191
 
            if (debian_file_id is not None and 
192
 
                t.kind(debian_file_id) == 'symlink' and 
193
 
                t.get_symlink_target(t.path2id('debian')) == '.'):
 
191
            if (t.path2id('debian') and
 
192
                t.kind('debian') == 'symlink' and
 
193
                t.get_symlink_target('debian') == '.'):
194
194
                changelog_file = 'changelog'
195
195
                top_level = True
196
196
        mutter("Using '%s' to get package information", changelog_file)
197
 
        changelog_id = t.path2id(changelog_file)
198
 
        if changelog_id is None:
 
197
        if t.path2id(changelog_file) is None:
199
198
            raise AddChangelogError(changelog_file)
200
 
        contents = t.get_file_text(changelog_id)
 
199
        contents = t.get_file_text(changelog_file)
201
200
    finally:
202
201
       t.unlock()
203
202
    changelog = Changelog()
562
561
    user_config = None
563
562
    if (working_tree and tree.has_filename(new_local_conf)):
564
563
        if tree.path2id(new_local_conf) is None:
565
 
            config_files.append((tree.get_file_byname(new_local_conf), True,
 
564
            config_files.append((tree.get_file(new_local_conf), True,
566
565
                        "local.conf"))
567
566
        else:
568
567
            warning('Not using configuration from %s as it is versioned.',
569
568
                    new_local_conf)
570
569
    if (working_tree and tree.has_filename(local_conf)):
571
570
        if tree.path2id(local_conf) is None:
572
 
            config_files.append((tree.get_file_byname(local_conf), True,
 
571
            config_files.append((tree.get_file(local_conf), True,
573
572
                        "local.conf"))
574
573
        else:
575
574
            warning('Not using configuration from %s as it is versioned.',
577
576
    config_files.append((global_conf(), True))
578
577
    user_config = global_conf()
579
578
    if tree.path2id(new_conf):
580
 
        config_files.append((tree.get_file(tree.path2id(new_conf)), False,
 
579
        config_files.append((tree.get_file(new_conf), False,
581
580
                    "bzr-builddeb.conf"))
582
581
    if tree.path2id(default_conf):
583
 
        config_files.append((tree.get_file(tree.path2id(default_conf)), False,
 
582
        config_files.append((tree.get_file(default_conf), False,
584
583
                    "default.conf"))
585
584
    config = DebBuildConfig(config_files, tree=tree)
586
585
    config.set_user_config(user_config)
664
663
    :return: String with package format
665
664
    """
666
665
    filename = "debian/source/format"
667
 
    if not tree.has_filename(filename):
 
666
    try:
 
667
        text = tree.get_file_text(filename)
 
668
    except IOError as (num, unused_msg):
 
669
        if num == errno.ENOENT:
 
670
            return FORMAT_1_0
 
671
        raise
 
672
    except errors.NoSuchFile:
668
673
        return FORMAT_1_0
669
 
    file_id = tree.path2id(filename)
670
 
    text = tree.get_file_text(file_id, filename)
671
674
    return text.strip()
672
675
 
673
676