Exemplo n.º 1
0
def main():
    parser = OptionParser(usage="Usage: %prog [options] [pkgname [verfilename]]",
                          version="%prog " + str(__version__),
                          prog=EXE_NAME)
    parser.add_option("-q", "--quiet", default=False, action="store_true",
                      help="Be quiet, do the job without any output.")
    parser.add_option("--count-all-patches", "--revision-number", default=False,
                      action="store_true", dest="count_all_patches",
                      help="By default %s counts the number of patches since the "
                           "most recent release tag. With this option, it counts "
                           "all the patches in the repository." % EXE_NAME)

    options, args = parser.parse_args()

    if args:
        pkgname = args.pop(0)
    else:
        pkgname = os.path.basename(os.getcwd())
        if not options.quiet:
            print "%s: You didn't pass a pkg-name on the command-line, so I'm going to take the name of the current working directory: \"%s\"" % (EXE_NAME, pkgname,)

    if args:
        verfilename = args.pop(0)
    else:
        verfilename = os.path.join(pkgname, "_version.py")
        if not options.quiet:
            print "%s: You didn't pass a verfilename on the command-line, so I'm going to build one from the name of the package: \"%s\"" % (EXE_NAME, verfilename,)

    (rc, newverstr) = darcsvermodule.update(pkgname=pkgname, verfilename=verfilename, revision_number=options.count_all_patches, quiet=options.quiet, EXE_NAME=EXE_NAME)
    return rc
Exemplo n.º 2
0
 def try_from_darcs(self, target):
     from darcsver.darcsvermodule import update
     (rc, verstr) = update(pkgname=self.distribution.get_name(),
                           verfilename=self.distribution.versionfiles,
                           revision_number=True,
                           version_body=DARCS_VERSION_BODY)
     if rc == 0:
         return verstr
Exemplo n.º 3
0
 def try_from_darcs(self, target):
     from darcsver.darcsvermodule import update
     (rc, verstr) = update(pkgname=self.distribution.get_name(),
                           verfilename=self.distribution.versionfiles,
                           revision_number=True,
                           version_body=DARCS_VERSION_BODY)
     if rc == 0:
         return verstr
Exemplo n.º 4
0
    def run(self):
        if self.distribution.versionfiles is None:
            toppackage = ''
            # If there is a package with the same name as the project name and
            # there is a directory by that name then use that.
            packagedir = None
            if self.distribution.packages and self.project_name in self.distribution.packages:
                toppackage = self.project_name
                srcdir = ''
                if self.distribution.package_dir:
                    srcdir = self.distribution.package_dir.get(toppackage)
                    if not srcdir is None:
                        srcdir = self.distribution.package_dir.get('', '')
                packagedir = os.path.join(srcdir, toppackage)

            if packagedir is None or not os.path.isdir(packagedir):
                # Else, if there is a singly-rooted tree of packages, use the
                # root of that.
                if self.distribution.packages:
                    for package in self.distribution.packages:
                        if not toppackage:
                            toppackage = package
                        else:
                            if toppackage.startswith(package + "."):
                                toppackage = package
                            else:
                                if not package.startswith(toppackage + "."):
                                    # Not singly-rooted
                                    toppackage = ''
                                    break

                srcdir = ''
                if self.distribution.package_dir:
                    srcdir = self.distribution.package_dir.get(toppackage)
                    if srcdir is None:
                        srcdir = self.distribution.package_dir.get('', '')
                packagedir = os.path.join(srcdir, toppackage)

            self.distribution.versionfiles = [
                os.path.join(packagedir, '_version.py')
            ]

        if self.distribution.versionbodies is None:
            self.distribution.versionbodies = [PYTHON_VERSION_BODY]

        assert all([
            isinstance(vfn, basestring)
            for vfn in self.distribution.versionfiles
        ]), self.distribution.versionfiles
        (rc, verstr) = darcsvermodule.update(
            self.project_name,
            self.distribution.versionfiles,
            self.count_all_patches,
            abort_if_snapshot=self.abort_if_snapshot,
            EXE_NAME="setup.py darcsver",
            version_body=self.distribution.versionbodies)
        if rc == 0:
            self.distribution.metadata.version = verstr
Exemplo n.º 5
0
    def run(self):
        if self.distribution.versionfiles is None:
            toppackage = ""
            # If there is a package with the same name as the project name and
            # there is a directory by that name then use that.
            packagedir = None
            if self.distribution.packages and self.project_name in self.distribution.packages:
                toppackage = self.project_name
                srcdir = ""
                if self.distribution.package_dir:
                    srcdir = self.distribution.package_dir.get(toppackage)
                    if not srcdir is None:
                        srcdir = self.distribution.package_dir.get("", "")
                packagedir = os.path.join(srcdir, toppackage)

            if packagedir is None or not os.path.isdir(packagedir):
                # Else, if there is a singly-rooted tree of packages, use the
                # root of that.
                if self.distribution.packages:
                    for package in self.distribution.packages:
                        if not toppackage:
                            toppackage = package
                        else:
                            if toppackage.startswith(package + "."):
                                toppackage = package
                            else:
                                if not package.startswith(toppackage + "."):
                                    # Not singly-rooted
                                    toppackage = ""
                                    break

                srcdir = ""
                if self.distribution.package_dir:
                    srcdir = self.distribution.package_dir.get(toppackage)
                    if srcdir is None:
                        srcdir = self.distribution.package_dir.get("", "")
                packagedir = os.path.join(srcdir, toppackage)

            self.distribution.versionfiles = [os.path.join(packagedir, "_version.py")]

        if self.distribution.versionbodies is None:
            self.distribution.versionbodies = [PYTHON_VERSION_BODY]

        assert all(
            [isinstance(vfn, basestring) for vfn in self.distribution.versionfiles]
        ), self.distribution.versionfiles
        (rc, verstr) = darcsvermodule.update(
            self.project_name,
            self.distribution.versionfiles,
            self.count_all_patches,
            abort_if_snapshot=self.abort_if_snapshot,
            EXE_NAME="setup.py darcsver",
            version_body=self.distribution.versionbodies,
        )
        if rc == 0:
            self.distribution.metadata.version = verstr