예제 #1
0
파일: filemap.py 프로젝트: c0ns0le/cygwin
 def setrevmap(self, revmap):
     # rebuild our state to make things restartable
     #
     # To avoid calling getcommit for every revision that has already
     # been converted, we rebuild only the parentmap, delaying the
     # rebuild of wantedancestors until we need it (i.e. until a
     # merge).
     #
     # We assume the order argument lists the revisions in
     # topological order, so that we can infer which revisions were
     # wanted by previous runs.
     self._rebuilt = not revmap
     seen = {SKIPREV: SKIPREV}
     dummyset = util.set()
     converted = []
     for rev in revmap.order:
         mapped = revmap[rev]
         wanted = mapped not in seen
         if wanted:
             seen[mapped] = rev
             self.parentmap[rev] = rev
         else:
             self.parentmap[rev] = seen[mapped]
         self.wantedancestors[rev] = dummyset
         arg = seen[mapped]
         if arg == SKIPREV:
             arg = None
         converted.append((rev, wanted, arg))
     self.convertedorder = converted
     return self.base.setrevmap(revmap)
예제 #2
0
파일: filemap.py 프로젝트: saminigod/cygwin
 def setrevmap(self, revmap):
     # rebuild our state to make things restartable
     #
     # To avoid calling getcommit for every revision that has already
     # been converted, we rebuild only the parentmap, delaying the
     # rebuild of wantedancestors until we need it (i.e. until a
     # merge).
     #
     # We assume the order argument lists the revisions in
     # topological order, so that we can infer which revisions were
     # wanted by previous runs.
     self._rebuilt = not revmap
     seen = {SKIPREV: SKIPREV}
     dummyset = util.set()
     converted = []
     for rev in revmap.order:
         mapped = revmap[rev]
         wanted = mapped not in seen
         if wanted:
             seen[mapped] = rev
             self.parentmap[rev] = rev
         else:
             self.parentmap[rev] = seen[mapped]
         self.wantedancestors[rev] = dummyset
         arg = seen[mapped]
         if arg == SKIPREV:
             arg = None
         converted.append((rev, wanted, arg))
     self.convertedorder = converted
     return self.base.setrevmap(revmap)
예제 #3
0
 def dirs_of(self, files):
     dirs = util.set()
     for f in files:
         if os.path.isdir(self.wjoin(f)):
             dirs.add(f)
         for i in strutil.rfindall(f, '/'):
             dirs.add(f[:i])
     return dirs
예제 #4
0
파일: subversion.py 프로젝트: carlgao/lenga
 def dirs_of(self, files):
     dirs = util.set()
     for f in files:
         if os.path.isdir(self.wjoin(f)):
             dirs.add(f)
         for i in strutil.rfindall(f, '/'):
             dirs.add(f[:i])
     return dirs
예제 #5
0
    def putcommit(self, files, parents, commit):
        for parent in parents:
            try:
                return self.revid(self.childmap[parent])
            except KeyError:
                pass
        entries = util.set(self.delete)
        files = util.frozenset(files)
        entries.update(self.add_dirs(files.difference(entries)))
        if self.copies:
            for s, d in self.copies:
                self._copyfile(s, d)
            self.copies = []
        if self.delete:
            self.xargs(self.delete, 'delete')
            self.delete = []
        entries.update(self.add_files(files.difference(entries)))
        entries.update(self.tidy_dirs(entries))
        if self.delexec:
            self.xargs(self.delexec, 'propdel', 'svn:executable')
            self.delexec = []
        if self.setexec:
            self.xargs(self.setexec, 'propset', 'svn:executable', '*')
            self.setexec = []

        fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
        fp = os.fdopen(fd, 'w')
        fp.write(commit.desc)
        fp.close()
        try:
            output = self.run0('commit',
                               username=util.shortuser(commit.author),
                               file=messagefile,
                               encoding='utf-8')
            try:
                rev = self.commit_re.search(output).group(1)
            except AttributeError:
                self.ui.warn(_('unexpected svn output:\n'))
                self.ui.warn(output)
                raise util.Abort(_('unable to cope with svn output'))
            if commit.rev:
                self.run('propset',
                         'hg:convert-rev',
                         commit.rev,
                         revprop=True,
                         revision=rev)
            if commit.branch and commit.branch != 'default':
                self.run('propset',
                         'hg:convert-branch',
                         commit.branch,
                         revprop=True,
                         revision=rev)
            for parent in parents:
                self.addchild(parent, rev)
            return self.revid(rev)
        finally:
            os.unlink(messagefile)
예제 #6
0
파일: subversion.py 프로젝트: carlgao/lenga
    def putcommit(self, files, parents, commit):
        for parent in parents:
            try:
                return self.revid(self.childmap[parent])
            except KeyError:
                pass
        entries = util.set(self.delete)
        files = util.frozenset(files)
        entries.update(self.add_dirs(files.difference(entries)))
        if self.copies:
            for s, d in self.copies:
                self._copyfile(s, d)
            self.copies = []
        if self.delete:
            self.xargs(self.delete, 'delete')
            self.delete = []
        entries.update(self.add_files(files.difference(entries)))
        entries.update(self.tidy_dirs(entries))
        if self.delexec:
            self.xargs(self.delexec, 'propdel', 'svn:executable')
            self.delexec = []
        if self.setexec:
            self.xargs(self.setexec, 'propset', 'svn:executable', '*')
            self.setexec = []

        fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
        fp = os.fdopen(fd, 'w')
        fp.write(commit.desc)
        fp.close()
        try:
            output = self.run0('commit',
                               username=util.shortuser(commit.author),
                               file=messagefile,
                               encoding='utf-8')
            try:
                rev = self.commit_re.search(output).group(1)
            except AttributeError:
                self.ui.warn(_('unexpected svn output:\n'))
                self.ui.warn(output)
                raise util.Abort(_('unable to cope with svn output'))
            if commit.rev:
                self.run('propset', 'hg:convert-rev', commit.rev,
                         revprop=True, revision=rev)
            if commit.branch and commit.branch != 'default':
                self.run('propset', 'hg:convert-branch', commit.branch,
                         revprop=True, revision=rev)
            for parent in parents:
                self.addchild(parent, rev)
            return self.revid(rev)
        finally:
            os.unlink(messagefile)
예제 #7
0
파일: filemap.py 프로젝트: c0ns0le/cygwin
    def mark_not_wanted(self, rev, p):
        # Mark rev as not interesting and update data structures.

        if p is None:
            # A root revision. Use SKIPREV to indicate that it doesn't
            # map to any revision in the restricted graph.  Put SKIPREV
            # in the set of wanted ancestors to simplify code elsewhere
            self.parentmap[rev] = SKIPREV
            self.wantedancestors[rev] = util.set((SKIPREV,))
            return

        # Reuse the data from our parent.
        self.parentmap[rev] = self.parentmap[p]
        self.wantedancestors[rev] = self.wantedancestors[p]
예제 #8
0
파일: filemap.py 프로젝트: saminigod/cygwin
    def mark_not_wanted(self, rev, p):
        # Mark rev as not interesting and update data structures.

        if p is None:
            # A root revision. Use SKIPREV to indicate that it doesn't
            # map to any revision in the restricted graph.  Put SKIPREV
            # in the set of wanted ancestors to simplify code elsewhere
            self.parentmap[rev] = SKIPREV
            self.wantedancestors[rev] = util.set((SKIPREV, ))
            return

        # Reuse the data from our parent.
        self.parentmap[rev] = self.parentmap[p]
        self.wantedancestors[rev] = self.wantedancestors[p]
예제 #9
0
파일: filemap.py 프로젝트: c0ns0le/cygwin
    def mark_wanted(self, rev, parents):
        # Mark rev ss wanted and update data structures.

        # rev will be in the restricted graph, so children of rev in
        # the original graph should still have rev as a parent in the
        # restricted graph.
        self.parentmap[rev] = rev

        # The set of wanted ancestors of rev is the union of the sets
        # of wanted ancestors of its parents. Plus rev itself.
        wrev = util.set()
        for p in parents:
            wrev.update(self.wantedancestors[p])
        wrev.add(rev)
        self.wantedancestors[rev] = wrev
예제 #10
0
파일: filemap.py 프로젝트: saminigod/cygwin
    def mark_wanted(self, rev, parents):
        # Mark rev ss wanted and update data structures.

        # rev will be in the restricted graph, so children of rev in
        # the original graph should still have rev as a parent in the
        # restricted graph.
        self.parentmap[rev] = rev

        # The set of wanted ancestors of rev is the union of the sets
        # of wanted ancestors of its parents. Plus rev itself.
        wrev = util.set()
        for p in parents:
            wrev.update(self.wantedancestors[p])
        wrev.add(rev)
        self.wantedancestors[rev] = wrev
예제 #11
0
 def get_blacklist(self):
     """Avoid certain revision numbers.
     It is not uncommon for two nearby revisions to cancel each other
     out, e.g. 'I copied trunk into a subdirectory of itself instead
     of making a branch'. The converted repository is significantly
     smaller if we ignore such revisions."""
     self.blacklist = util.set()
     blacklist = self.blacklist
     for line in file("blacklist.txt", "r"):
         if not line.startswith("#"):
             try:
                 svn_rev = int(line.strip())
                 blacklist.add(svn_rev)
             except ValueError, e:
                 pass  # not an integer or a comment
예제 #12
0
파일: subversion.py 프로젝트: carlgao/lenga
 def get_blacklist(self):
     """Avoid certain revision numbers.
     It is not uncommon for two nearby revisions to cancel each other
     out, e.g. 'I copied trunk into a subdirectory of itself instead
     of making a branch'. The converted repository is significantly
     smaller if we ignore such revisions."""
     self.blacklist = util.set()
     blacklist = self.blacklist
     for line in file("blacklist.txt", "r"):
         if not line.startswith("#"):
             try:
                 svn_rev = int(line.strip())
                 blacklist.add(svn_rev)
             except ValueError, e:
                 pass # not an integer or a comment