コード例 #1
0
ファイル: WorkSpace.py プロジェクト: wca/openzfs
    def findoutgoing(self, parent):
        '''Return the base set of outgoing nodes.

        A caching wrapper around mercurial.localrepo.findoutgoing().
        Complains (to the user), if the parent workspace is
        non-existent or inaccessible'''

        self.ui.pushbuffer()
        try:
            try:
                ui = self.ui
                if hasattr(cmdutil, 'remoteui'):
                    ui = cmdutil.remoteui(ui, {})
                pws = hg.repository(ui, parent)
                if Version.at_least("1.6"):
                    return discovery.findoutgoing(self.repo, pws)
                else:
                    return self.repo.findoutgoing(pws)
            except error.RepoError:
                self.ui.warn("Warning: Parent workspace '%s' is not "
                             "accessible\n"
                             "active list will be incomplete\n\n" % parent)
                return []
        finally:
            self.ui.popbuffer()
コード例 #2
0
ファイル: WorkSpace.py プロジェクト: wca/openzfs
    def _changed_file(self, path):
        '''Compare the parent and local versions of a given file.
        Return True if file changed, False otherwise.

        Note that this compares the given path in both versions, not the given
        entry; renamed and copied files are compared by name, not history.

        The fast path compares file metadata, slow path is a
        real comparison of file content.'''

        if ((path in self.parenttip) != (path in self.localtip)):
            return True

        parentfile = self.parenttip.filectx(path)
        localfile = self.localtip.filectx(path)

        #
        # NB: Keep these ordered such as to make every attempt
        #     to short-circuit the more time consuming checks.
        #
        if parentfile.size() != localfile.size():
            return True

        if parentfile.flags() != localfile.flags():
            return True

        if Version.at_least("1.7"):
            if parentfile.cmp(localfile):
                return True
        else:
            if parentfile.cmp(localfile.data()):
                return True
コード例 #3
0
ファイル: WorkSpace.py プロジェクト: apprisi/illumos-gate
    def findoutgoing(self, parent):
        '''Return the base set of outgoing nodes.

        A caching wrapper around mercurial.localrepo.findoutgoing().
        Complains (to the user), if the parent workspace is
        non-existent or inaccessible'''

        self.ui.pushbuffer()
        try:
            try:
                ui = self.ui
                if hasattr(cmdutil, 'remoteui'):
                    ui = cmdutil.remoteui(ui, {})
                pws = hg.repository(ui, parent)
                if Version.at_least("1.6"):
                    return discovery.findoutgoing(self.repo, pws)
                else:
                    return self.repo.findoutgoing(pws)
            except error.RepoError:
                self.ui.warn("Warning: Parent workspace '%s' is not "
                             "accessible\n"
                             "active list will be incomplete\n\n" % parent)
                return []
        finally:
            self.ui.popbuffer()
コード例 #4
0
ファイル: WorkSpace.py プロジェクト: apprisi/illumos-gate
    def _changed_file(self, path):
        '''Compare the parent and local versions of a given file.
        Return True if file changed, False otherwise.

        Note that this compares the given path in both versions, not the given
        entry; renamed and copied files are compared by name, not history.

        The fast path compares file metadata, slow path is a
        real comparison of file content.'''

        if ((path in self.parenttip) != (path in self.localtip)):
            return True

        parentfile = self.parenttip.filectx(path)
        localfile = self.localtip.filectx(path)

        #
        # NB: Keep these ordered such as to make every attempt
        #     to short-circuit the more time consuming checks.
        #
        if parentfile.size() != localfile.size():
            return True

        if parentfile.flags() != localfile.flags():
            return True

        if Version.at_least("1.7"):
            if parentfile.cmp(localfile):
                return True
        else:
            if parentfile.cmp(localfile.data()):
                return True
コード例 #5
0
    def diff(self, node1=None, node2=None, match=None, opts=None):
        ret = cStringIO.StringIO()
        try:
            for chunk in patch.diff(self.repo, node1, node2, match=match,
                                    opts=opts):
                ret.write(chunk)
        finally:
            # Workaround Hg bug 1651
            if not Version.at_least("1.3"):
                self.repo.dirstate.invalidate()

        return ret.getvalue()
コード例 #6
0
ファイル: cdm.py プロジェクト: xiaobiqiang/opensolaris
def reposetup(ui, repo):
    if repo.local() and repo not in wslist:
        wslist[repo] = WorkSpace(repo)

        if Version.at_least("1.3"):
            interactive = ui.interactive()
        else:
            interactive = ui.interactive

        if interactive and sys.stdin.isatty():
            ui.setconfig('hooks', 'preoutgoing.cdm_pbconfirm',
                         'python:hgext_cdm.pbconfirm')
コード例 #7
0
def yes_no(ui, msg, default):
    if default:
        prompt = ' [Y/n]:'
        defanswer = 'y'
    else:
        prompt = ' [y/N]:'
        defanswer = 'n'

    if Version.at_least("1.4"):
        index = ui.promptchoice(msg + prompt, ['&yes', '&no'],
                                default=['y', 'n'].index(defanswer))
        resp = ('y', 'n')[index]
    else:
        resp = ui.prompt(msg + prompt, ['&yes', '&no'], default=defanswer)

    return resp[0] in ('Y', 'y')
コード例 #8
0
ファイル: cdm.py プロジェクト: xiaobiqiang/opensolaris
def yes_no(ui, msg, default):
    if default:
        prompt = ' [Y/n]:'
        defanswer = 'y'
    else:
        prompt = ' [y/N]:'
        defanswer = 'n'

    if Version.at_least("1.3.0"):
        resp = ui.prompt(msg + prompt, ['&yes', '&no'], default=defanswer)
    else:
        resp = ui.prompt(msg + prompt,
                         r'([Yy(es)?|[Nn]o?)?',
                         default=defanswer)

    return resp[0] in ('Y', 'y')
コード例 #9
0
ファイル: Backup.py プロジェクト: wca/openzfs
        #
        time.sleep(1)

        files = {}
        try:
            diff = self.bu.backupfile('diff')
            try:
                fuzz = patch.patch(diff, self.ws.ui, strip=1,
                                   cwd=self.ws.repo.root, files=files)
                if fuzz:
                    raise util.Abort('working copy diff applied with fuzz')
            except Exception, e:
                raise util.Abort("couldn't apply working copy diff: %s\n"
                                 "   %s" % (diff, e))
        finally:
            if Version.at_least("1.7"):
                cmdutil.updatedir(self.ws.ui, self.ws.repo, files)
            else:
                patch.updatedir(self.ws.ui, self.ws.repo, files)

        if not self.bu.exists('renames'):
            return

        #
        # We need to re-apply name changes where the new name
        # (rename/copy destination) is an already versioned file, as
        # Hg would otherwise ignore them.
        #
        try:
            fp = self.bu.open('renames')
            for line in fp:
コード例 #10
0
# important bit here (in that if it is incorrect, everything else will
# be as incorrect, or more)
#

import cStringIO
import os
from mercurial import cmdutil, context, hg, node, patch, repair, util
from hgext import mq

from onbld.Scm import Version

#
# Mercurial >= 1.2 has its exception types in a mercurial.error
# module, prior versions had them in their associated modules.
#
if Version.at_least("1.2"):
    from mercurial import error
    HgRepoError = error.RepoError
    HgLookupError = error.LookupError
else:
    from mercurial import repo, revlog
    HgRepoError = repo.RepoError
    HgLookupError = revlog.LookupError


class ActiveEntry(object):
    '''Representation of the changes made to a single file.

    MODIFIED   - Contents changed, but no other changes were made
    ADDED      - File is newly created
    REMOVED    - File is being removed
コード例 #11
0
            except EnvironmentError, e:
                raise util.Abort('Could not create backup directory %s: %s' %
                                 (self.backupdir, e))

        self.generation += 1
        self.create_gen(self.generation)

        try:
            for x in self.modules:
                x.backup()
        except Exception, e:
            if isinstance(e, KeyboardInterrupt):
                self.ws.ui.warn("Interrupted\n")
            else:
                self.ws.ui.warn("Error: %s\n" % e)
                if Version.at_least("1.3.0"):
                    show_traceback = self.ws.ui.configbool(
                        'ui', 'traceback', False)
                else:
                    show_traceback = self.ws.ui.traceback

                #
                # If it's not a 'normal' error, we want to print a stack
                # trace now in case the attempt to remove the partial
                # backup also fails, and raises a second exception.
                #
                if (not isinstance(e, (EnvironmentError, util.Abort))
                        or show_traceback):
                    traceback.print_exc()

            for x in self.modules:
コード例 #12
0
ファイル: cdm.py プロジェクト: xiaobiqiang/opensolaris
    if not source:
        append_new_parent(parent)
        return
    else:
        path, target = source.rsplit(':', 1)

        if path != repo.join('hgrc'):
            raise util.Abort(
                "Cannot edit path specification not in repo hgrc\n"
                "default path is from: %s" % source)

        update_parent(path, int(target), parent)


if Version.at_least("1.3"):
    cdm_reparent = cdm_reparent_13
else:
    cdm_reparent = cdm_reparent_11


def backup_name(fullpath):
    '''Create a backup directory name based on the specified path.

    In most cases this is the basename of the path specified, but
    certain cases are handled specially to create meaningful names'''

    special = ['usr/closed']

    fullpath = fullpath.rstrip(os.path.sep).split(os.path.sep)
コード例 #13
0
ファイル: WorkSpace.py プロジェクト: wca/openzfs
# present the entire change in workspace state between a parent and
# its child and is the important bit here (in that if it is incorrect,
# everything else will be as incorrect, or more)
#

import cStringIO
import os
from mercurial import cmdutil, context, error, hg, node, patch, repair, util
from hgext import mq

from onbld.Scm import Version

#
# Mercurial 1.6 moves findoutgoing into a discover module
#
if Version.at_least("1.6"):
    from mercurial import discovery


class ActiveEntry(object):
    '''Representation of the changes made to a single file.

    MODIFIED   - Contents changed, but no other changes were made
    ADDED      - File is newly created
    REMOVED    - File is being removed

    Copies are represented by an Entry whose .parentname is non-nil

    Truly copied files have non-nil .parentname and .renamed = False
    Renames have non-nil .parentname and .renamed = True
コード例 #14
0
ファイル: WorkSpace.py プロジェクト: apprisi/illumos-gate
# its child and is the important bit here (in that if it is incorrect,
# everything else will be as incorrect, or more)
#

import cStringIO
import os
from mercurial import cmdutil, context, error, hg, node, patch, repair, util
from hgext import mq

from onbld.Scm import Version


#
# Mercurial 1.6 moves findoutgoing into a discover module
#
if Version.at_least("1.6"):
    from mercurial import discovery


class ActiveEntry(object):
    '''Representation of the changes made to a single file.

    MODIFIED   - Contents changed, but no other changes were made
    ADDED      - File is newly created
    REMOVED    - File is being removed

    Copies are represented by an Entry whose .parentname is non-nil

    Truly copied files have non-nil .parentname and .renamed = False
    Renames have non-nil .parentname and .renamed = True