Esempio n. 1
0
    def _mksubs(self):
        self._subs = {}

        tags = git.tags()

        revs = list(git.rev_list(self.hash.encode('hex')))
        latest = revs[0]
        for (date, commit) in revs:
            l = time.localtime(date)
            ls = time.strftime('%Y-%m-%d-%H%M%S', l)
            commithex = commit.encode('hex')
            target = '../.commit/%s/%s' % (commithex[:2], commithex[2:])
            n1 = FakeSymlink(self, ls, target)
            n1.ctime = n1.mtime = date
            self._subs[ls] = n1

            for tag in tags.get(commit, []):
                t1 = FakeSymlink(self, tag, target)
                t1.ctime = t1.mtime = date
                self._subs[tag] = t1

        (date, commit) = latest
        commithex = commit.encode('hex')
        target = '../.commit/%s/%s' % (commithex[:2], commithex[2:])
        n1 = FakeSymlink(self, 'latest', target)
        n1.ctime = n1.mtime = date
        self._subs['latest'] = n1
Esempio n. 2
0
def main(argv):
    o = options.Options(optspec)
    opt, flags, extra = o.parse_bytes(argv[1:])

    git.check_repo_or_die()

    tags = [t for sublist in git.tags().values() for t in sublist]

    if opt.delete:
        # git.delete_ref() doesn't complain if a ref doesn't exist.  We
        # could implement this verification but we'd need to read in the
        # contents of the tag file and pass the hash, and we already know
        # about the tag's existance via "tags".
        tag_name = argv_bytes(opt.delete)
        if not opt.force and tag_name not in tags:
            log("error: tag '%s' doesn't exist\n" % path_msg(tag_name))
            sys.exit(1)
        tag_file = b'refs/tags/%s' % tag_name
        git.delete_ref(tag_file)
        sys.exit(0)

    if not extra:
        for t in tags:
            sys.stdout.flush()
            out = byte_stream(sys.stdout)
            out.write(t)
            out.write(b'\n')
        sys.exit(0)
    elif len(extra) != 2:
        o.fatal('expected commit ref and hash')

    tag_name, commit = map(argv_bytes, extra[:2])
    if not tag_name:
        o.fatal("tag name must not be empty.")
    debug1("args: tag name = %s; commit = %s\n" %
           (path_msg(tag_name), commit.decode('ascii')))

    if tag_name in tags and not opt.force:
        log("bup: error: tag '%s' already exists\n" % path_msg(tag_name))
        sys.exit(1)

    if tag_name.startswith(b'.'):
        o.fatal("'%s' is not a valid tag name." % path_msg(tag_name))

    try:
        hash = git.rev_parse(commit)
    except git.GitError as e:
        log("bup: error: %s" % e)
        sys.exit(2)

    if not hash:
        log("bup: error: commit %s not found.\n" % commit.decode('ascii'))
        sys.exit(2)

    with git.PackIdxList(git.repo(b'objects/pack')) as pL:
        if not pL.exists(hash):
            log("bup: error: commit %s not found.\n" % commit.decode('ascii'))
            sys.exit(2)

    git.update_ref(b'refs/tags/' + tag_name, hash, None, force=True)
Esempio n. 3
0
File: vfs.py Progetto: Kelimion/bup
    def _mksubs(self):
        self._subs = {}

        tags = git.tags()

        revs = list(git.rev_list(self.hash.encode('hex')))
        latest = revs[0]
        for (date, commit) in revs:
            l = time.localtime(date)
            ls = time.strftime('%Y-%m-%d-%H%M%S', l)
            commithex = commit.encode('hex')
            target = '../.commit/%s/%s' % (commithex[:2], commithex[2:])
            n1 = FakeSymlink(self, ls, target)
            n1.ctime = n1.mtime = date
            self._subs[ls] = n1

            for tag in tags.get(commit, []):
                t1 = FakeSymlink(self, tag, target)
                t1.ctime = t1.mtime = date
                self._subs[tag] = t1

        (date, commit) = latest
        commithex = commit.encode('hex')
        target = '../.commit/%s/%s' % (commithex[:2], commithex[2:])
        n1 = FakeSymlink(self, 'latest', target)
        n1.ctime = n1.mtime = date
        self._subs['latest'] = n1
Esempio n. 4
0
File: vfs.py Progetto: pfrouleau/bup
    def _mksubs(self):
        self._subs = {}

        tags = git.tags(repo_dir=self._repo_dir)

        revs = list(git.rev_list(self.hash.encode("hex"), repo_dir=self._repo_dir))
        latest = revs[0]
        for (date, commit) in revs:
            l = time.localtime(date)
            ls = time.strftime("%Y-%m-%d-%H%M%S", l)
            commithex = commit.encode("hex")
            target = "../.commit/%s/%s" % (commithex[:2], commithex[2:])
            n1 = FakeSymlink(self, ls, target, self._repo_dir)
            n1.ctime = n1.mtime = date
            self._subs[ls] = n1

            for tag in tags.get(commit, []):
                t1 = FakeSymlink(self, tag, target, self._repo_dir)
                t1.ctime = t1.mtime = date
                self._subs[tag] = t1

        (date, commit) = latest
        commithex = commit.encode("hex")
        target = "../.commit/%s/%s" % (commithex[:2], commithex[2:])
        n1 = FakeSymlink(self, "latest", target, self._repo_dir)
        n1.ctime = n1.mtime = date
        self._subs["latest"] = n1
Esempio n. 5
0
File: tag-cmd.py Progetto: yafey/bup
optspec = """
bup tag
bup tag [-f] <tag name> <commit>
bup tag [-f] -d <tag name>
--
d,delete=   Delete a tag
f,force     Overwrite existing tag, or ignore missing tag when deleting
"""

o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])

git.check_repo_or_die()

tags = [t for sublist in git.tags().values() for t in sublist]

if opt.delete:
    # git.delete_ref() doesn't complain if a ref doesn't exist.  We
    # could implement this verification but we'd need to read in the
    # contents of the tag file and pass the hash, and we already know
    # about the tag's existance via "tags".
    if not opt.force and opt.delete not in tags:
        log("error: tag '%s' doesn't exist\n" % opt.delete)
        sys.exit(1)
    tag_file = 'refs/tags/%s' % opt.delete
    git.delete_ref(tag_file)
    sys.exit(0)

if not extra:
    for t in tags: