Exemplo n.º 1
0
 def test_commit_with_more_authors(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     author = (b'Sue Wong', b'*****@*****.**', 1234565432, -6 * 3600)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     more_authors = [
         (b'Al Smith', b'*****@*****.**', 1234565432, -6 * 3600),
         (b'Bill Jones', b'*****@*****.**', 1234565432, -6 * 3600),
     ]
     c = commands.CommitCommand(b'refs/heads/master',
                                b'bbb',
                                author,
                                committer,
                                b'release v1.0',
                                b':aaa',
                                None,
                                None,
                                more_authors=more_authors)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :bbb\n"
         b"author Sue Wong <*****@*****.**> 1234565432 -0600\n"
         b"author Al Smith <*****@*****.**> 1234565432 -0600\n"
         b"author Bill Jones <*****@*****.**> 1234565432 -0600\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa", repr_bytes(c))
Exemplo n.º 2
0
def main(spec, rootpath, outfile):
    with open(spec, 'r') as f:
        y = yaml.safe_load(f)

    versions = [Version("..", v) for v in y['versions']]
    lastset = FileSet(None)
    files = {}
    cmds = []

    hfiles = HistoricalFiles(".")
    mk = COMMIT_BASE_MARK

    for i, v in enumerate(versions):
        if v.fileset is not None:
            hfiles.apply_files(v.fileset, versions[:i + 1])
            cmds.extend(apply_changes(v, lastset, files, mk))
            mk += 1
            lastset = v.fileset

    # Write it out
    with open(outfile, 'wb') as f:
        for c in cmds:
            f.write(repr_bytes(c))
            f.write(b'\n')

    return True
Exemplo n.º 3
0
 def test_commit_with_int_mark(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     properties = {
         u'greeting': u'hello',
         u'planet': u'world',
     }
     c = commands.CommitCommand(b'refs/heads/master',
                                123,
                                None,
                                committer,
                                b'release v1.0',
                                b':aaa',
                                None,
                                None,
                                properties=properties)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :123\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"property greeting 5 hello\n"
         b"property planet 5 world", repr_bytes(c))
Exemplo n.º 4
0
    def to_string(self, use_features=True, include_file_contents=False):
        """
            @todo the name to_string is ambiguous since the method actually
                returns bytes.
        """
        if self.mark is None:
            mark_line = b''
        else:
            if isinstance(self.mark, (int)):
                mark_line = b'\nmark :' + str(self.mark).encode('utf-8')
            else:
                mark_line = b'\nmark :' + self.mark

        if self.author is None:
            author_section = b''
        else:
            author_section = b'\nauthor ' + format_who_when(self.author)
            if use_features and self.more_authors:
                for author in self.more_authors:
                    author_section += b'\nauthor ' + format_who_when(author)

        committer = b'committer ' + format_who_when(self.committer)

        if self.message is None:
            msg_section = b''
        else:
            msg = self.message
            msg_section = ('\ndata %d\n' % len(msg)).encode('ascii') + msg
        if self.from_ is None:
            from_line = b''
        else:
            from_line = b'\nfrom ' + self.from_
        if self.merges is None:
            merge_lines = b''
        else:
            merge_lines = b''.join([b'\nmerge ' + m for m in self.merges])
        if use_features and self.properties:
            property_lines = []
            for name in sorted(self.properties):
                value = self.properties[name]
                property_lines.append(b'\n' + format_property(name, value))
            properties_section = b''.join(property_lines)
        else:
            properties_section = b''
        if self.file_iter is None:
            filecommands = b''
        else:
            if include_file_contents:
                filecommands = b''.join(
                    [b'\n' + repr_bytes(c) for c in self.iter_files()])
            else:
                filecommands = b''.join(
                    [b'\n' + str(c) for c in self.iter_files()])
        return b''.join([
            b'commit ', self.ref, mark_line, author_section + b'\n', committer,
            msg_section, from_line, merge_lines, properties_section,
            filecommands
        ])
Exemplo n.º 5
0
 def test_tag_no_from(self):
     tagger = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.TagCommand(b'refs/tags/v1.0', None, tagger, b'create v1.0')
     self.assertEqual(
         b"tag refs/tags/v1.0\n"
         b"tagger Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 11\n"
         b"create v1.0",
         repr_bytes(c))
Exemplo n.º 6
0
 def test_tag_no_from(self):
     tagger = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.TagCommand(b'refs/tags/v1.0', None, tagger,
                             b'create v1.0')
     self.assertEqual(
         b"tag refs/tags/v1.0\n"
         b"tagger Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 11\n"
         b"create v1.0", repr_bytes(c))
Exemplo n.º 7
0
def main(hgin, hgout):
    with open(hgin, 'rb') as f:
        p = ImportParser(f)
        l = list(p.iter_commands())

    cutoff = 6

    t = util.Tracker()
    for c in l[:cutoff + 1]:
        t.feed(c)

    # Cobble together a new commit.
    last = l[cutoff]
    commit = CommitCommand(ref=last.ref,
                           mark=last.mark,
                           author=last.author,
                           committer=last.committer,
                           message=last.message,
                           from_=None,
                           merges=None,
                           file_iter=[
                               FileModifyCommand(p, f.mode, f.modify.dataref,
                                                 f.modify.data)
                               for p, f in t.last.files.items()
                           ])

    # Still need to make annotated tags + fix authors.
    with open(hgout, 'wb') as f:
        f.write(repr_bytes(commit))
        f.write(b'\n')
        for c in l[cutoff + 1:]:
            if c.name == b'reset':
                c = fix_tag(c, t)
            if c.name == b'commit':
                fix_authors(c)

            if c is not None:
                t.feed(c)
                f.write(repr_bytes(c))
                f.write(b'\n')

    return True
Exemplo n.º 8
0
 def test_tag(self):
     # tagger tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     tagger = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.TagCommand(b'refs/tags/v1.0', b':xxx', tagger, b'create v1.0')
     self.assertEqual(
         b"tag refs/tags/v1.0\n"
         b"from :xxx\n"
         b"tagger Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 11\n"
         b"create v1.0",
         repr_bytes(c))
Exemplo n.º 9
0
 def test_tag(self):
     # tagger tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     tagger = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.TagCommand(b'refs/tags/v1.0', b':xxx', tagger,
                             b'create v1.0')
     self.assertEqual(
         b"tag refs/tags/v1.0\n"
         b"from :xxx\n"
         b"tagger Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 11\n"
         b"create v1.0", repr_bytes(c))
Exemplo n.º 10
0
 def test_commit_no_mark(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b'refs/heads/master', None, None, committer,
                                b'release v1.0', b':aaa', None, None)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa", repr_bytes(c))
Exemplo n.º 11
0
 def test_commit_no_from(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b"refs/heads/master", b"bbb", None, committer,
         b"release v1.0", None, None, None)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :bbb\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0",
         repr_bytes(c))
Exemplo n.º 12
0
def main(*flist):
    infiles = flist[:-1]
    outfile = flist[-1]
    
    # Global tracker
    gt = util.Tracker()
    output = []
    
    for infile in infiles:
        # Local tracker
        lt = util.Tracker()
        
        print("Processing {} ...".format(infile))
        with open(infile, 'rb') as f:
            p = ImportParser(f)
            for cmd in p.iter_commands():
                if cmd.name == b'commit':
                    # Stitch together if this is the first commit to an
                    # existing branch.
                    if cmd.ref in gt.branches and cmd.ref not in lt.branches:
                        prev = gt.branches[cmd.ref]
                        lt.feed(cmd)
                        c = util.rebase_branch(prev, lt.last, cmd)
                        if c is None:
                            print("OOPS - Not implemented!")
                            return False
                        if c.from_ is not None:
                            if c.merges is not None:
                                c.merges.append(c.from_)
                            else:
                                c.merges = [c.from_]
                        c.from_ = None
                        gt.feed(c)
                        output.append(c)
                    else:
                        lt.feed(cmd)
                        gt.feed(cmd)
                        output.append(cmd)
                else:
                    lt.feed(cmd)
                    gt.feed(cmd)
                    output.append(cmd)
    
    with open(outfile, 'wb') as f:
        for c in output:
            f.write(repr_bytes(c))
            f.write(b'\n')
    
    return True
Exemplo n.º 13
0
 def test_commit_with_author(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     author = (b'Sue Wong', b'*****@*****.**', 1234565432, -6 * 3600)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b'refs/heads/master', b'bbb', author,
         committer, b'release v1.0', b':aaa', None, None)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :bbb\n"
         b"author Sue Wong <*****@*****.**> 1234565432 -0600\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa",
         repr_bytes(c))
Exemplo n.º 14
0
 def test_commit_with_merges(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b"refs/heads/master", b"ddd", None, committer,
             b'release v1.0', b":aaa", [b':bbb', b':ccc'], None)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :ddd\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"merge :bbb\n"
         b"merge :ccc",
         repr_bytes(c))
Exemplo n.º 15
0
 def test_commit_with_merges(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b"refs/heads/master", b"ddd", None,
                                committer, b'release v1.0', b":aaa",
                                [b':bbb', b':ccc'], None)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :ddd\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"merge :bbb\n"
         b"merge :ccc", repr_bytes(c))
Exemplo n.º 16
0
    def test_commit_unicode_committer(self):
        # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
        name = u'\u013d\xf3r\xe9m \xcdp\u0161\xfam'

        commit_utf8 = utf8_bytes_string(
            u"commit refs/heads/master\n"
            u"mark :bbb\n"
            u"committer %s <*****@*****.**> 1234567890 -0600\n"
            u"data 12\n"
            u"release v1.0\n"
            u"from :aaa" % (name,)
        )

        committer = (name, b'*****@*****.**', 1234567890, -6 * 3600)
        c = commands.CommitCommand(b'refs/heads/master', b'bbb', None, committer,
            b'release v1.0', b':aaa', None, None)

        self.assertEqual(commit_utf8, repr_bytes(c))
Exemplo n.º 17
0
    def test_commit_unicode_committer(self):
        # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
        name = u'\u013d\xf3r\xe9m \xcdp\u0161\xfam'

        commit_utf8 = utf8_bytes_string(
            u"commit refs/heads/master\n"
            u"mark :bbb\n"
            u"committer %s <*****@*****.**> 1234567890 -0600\n"
            u"data 12\n"
            u"release v1.0\n"
            u"from :aaa" % (name, ))

        committer = (name, b'*****@*****.**', 1234567890, -6 * 3600)
        c = commands.CommitCommand(b'refs/heads/master', b'bbb', None,
                                   committer, b'release v1.0', b':aaa', None,
                                   None)

        self.assertEqual(commit_utf8, repr_bytes(c))
Exemplo n.º 18
0
 def test_commit_with_int_mark(self):
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     properties = {
         u'greeting':  u'hello',
         u'planet':    u'world',
         }
     c = commands.CommitCommand(b'refs/heads/master', 123, None,
         committer, b'release v1.0', b':aaa', None, None,
         properties=properties)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :123\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"property greeting 5 hello\n"
         b"property planet 5 world",
         repr_bytes(c))
Exemplo n.º 19
0
 def test_commit_with_filecommands(self):
     file_cmds = iter([
         commands.FileDeleteCommand(b'readme.txt'),
         commands.FileModifyCommand(b'NEWS', 0o100644, None,
             b'blah blah blah'),
         ])
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b'refs/heads/master', b'bbb', None, committer,
         b'release v1.0', b':aaa', None, file_cmds)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :bbb\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"D readme.txt\n"
         b"M 644 inline NEWS\n"
         b"data 14\n"
         b"blah blah blah",
         repr_bytes(c))
Exemplo n.º 20
0
 def test_commit_with_filecommands(self):
     file_cmds = iter([
         commands.FileDeleteCommand(b'readme.txt'),
         commands.FileModifyCommand(b'NEWS', 0o100644, None,
                                    b'blah blah blah'),
     ])
     # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
     committer = (b'Joe Wong', b'*****@*****.**', 1234567890, -6 * 3600)
     c = commands.CommitCommand(b'refs/heads/master', b'bbb', None,
                                committer, b'release v1.0', b':aaa', None,
                                file_cmds)
     self.assertEqual(
         b"commit refs/heads/master\n"
         b"mark :bbb\n"
         b"committer Joe Wong <*****@*****.**> 1234567890 -0600\n"
         b"data 12\n"
         b"release v1.0\n"
         b"from :aaa\n"
         b"D readme.txt\n"
         b"M 644 inline NEWS\n"
         b"data 14\n"
         b"blah blah blah", repr_bytes(c))
Exemplo n.º 21
0
 def test_filecopy(self):
     c = commands.FileCopyCommand(b'foo/bar', b'foo/baz')
     self.assertEqual(b'C foo/bar foo/baz', repr_bytes(c))
Exemplo n.º 22
0
 def test_filemodify_treeref(self):
     c = commands.FileModifyCommand(b'tree-info', 0o160000,
                                    b'revision-id-info', None)
     self.assertEqual(b'M 160000 revision-id-info tree-info', repr_bytes(c))
Exemplo n.º 23
0
 def test_filemodify_file_internal(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100644, None,
                                    b'hello world')
     self.assertEqual(b'M 644 inline foo/bar\ndata 11\nhello world',
                      repr_bytes(c))
Exemplo n.º 24
0
 def test_blob_no_mark(self):
     c = commands.BlobCommand(None, b"hello world")
     self.assertEqual(b"blob\ndata 11\nhello world", repr_bytes(c))
Exemplo n.º 25
0
 def test_replace_attr(self):
     c2 = self.c.copy(mark=b'ccc')
     self.assertEqual(
         repr_bytes(self.c).replace(b'mark :bbb', b'mark :ccc'),
         repr_bytes(c2)
     )
Exemplo n.º 26
0
 def test_reset_no_from(self):
     c = commands.ResetCommand(b'refs/remotes/origin/master', None)
     self.assertEqual(b'reset refs/remotes/origin/master', repr_bytes(c))
Exemplo n.º 27
0
    def test_notecommit(self):
        committer = (b'Ed Mund', b'*****@*****.**', 1234565432, 0)

        commits = [
            commands.CommitCommand(ref=b'refs/heads/master',
                                   mark=b'1',
                                   author=committer,
                                   committer=committer,
                                   message=b'test\n',
                                   from_=None,
                                   merges=[],
                                   file_iter=[
                                       commands.FileModifyCommand(
                                           b'bar', 0o100644, None, b'')
                                   ]),
            commands.CommitCommand(
                ref=b'refs/notes/commits',
                mark=None,
                author=None,
                committer=committer,
                message=b"Notes added by 'git notes add'\n",
                from_=None,
                merges=[],
                file_iter=[commands.NoteModifyCommand(b'1', b'Test note\n')]),
            commands.CommitCommand(
                ref=b'refs/notes/test',
                mark=None,
                author=None,
                committer=committer,
                message=b"Notes added by 'git notes add'\n",
                from_=None,
                merges=[],
                file_iter=[commands.NoteModifyCommand(b'1', b'Test test\n')])
        ]

        self.assertEqual(
            b"""commit refs/heads/master
mark :1
author Ed Mund <*****@*****.**> 1234565432 +0000
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 5
test

M 644 inline bar
data 0
commit refs/notes/commits
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 31
Notes added by 'git notes add'

N inline :1
data 10
Test note
commit refs/notes/test
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 31
Notes added by 'git notes add'

N inline :1
data 10
Test test
""", b''.join([repr_bytes(s) for s in commits]))
Exemplo n.º 28
0
 def test_checkpoint(self):
     c = commands.CheckpointCommand()
     self.assertEqual(b'checkpoint', repr_bytes(c))
Exemplo n.º 29
0
    def test_notecommit(self):
        committer = (b'Ed Mund', b'*****@*****.**', 1234565432, 0)

        commits = [
            commands.CommitCommand(
                ref=b'refs/heads/master',
                mark=b'1',
                author=committer,
                committer=committer,
                message=b'test\n',
                from_=None,
                merges=[],
                file_iter=[
                    commands.FileModifyCommand(b'bar', 0o100644, None, b'')
                ]),
            commands.CommitCommand(
                ref=b'refs/notes/commits',
                mark=None,
                author=None,
                committer=committer,
                message=b"Notes added by 'git notes add'\n",
                from_=None,
                merges=[],
                file_iter=[
                    commands.NoteModifyCommand(b'1', b'Test note\n')
                ]),
            commands.CommitCommand(
                ref=b'refs/notes/test',
                mark=None,
                author=None,
                committer=committer,
                message=b"Notes added by 'git notes add'\n",
                from_=None,
                merges=[],
                file_iter=[
                    commands.NoteModifyCommand(b'1', b'Test test\n')
                ])
        ]

        self.assertEqual(
            b"""commit refs/heads/master
mark :1
author Ed Mund <*****@*****.**> 1234565432 +0000
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 5
test

M 644 inline bar
data 0
commit refs/notes/commits
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 31
Notes added by 'git notes add'

N inline :1
data 10
Test note
commit refs/notes/test
committer Ed Mund <*****@*****.**> 1234565432 +0000
data 31
Notes added by 'git notes add'

N inline :1
data 10
Test test
""", b''.join([repr_bytes(s) for s in commits]))
Exemplo n.º 30
0
 def test_noteonly(self):
     c = commands.NoteModifyCommand(b'foo', b'A basic note')
     self.assertEqual(b'N inline :foo\ndata 12\nA basic note', repr_bytes(c))
Exemplo n.º 31
0
 def test_filedeleteall(self):
     c = commands.FileDeleteAllCommand()
     self.assertEqual(b'deleteall', repr_bytes(c))
Exemplo n.º 32
0
 def test_filerename_quoted(self):
     # Check the first path is quoted if it contains spaces
     c = commands.FileRenameCommand(b'foo/b a r', b'foo/b a z')
     self.assertEqual(b'R "foo/b a r" foo/b a z', repr_bytes(c))
Exemplo n.º 33
0
 def test_filerename(self):
     c = commands.FileRenameCommand(b'foo/bar', b'foo/baz')
     self.assertEqual(b'R foo/bar foo/baz', repr_bytes(c))
Exemplo n.º 34
0
 def test_filerename_quoted(self):
     # Check the first path is quoted if it contains spaces
     c = commands.FileRenameCommand(b'foo/b a r', b'foo/b a z')
     self.assertEqual(b'R "foo/b a r" foo/b a z', repr_bytes(c))
Exemplo n.º 35
0
 def test_noteonly(self):
     c = commands.NoteModifyCommand(b'foo', b'A basic note')
     self.assertEqual(b'N inline :foo\ndata 12\nA basic note',
                      repr_bytes(c))
Exemplo n.º 36
0
 def test_filedelete(self):
     c = commands.FileDeleteCommand(b'foo/bar')
     self.assertEqual(b'D foo/bar', repr_bytes(c))
Exemplo n.º 37
0
 def test_blob_no_mark(self):
     c = commands.BlobCommand(None, b"hello world")
     self.assertEqual(b"blob\ndata 11\nhello world", repr_bytes(c))
Exemplo n.º 38
0
 def test_blob(self):
     c = commands.BlobCommand(b"1", b"hello world")
     self.assertEqual(b"blob\nmark :1\ndata 11\nhello world", repr_bytes(c))
Exemplo n.º 39
0
 def test_feature(self):
     c = commands.FeatureCommand(b"dwim")
     self.assertEqual(b"feature dwim", repr_bytes(c))
Exemplo n.º 40
0
 def test_reset_no_from(self):
     c = commands.ResetCommand(b'refs/remotes/origin/master', None)
     self.assertEqual(b'reset refs/remotes/origin/master', repr_bytes(c))
Exemplo n.º 41
0
 def test_filemodify_file(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100644, b':23', None)
     self.assertEqual(b'M 644 :23 foo/bar', repr_bytes(c))
Exemplo n.º 42
0
 def test_filemodify_treeref(self):
     c = commands.FileModifyCommand(b'tree-info', 0o160000,
         b'revision-id-info', None)
     self.assertEqual(b'M 160000 revision-id-info tree-info', repr_bytes(c))
Exemplo n.º 43
0
 def test_filemodify_file_executable(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100755, b':23', None)
     self.assertEqual(b'M 755 :23 foo/bar', repr_bytes(c))
Exemplo n.º 44
0
 def test_reset(self):
     c = commands.ResetCommand(b"refs/tags/v1.0", b":xxx")
     self.assertEqual(b"reset refs/tags/v1.0\nfrom :xxx\n", repr_bytes(c))
Exemplo n.º 45
0
 def test_filemodify_symlink(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o120000, None, b'baz')
     self.assertEqual(b'M 120000 inline foo/bar\ndata 3\nbaz',
                      repr_bytes(c))
Exemplo n.º 46
0
 def test_filemodify_symlink(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o120000, None, b'baz')
     self.assertEqual(b'M 120000 inline foo/bar\ndata 3\nbaz', repr_bytes(c))
Exemplo n.º 47
0
 def test_filedelete(self):
     c = commands.FileDeleteCommand(b'foo/bar')
     self.assertEqual(b'D foo/bar', repr_bytes(c))
Exemplo n.º 48
0
 def test_filemodify_file_internal(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100644, None,
         b'hello world')
     self.assertEqual(b'M 644 inline foo/bar\ndata 11\nhello world', repr_bytes(c))
Exemplo n.º 49
0
 def test_filerename(self):
     c = commands.FileRenameCommand(b'foo/bar', b'foo/baz')
     self.assertEqual(b'R foo/bar foo/baz', repr_bytes(c))
Exemplo n.º 50
0
def main(blobs, cmds, outfile):
    t = util.Tracker()
    out = []
    cmk = BASE_MARK
    
    with open(blobs, 'rb') as f:
        p = ImportParser(f)
        for c in p.iter_commands():
            fix_blobmark(c)
            t.feed(c)
            out.append(c)

    with open(cmds, 'rb') as f:
        p = ImportParser(f)
        l = list(p.iter_commands())
        
        # Ignore the first 3 commands (false start)
        i = 2
        for c in l[3:]:
            i += 1

            fix_blobmark(c)
            if c.name == b'commit':
                fix_person(c)

            # Track everything until we hit the coroutines commit.
            if c.name == b'commit' and c.message == b'semiautomatic variables\n':
                break

            t.feed(c)

            # Look for untagged releases
            if c.name == b'commit':
                out.append(c)
                tag = find_release_tag(c)
                if tag is not None:
                    out.append(tag)
            elif c.name == b'reset':
                tag = fix_tag(c, t)
                if tag is not None:
                    out.append(tag)
            else:
                out.append(c)

        # Branch coroutine/
        bc = l[i]
        #fix_blobmark(bc) - this already happened above!
        #fix_person(bc)
        bc.ref = b'refs/heads/coroutine'
        bc.from_ = b':' + t.last.commit.mark
        t.feed(bc)
        out.append(bc)
        
        # Here begins the madness.  We need to fork commits to master and coroutine.
        for c in l[i+1:]:
            fix_blobmark(c)
            if c.name == b'commit':
                fix_person(c)
                coro, mstr = fork_commit(c)
                if mstr is not None:
                    mstr = util.rebase(t, mstr)
                    if mstr is not None:
                        mstr.mark = str(cmk).encode('utf-8')
                        cmk += 1
                        t.feed(mstr)
                        out.append(mstr)

                        # Look for untagged releases
                        tag = find_release_tag(mstr)
                        if tag is not None:
                            out.append(tag)
                if coro is not None:
                    coro = util.rebase(t, coro)
                    if coro is not None:
                        coro.mark = str(cmk).encode('utf-8')
                        cmk += 1
                        t.feed(coro)
                        out.append(coro)
            elif c.name == b'reset':
                tag = fix_tag(c, t)
                if tag is not None:
                    out.append(tag)
            else:
                out.append(c)
    
    with open(outfile, 'wb') as f:
        for c in out:
            f.write(repr_bytes(c))
            f.write(b'\n')
    
    return True
Exemplo n.º 51
0
 def test_filedeleteall(self):
     c = commands.FileDeleteAllCommand()
     self.assertEqual(b'deleteall', repr_bytes(c))
Exemplo n.º 52
0
 def test_filemodify_file_executable(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100755, b':23', None)
     self.assertEqual(b'M 755 :23 foo/bar', repr_bytes(c))
Exemplo n.º 53
0
 def test_checkpoint(self):
     c = commands.CheckpointCommand()
     self.assertEqual(b'checkpoint', repr_bytes(c))
Exemplo n.º 54
0
 def test_reset(self):
     c = commands.ResetCommand(b"refs/tags/v1.0", b":xxx")
     self.assertEqual(b"reset refs/tags/v1.0\nfrom :xxx\n", repr_bytes(c))
Exemplo n.º 55
0
 def test_progress(self):
     c = commands.ProgressCommand(b"doing foo")
     self.assertEqual(b"progress doing foo", repr_bytes(c))
Exemplo n.º 56
0
 def test_filecopy(self):
     c = commands.FileCopyCommand(b'foo/bar', b'foo/baz')
     self.assertEqual(b'C foo/bar foo/baz', repr_bytes(c))
Exemplo n.º 57
0
 def test_feature_with_value(self):
     c = commands.FeatureCommand(b"dwim", b"please")
     self.assertEqual(b"feature dwim=please", repr_bytes(c))
Exemplo n.º 58
0
 def test_blob(self):
     c = commands.BlobCommand(b"1", b"hello world")
     self.assertEqual(b"blob\nmark :1\ndata 11\nhello world", repr_bytes(c))
Exemplo n.º 59
0
 def _print_command(self, cmd):
     """Wrapper to avoid adding unnecessary blank lines."""
     text = helpers.repr_bytes(cmd)
     self.outf.write(text)
     if not text.endswith(b'\n'):
         self.outf.write(b'\n')
Exemplo n.º 60
0
 def test_filemodify_file(self):
     c = commands.FileModifyCommand(b'foo/bar', 0o100644, b':23', None)
     self.assertEqual(b'M 644 :23 foo/bar', repr_bytes(c))