Ejemplo n.º 1
0
 def deltag(self, file):
     if (not self.fsonly) and \
            ((not isdarcs()) and (not ishg())):
         if self.verb:
             print "Deleting %s" % file
         if os.path.islink(os.path.join(self.wcpath,file)) or os.path.exists(os.path.join(self.wcpath, file)):
             util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       cmd().delete + [file])
Ejemplo n.º 2
0
 def deltag(self, file):
     if (not self.fsonly) and \
            ((not isdarcs()) and (not ishg())):
         if self.verb:
             print "Deleting %s" % file
         if os.path.islink(os.path.join(
                 self.wcpath, file)) or os.path.exists(
                     os.path.join(self.wcpath, file)):
             util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                           cmd().delete + [file])
Ejemplo n.º 3
0
 def movetag(self, src, dest):
     if self.verb:
         print "Moving %s to %s" % (src, dest)
     if src[-1] == '/' \
            and dest[-1] == '/' \
            and ((not isdarcs()) and (not isgit()) and (not ishg())):
         # Dir to dir -- darcs mv will catch it already.
         # Git doesn't do rename recording, so don't worry about it?
         return
     src, dest = self.slashstrip(src, dest)
     if not self.fsonly:
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       [cmd().move, src, dest])
Ejemplo n.º 4
0
 def movetag(self, src, dest):
     if self.verb:
         print "Moving %s to %s" % (src, dest)
     if src[-1] == '/' \
            and dest[-1] == '/' \
            and ((not isdarcs()) and (not isgit()) and (not ishg())):
         # Dir to dir -- darcs mv will catch it already.
         # Git doesn't do rename recording, so don't worry about it?
         return
     src, dest = self.slashstrip(src, dest)
     if not self.fsonly:
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       [cmd().move, src, dest])
Ejemplo n.º 5
0
    def movefile(self, src, dest):
        if self.verb:
            print "Moving file %s to %s" % (src, dest)
        src, dest = self.slashstrip(src, dest)

        def doit():
            destdir = os.path.dirname(dest)
            if (not os.path.exists(destdir)) and destdir != '':
                self.makedirs(destdir)
            if self.fsonly or \
               (not isdarcs() and (not isgit()) and (not ishg())):
                # Darcs, hg, and git actually do this when they move the tag
                os.rename(src, dest)

        util.chdircmd(self.wcpath, doit)
Ejemplo n.º 6
0
    def movefile(self, src, dest):
        if self.verb:
            print "Moving file %s to %s" % (src, dest)
        src, dest = self.slashstrip(src, dest)

        def doit():
            destdir = os.path.dirname(dest)
            if (not os.path.exists(destdir)) and destdir != '':
                self.makedirs(destdir)
            if self.fsonly or \
               (not isdarcs() and (not isgit()) and (not ishg())):
                # Darcs, hg, and git actually do this when they move the tag
                os.rename(src, dest)

        util.chdircmd(self.wcpath, doit)
Ejemplo n.º 7
0
 def addtag(self, file):
     if self.verb:
         print "Adding %s" % file
     if (file[-1] == '/') and \
        (not os.path.exists(os.path.join(self.wcpath,
                                         file[:-1]))):
         try:
             print "addtag: making dir %s" % file[:-1]
             os.makedirs(os.path.join(self.wcpath, file[:-1]))
         except:
             raise
     file = self.slashstrip(file)
     isdir = os.path.isdir(os.path.join(self.wcpath, file))
     if (not self.fsonly) and \
            (not ishg()) and ((not isdarcs()) or isdir):
         # Darcs will see adds later, but we need to add dirs
         # now so darcs mv will work.
         #
         # Mercurial will see adds later, and doesn't track directories,
         # so we don't do anything with it.
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       cmd().add + [file])
Ejemplo n.º 8
0
 def addtag(self, file):
     if self.verb:
         print "Adding %s" % file
     if (file[-1] == '/') and \
        (not os.path.exists(os.path.join(self.wcpath,
                                         file[:-1]))):
         try:
             print "addtag: making dir %s" % file[:-1]
             os.makedirs(os.path.join(self.wcpath, file[:-1]))
         except:
             raise
     file = self.slashstrip(file)
     isdir = os.path.isdir(os.path.join(self.wcpath, file))
     if (not self.fsonly) and \
            (not ishg()) and ((not isdarcs()) or isdir):
         # Darcs will see adds later, but we need to add dirs
         # now so darcs mv will work.
         #
         # Mercurial will see adds later, and doesn't track directories,
         # so we don't do anything with it.
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       cmd().add + [file])
Ejemplo n.º 9
0
 def gettreeversion(self):
     if isdarcs():
         #util.chdircmd(self.wcpath, util.getstdoutsafeexec, "darcs",
         #              ['check'])
         return "Darcs repository"
     elif ishg():
         return "Mercurial repository"
     elif issvk():
         return "Svk repository"
     elif isgit():
         return "Git repository"
     else:
         return util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                              ['tree-version'])[0].strip() 
Ejemplo n.º 10
0
 def gettreeversion(self):
     if isdarcs():
         #util.chdircmd(self.wcpath, util.getstdoutsafeexec, "darcs",
         #              ['check'])
         return "Darcs repository"
     elif ishg():
         return "Mercurial repository"
     elif issvk():
         return "Svk repository"
     elif isgit():
         return "Git repository"
     else:
         return util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                              ['tree-version'])[0].strip()
Ejemplo n.º 11
0
    def __init__(self,
                 wcobj,
                 importdir,
                 docommit,
                 log='',
                 verbose=0,
                 summary=None):
        self.wcobj = wcobj
        self.log = log
        self.docommit = docommit
        self.verb = verbose
        self.summary = summary

        if os.path.isdir(importdir):
            self.importdir = os.path.abspath(importdir)
            self.importfile = None
            self.tmpdir = None

        else:  # Not a dir, try to unpack an archive.
            self.importfile = os.path.abspath(importdir)
            # mkdtemp returns an absolute path
            self.importdir = mkdtemp("-vcs-load-dirs", ",,unpack-", "..")
            self.tmpdir = self.importdir

            try:
                if self.verb:
                    print "Unpacking archive..."

                if self.importfile.endswith(".tar.gz"):
                    util.chdircmd(self.importdir, util.safeexec, "tar",
                                  ["-zxf", self.importfile])

                elif self.importfile.endswith(".tar.bz2"):
                    util.chdircmd(self.importdir, util.safeexec, "tar",
                                  ["-jxf", self.importfile])
                elif self.importfile.endswith(".zip"):
                    util.chdircmd(self.importdir, util.safeexec, "unzip",
                                  [self.importfile])
                else:
                    raise IOError, "Unknown archive file type"

                # Many tarballs expand into just one single directory.
                # Check to see if that's the case.

                dents = os.listdir(self.importdir)
                if len(dents) == 1 and os.path.isdir(self.importdir + "/" +
                                                     dents[0]):
                    self.importdir = self.importdir + "/" + dents[0]
            except:
                self.cleanup()
                raise
Ejemplo n.º 12
0
    def makelog(self, summary, logtext):
        self.summary = summary
        self.logtext = logtext
        if ishg() or isgit() or isdarcs():
            logfn = self.wcpath + "/../,,vcslog"
	else:
            logfn =  util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                                   ['make-log'])[0].strip()

        self.logfn = os.path.abspath(logfn)
        
        fd = open(self.logfn, "w")
        if isgit():
            fd.write("%s\n\n" % summary)
        if ishg():
            fd.write("%s\n" % summary)
        elif not (isdarcs() or ishg()):
            fd.write("Summary: %s\n" % summary)
            fd.write("Keywords: \n\n")
        fd.write(logtext)
        print "LOGTEXT", logtext
        fd.close()
Ejemplo n.º 13
0
    def makelog(self, summary, logtext):
        self.summary = summary
        self.logtext = logtext
        if ishg() or isgit() or isdarcs():
            logfn = self.wcpath + "/../,,vcslog"
        else:
            logfn = util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                                  ['make-log'])[0].strip()

        self.logfn = os.path.abspath(logfn)

        fd = open(self.logfn, "w")
        if isgit():
            fd.write("%s\n\n" % summary)
        if ishg():
            fd.write("%s\n" % summary)
        elif not (isdarcs() or ishg()):
            fd.write("Summary: %s\n" % summary)
            fd.write("Keywords: \n\n")
        fd.write(logtext)
        print "LOGTEXT", logtext
        fd.close()
Ejemplo n.º 14
0
    def __init__(self, wcobj, importdir, docommit, log = '', verbose = 0,
                 summary = None):
        self.wcobj = wcobj
        self.log = log
        self.docommit = docommit
        self.verb = verbose
        self.summary = summary

        if os.path.isdir(importdir):
            self.importdir = os.path.abspath(importdir)
            self.importfile = None
            self.tmpdir = None

        else:                           # Not a dir, try to unpack an archive.
            self.importfile = os.path.abspath(importdir)
            # mkdtemp returns an absolute path
            self.importdir = mkdtemp("-vcs-load-dirs", ",,unpack-", "..")
            self.tmpdir = self.importdir

            try:
                if self.verb:
                    print "Unpacking archive..."

                if self.importfile.endswith(".tar.gz"):
                    util.chdircmd(self.importdir, util.safeexec, "tar",
                                  ["-zxf", self.importfile])

                elif self.importfile.endswith(".tar.bz2"):
                    util.chdircmd(self.importdir, util.safeexec, "tar",
                                  ["-jxf", self.importfile])
                elif self.importfile.endswith(".zip"):
                    util.chdircmd(self.importdir, util.safeexec, "unzip",
                                  [self.importfile])
                else:
                    raise IOError, "Unknown archive file type"

                # Many tarballs expand into just one single directory.
                # Check to see if that's the case.

                dents = os.listdir(self.importdir)
                if len(dents) == 1 and os.path.isdir(self.importdir + "/" +
                                                     dents[0]):
                    self.importdir = self.importdir + "/" + dents[0]
            except:
                self.cleanup()
                raise
Ejemplo n.º 15
0
 def gettaggingmethod(self):
     if isdarcs() or isgit() or ishg():
         return 'explicit'
     else:
         return util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                              [cmd().tagging_method])[0].strip()
Ejemplo n.º 16
0
    def commit(self):
        if self.verb:
            print "Committing changes"
        if isdarcs():
            util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                          [cmd().commit, "-l", "-a", "-m", self.summary,
                           "--logfile", self.logfn,
                           "--delete-logfile"])
        elif isgit():
            util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                          [cmd().commit, "-a", "-F", self.logfn])
	    os.unlink(self.logfn)
        elif ishg():
            util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                          [cmd().commit, "-A", "-l", self.logfn])
            os.unlink(self.logfn)
        else:
            if len(util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd, ['logs']))==0:
                util.chdircmd(self.wcpath, util.safeexec, vcscmd, [cmd().importcmd])
            else:
                util.chdircmd(self.wcpath, util.safeexec, vcscmd, [cmd().commit])
Ejemplo n.º 17
0
 def commit(self):
     if self.verb:
         print "Committing changes"
     if isdarcs():
         util.chdircmd(self.wcpath, util.safeexec, vcscmd, [
             cmd().commit, "-l", "-a", "-m", self.summary, "--logfile",
             self.logfn, "--delete-logfile"
         ])
     elif isgit():
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       [cmd().commit, "-a", "-F", self.logfn])
         os.unlink(self.logfn)
     elif ishg():
         util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                       [cmd().commit, "-A", "-l", self.logfn])
         os.unlink(self.logfn)
     else:
         if len(
                 util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                               ['logs'])) == 0:
             util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                           [cmd().importcmd])
         else:
             util.chdircmd(self.wcpath, util.safeexec, vcscmd,
                           [cmd().commit])
Ejemplo n.º 18
0
 def gettaggingmethod(self):
     if isdarcs() or isgit() or ishg():
         return 'explicit'
     else:
         return util.chdircmd(self.wcpath, util.getstdoutsafeexec, vcscmd,
                              [cmd().tagging_method])[0].strip()