Пример #1
0
def remember_path(ui, repo, path, value):
    '''appends the path to the working copy's hgrc and backs up the original'''

    paths = dict(ui.configitems('paths'))
    # This should never happen.
    if path in paths:
        return
    # ConfigParser only cares about these three characters.
    if re.search(r'[:=\s]', path):
        return

    try:
        audit_path = scmutil.pathauditor(repo.root)
    except ImportError:
        audit_path = getattr(repo.opener, 'audit_path', util.path_auditor(repo.root))

    audit_path('hgrc')
    audit_path('hgrc.backup')
    base = repo.opener.base

    hgrc, backup = [os.path.join(base, x) for x in 'hgrc', 'hgrc.backup']
    if os.path.exists(hgrc):
        util.copyfile(hgrc, backup)

    ui.setconfig('paths', path, value)

    try:
        fp = repo.opener('hgrc', 'a', text=True)
        # Mercurial assumes Unix newlines by default and so do we.
        fp.write('\n[paths]\n%s = %s\n' % (path, value))
        fp.close()
    except IOError:
        return
Пример #2
0
def remember_path(ui, repo, path, value):
    '''appends the path to the working copy's hgrc and backs up the original'''

    paths = dict(ui.configitems('paths'))
    # This should never happen.
    if path in paths: return
    # ConfigParser only cares about these three characters.
    if re.search(r'[:=\s]', path): return

    audit_path = getattr(repo.opener, 'audit_path',
            util.path_auditor(repo.root))

    audit_path('hgrc')
    audit_path('hgrc.backup')
    base = repo.opener.base
    util.copyfile(os.path.join(base, 'hgrc'),
                  os.path.join(base, 'hgrc.backup'))
    ui.setconfig('paths', path, value)

    try:
        fp = repo.opener('hgrc', 'a', text=True)
        # Mercurial assumes Unix newlines by default and so do we.
        fp.write('\n[paths]\n%s = %s\n' % (path, value))
        fp.close()
    except IOError, e:
        return
Пример #3
0
    def search_thread(self, q, tgts, copy):
        hglib.invalidaterepo(self.repo)
        srcs = []
        audit_path = util.path_auditor(self.repo.root)
        m = cmdutil.match(self.repo)
        for abs in self.repo.walk(m):
            target = self.repo.wjoin(abs)
            good = True
            try:
                audit_path(abs)
            except:
                good = False
            status = self.repo.dirstate[abs]
            if (not good or not os.path.lexists(target)
                or (os.path.isdir(target) and not os.path.islink(target))):
                srcs.append(abs)
            elif copy and status == 'n':
                # looking for copies, so any revisioned file is a
                # potential source (yes, this will be expensive)
                # Added and removed files are not considered as copy
                # sources.
                srcs.append(abs)
        if copy:
            simularity = 1.0
        else:
            simularity = self.adjustment.get_value() / 100.0;

        gen = similar.findrenames(self.repo, tgts, srcs, simularity)
        for old, new, score in gen:
            q.put( [old, new, '%d%%' % (score*100)] )
Пример #4
0
def build_audit_path(repo):
    try:
        # Mercurial 2.9
        return pathutil.pathauditor(repo.root)
    except ImportError:
        try:
            # Mercurial 1.9 to 2.9
            return scmutil.pathauditor(repo.root)
        except ImportError:
            # Mercurial < 1.9
            return getattr(repo.opener, 'audit_path', util.path_auditor(repo.root))
Пример #5
0
def unremember_path(ui, repo):
    '''restores the working copy's hgrc'''

    audit_path = getattr(repo.opener, 'audit_path',
            util.path_auditor(repo.root))

    audit_path('hgrc')
    audit_path('hgrc.backup')
    base = repo.opener.base
    if os.path.exists(os.path.join(base, 'hgrc')):
        util.copyfile(os.path.join(base, 'hgrc.backup'),
                      os.path.join(base, 'hgrc'))
Пример #6
0
 def apply(self):
     assert not self.applied, _("Need to clear self.applied if you really want to re-apply actions")
     self.debug(_("Sorting actions\n"))
     self.actions.sort()
     #start transaction?
     self.debug(_("Performing actions:\n"))
     auditor = util.path_auditor(self.repo.root)
     self.stats = mergeStats()
     for a in self.actions:
         if a.fctx.path()[0] == "/": continue #no rooted paths allowed for security
         self.debug( "  %s\n" % str(a))
         a.apply( self.repo, auditor, self.stats)
     self.applied = True
     return self.stats
Пример #7
0
def unremember_path(ui, repo):
    '''restores the working copy's hgrc'''

    try:
        audit_path = scmutil.pathauditor(repo.root)
    except ImportError:
        audit_path = getattr(repo.opener, 'audit_path', util.path_auditor(repo.root))

    audit_path('hgrc')
    audit_path('hgrc.backup')
    base = repo.opener.base

    hgrc, backup = [os.path.join(base, x) for x in 'hgrc', 'hgrc.backup']
    if os.path.exists(backup):
        util.copyfile(backup, hgrc)
    else:
        os.remove(hgrc)
Пример #8
0
 def apply(self):
     assert not self.applied, _(
         "Need to clear self.applied if you really want to re-apply actions"
     )
     self.debug(_("Sorting actions\n"))
     self.actions.sort()
     #start transaction?
     self.debug(_("Performing actions:\n"))
     auditor = util.path_auditor(self.repo.root)
     self.stats = mergeStats()
     for a in self.actions:
         if a.fctx.path()[0] == "/":
             continue  #no rooted paths allowed for security
         self.debug("  %s\n" % str(a))
         a.apply(self.repo, auditor, self.stats)
     self.applied = True
     return self.stats
Пример #9
0
def unremember_path(ui, repo):
    '''restores the working copy's hgrc'''

    try:
        audit_path = scmutil.pathauditor(repo.root)
    except ImportError:
        audit_path = getattr(repo.opener, 'audit_path',
                             util.path_auditor(repo.root))

    audit_path('hgrc')
    audit_path('hgrc.backup')
    base = repo.opener.base

    hgrc, backup = [os.path.join(base, x) for x in 'hgrc', 'hgrc.backup']
    if os.path.exists(backup):
        util.copyfile(backup, hgrc)
    else:
        os.remove(hgrc)