Beispiel #1
0
def remotelookup(orig, repo, proto, key):
    k = encoding.tolocal(key)
    if k.startswith("_gitlookup_"):
        ret = _dolookup(repo, k)
        if ret is not None:
            success = 1
        else:
            success = 0
            ret = "gitlookup failed"
        return "%s %s\n" % (success, ret)
    return orig(repo, proto, key)
Beispiel #2
0
def geturl(path):
    try:
        return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
    except svn.core.SubversionException:
        # svn.client.url_from_path() fails with local repositories
        pass
    if os.path.isdir(path):
        path = os.path.normpath(os.path.abspath(path))
        if pycompat.iswindows:
            path = "/" + util.normpath(path)
        # Module URL is later compared with the repository URL returned
        # by svn API, which is UTF-8.
        path = encoding.tolocal(path)
        path = "file://%s" % quote(path)
    return svn.core.svn_path_canonicalize(path)
Beispiel #3
0
    def _lookup(repo, proto, key):
        localkey = encoding.tolocal(key)

        if isinstance(localkey, str) and repo._scratchbranchmatcher.match(localkey):
            scratchnode = repo.bundlestore.index.getnode(localkey)
            if scratchnode:
                return "%s %s\n" % (1, scratchnode)
            else:
                return "%s %s\n" % (0, "scratch branch %s not found" % localkey)
        else:
            try:
                r = nodemod.hex(repo.lookup(localkey))
                return "%s %s\n" % (1, r)
            except Exception as inst:
                try:
                    node = repo.bundlestore.index.getnodebyprefix(localkey)
                    if node:
                        return "%s %s\n" % (1, node)
                    else:
                        return "%s %s\n" % (0, str(inst))
                except Exception as inst:
                    return "%s %s\n" % (0, str(inst))
Beispiel #4
0
def _unescapebookmark(bookmark):
    bookmark = encoding.tolocal(bookmark)
    bookmark = bookmark.replace("*%", "*")
    return bookmark.replace("bookmarksbookmarks", "bookmarks")
Beispiel #5
0
def wireprotolistkeyspatterns(repo, proto, namespace, patterns):
    patterns = wireproto.decodelist(patterns)
    d = pycompat.iteritems(repo.listkeys(encoding.tolocal(namespace),
                                         patterns))
    return pushkey.encodekeys(d)
Beispiel #6
0
repo.commit(text="commit1", date="0 0")

d = repo[None]["foo"].date()
if os.name == "nt":
    d = d[:2]
print("workingfilectx.date = (%d, %d)" % d)

# test memctx with non-ASCII commit message


def filectxfn(repo, memctx, path):
    return context.memfilectx(repo, memctx, "foo", b"")


ctx = context.memctx(
    repo, ["tip", None], encoding.tolocal("Gr\xc3\xbcezi!"), ["foo"], filectxfn
)
ctx.commit()

# test performing a status


def getfilectx(repo, memctx, f):
    fctx = memctx.parents()[0][f]
    data, flags = fctx.data(), fctx.flags()
    if f == "foo":
        data += b"bar\n"
    return context.memfilectx(repo, memctx, f, data, "l" in flags, "x" in flags)


ctxa = repo.changectx(0)
Beispiel #7
0
repo[None].add(["foo"])
repo.commit(text="commit1", date="0 0")

d = repo[None]["foo"].date()
if os.name == "nt":
    d = d[:2]
print("workingfilectx.date = (%d, %d)" % d)

# test memctx with non-ASCII commit message


def filectxfn(repo, memctx, path):
    return context.memfilectx(repo, memctx, "foo", "")


ctx = context.memctx(repo, ["tip", None], encoding.tolocal("Gr\xc3\xbcezi!"),
                     ["foo"], filectxfn)
ctx.commit()
for enc in "ASCII", "Latin-1", "UTF-8":
    encoding.encoding = enc
    print("%-8s: %s" % (enc, repo["tip"].description()))

# test performing a status


def getfilectx(repo, memctx, f):
    fctx = memctx.parents()[0][f]
    data, flags = fctx.data(), fctx.flags()
    if f == "foo":
        data += "bar\n"
    return context.memfilectx(repo, memctx, f, data, "l" in flags, "x"
Beispiel #8
0
 def testasciifastpath(self):
     s = b"\0" * 100
     self.assertTrue(s is encoding.tolocal(s))
     self.assertTrue(s is encoding.fromlocal(s))