def addbranchrevs(lrepo, repo, branches, revs): hashbranch, branches = branches if not hashbranch and not branches: return revs or None, revs and revs[0] or None revs = revs and list(revs) or [] if not repo.capable('branchmap'): if branches: raise util.Abort(_("remote branch lookup not supported")) revs.append(hashbranch) return revs, revs[0] branchmap = repo.branchmap() def primary(butf8): if butf8 == '.': if not lrepo or not lrepo.local(): raise util.Abort(_("dirstate branch not accessible")) butf8 = lrepo.dirstate.branch() if butf8 in branchmap: revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) return True else: return False for branch in branches: butf8 = encoding.fromlocal(branch) if not primary(butf8): raise error.RepoLookupError(_("unknown branch '%s'") % branch) if hashbranch: butf8 = encoding.fromlocal(hashbranch) if not primary(butf8): revs.append(hashbranch) return revs, revs[0]
def add(self, manifest, files, desc, transaction, p1, p2, user, date=None, extra={}): user = user.strip() # An empty username or a username with a "\n" will make the # revision text contain two "\n\n" sequences -> corrupt # repository since read cannot unpack the revision. if not user: raise error.RevlogError(_("empty username")) if "\n" in user: raise error.RevlogError(_("username %s contains a newline") % repr(user)) # strip trailing whitespace and leading and trailing empty lines desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) if date: parseddate = "%d %d" % util.parsedate(date) else: parseddate = "%d %d" % util.makedate() if extra and extra.get("branch") in ("default", ""): del extra["branch"] if extra: extra = encodeextra(extra) parseddate = "%s %s" % (parseddate, extra) l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] text = "\n".join(l) return self.addrevision(text, transaction, len(self), p1, p2)
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): return False d = self._call("pushkey", namespace=encoding.fromlocal(namespace), key=encoding.fromlocal(key), old=encoding.fromlocal(old), new=encoding.fromlocal(new)) try: d = bool(int(d)) except ValueError: raise error.ResponseError( _('push failed (unexpected response):'), d) return d
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): yield False, None f = future() yield todict(namespace=encoding.fromlocal(namespace), key=encoding.fromlocal(key), old=encoding.fromlocal(old), new=encoding.fromlocal(new)), f d = f.value try: d = bool(int(d)) except ValueError: raise error.ResponseError(_('push failed (unexpected response):'), d) yield d
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): yield False, None f = future() yield todict(namespace=encoding.fromlocal(namespace), key=encoding.fromlocal(key), old=encoding.fromlocal(old), new=encoding.fromlocal(new)), f d = f.value try: d = bool(int(d)) except ValueError: raise error.ResponseError( _('push failed (unexpected response):'), d) yield d
def buildmetadata(ctx): '''build content of .hg_archival.txt''' repo = ctx.repo() hex = ctx.hex() if ctx.rev() is None: hex = ctx.p1().hex() if ctx.dirty(): hex += '+' base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch())) tags = ''.join('tag: %s\n' % t for t in ctx.tags() if repo.tagtype(t) == 'global') if not tags: repo.ui.pushbuffer() opts = { 'template': '{latesttag}\n{latesttagdistance}', 'style': '', 'patch': None, 'git': None } cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) ltags, dist = repo.ui.popbuffer().split('\n') ltags = ltags.split(':') if ctx.rev() is None: changessince = len(repo.revs('only(%d,%s)', ctx.p1(), ltags[0])) + 1 else: changessince = len(repo.revs('only(%d,%s)', ctx.rev(), ltags[0])) tags = ''.join('latesttag: %s\n' % t for t in ltags) tags += 'latesttagdistance: %s\n' % dist tags += 'changessincelatesttag: %s\n' % changessince return base + tags
def write(self, tr=None): """Save branch cache if it is dirty.""" repo = self._repo if self._rbcnamescount < len(self._names): try: if self._rbcnamescount != 0: f = repo.vfs.open(_rbcnames, 'ab') if f.tell() == self._rbcsnameslen: f.write('\0') else: f.close() repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) self._rbcnamescount = 0 self._rbcrevslen = 0 if self._rbcnamescount == 0: f = repo.vfs.open(_rbcnames, 'wb') f.write('\0'.join( encoding.fromlocal(b) for b in self._names[self._rbcnamescount:])) self._rbcsnameslen = f.tell() f.close() except (IOError, OSError, util.Abort), inst: repo.ui.debug("couldn't write revision branch cache names: " "%s\n" % inst) return self._rbcnamescount = len(self._names)
def write(self, repo): """Save branch cache if it is dirty.""" if self._rbcnamescount < len(self._names): try: if self._rbcnamescount != 0: f = repo.vfs.open(_rbcnames, 'ab') # The position after open(x, 'a') is implementation defined- # see issue3543. SEEK_END was added in 2.5 f.seek(0, 2) #os.SEEK_END if f.tell() == self._rbcsnameslen: f.write('\0') else: f.close() repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) self._rbcnamescount = 0 self._rbcrevslen = 0 if self._rbcnamescount == 0: f = repo.vfs.open(_rbcnames, 'wb') f.write('\0'.join(encoding.fromlocal(b) for b in self._names[self._rbcnamescount:])) self._rbcsnameslen = f.tell() f.close() except (IOError, OSError, util.Abort), inst: repo.ui.debug("couldn't write revision branch cache names: " "%s\n" % inst) return self._rbcnamescount = len(self._names)
def write(self, repo): try: f = repo.vfs(_filename(repo), "w", atomictemp=True) cachekey = [hex(self.tipnode), str(self.tiprev)] if self.filteredhash is not None: cachekey.append(hex(self.filteredhash)) f.write(" ".join(cachekey) + '\n') nodecount = 0 for label, nodes in sorted(self.iteritems()): for node in nodes: nodecount += 1 if node in self._closednodes: state = 'c' else: state = 'o' f.write("%s %s %s\n" % (hex(node), state, encoding.fromlocal(label))) f.close() repo.ui.log('branchcache', 'wrote %s branch cache with %d labels and %d nodes\n', repo.filtername, len(self), nodecount) except (IOError, OSError, util.Abort), inst: repo.ui.debug("couldn't write branch cache: %s\n" % inst) # Abort may be raise by read only opener pass
def write(self, tr=None): """Save branch cache if it is dirty.""" repo = self._repo if self._rbcnamescount < len(self._names): try: if self._rbcnamescount != 0: f = repo.vfs.open(_rbcnames, 'ab') if f.tell() == self._rbcsnameslen: f.write('\0') else: f.close() repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) self._rbcnamescount = 0 self._rbcrevslen = 0 if self._rbcnamescount == 0: f = repo.vfs.open(_rbcnames, 'wb') f.write('\0'.join(encoding.fromlocal(b) for b in self._names[self._rbcnamescount:])) self._rbcsnameslen = f.tell() f.close() except (IOError, OSError, util.Abort), inst: repo.ui.debug("couldn't write revision branch cache names: " "%s\n" % inst) return self._rbcnamescount = len(self._names)
def __init__(self, repo, text="", user=None, date=None, extra=None, changes=None): self._repo = repo self._rev = None self._node = None self._text = text if date: self._date = util.parsedate(date) if user: self._user = user if changes: self._status = list(changes[:4]) self._unknown = changes[4] self._ignored = changes[5] self._clean = changes[6] else: self._unknown = None self._ignored = None self._clean = None self._extra = {} if extra: self._extra = extra.copy() if "branch" not in self._extra: try: branch = encoding.fromlocal(self._repo.dirstate.branch()) except UnicodeDecodeError: raise util.Abort(_("branch name not in UTF-8!")) self._extra["branch"] = branch if self._extra["branch"] == "": self._extra["branch"] = "default"
def buildmetadata(ctx): '''build content of .hg_archival.txt''' repo = ctx.repo() hex = ctx.hex() if ctx.rev() is None: hex = ctx.p1().hex() if ctx.dirty(): hex += '+' base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch())) tags = ''.join('tag: %s\n' % t for t in ctx.tags() if repo.tagtype(t) == 'global') if not tags: repo.ui.pushbuffer() opts = {'template': '{latesttag}\n{latesttagdistance}', 'style': '', 'patch': None, 'git': None} cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) ltags, dist = repo.ui.popbuffer().split('\n') ltags = ltags.split(':') if ctx.rev() is None: changessince = len(repo.revs('only(%d,%s)', ctx.p1(), ltags[0])) + 1 else: changessince = len(repo.revs('only(%d,%s)', ctx.rev(), ltags[0])) tags = ''.join('latesttag: %s\n' % t for t in ltags) tags += 'latesttagdistance: %s\n' % dist tags += 'changessincelatesttag: %s\n' % changessince return base + tags
def lookup(self, key): self.requirecap('lookup', _('look up remote revision')) d = self._call("lookup", key=encoding.fromlocal(key)) success, data = d[:-1].split(" ", 1) if int(success): return bin(data) self._abort(error.RepoError(data))
def listkeys(self, namespace): if not self.capable('pushkey'): yield {}, None f = future() self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield {'namespace': encoding.fromlocal(namespace)}, f d = f.value yield pushkeymod.decodekeys(d)
def branchmap(repo, proto): branchmap = repo.branchmap() heads = [] for branch, nodes in branchmap.iteritems(): branchname = urllib.quote(encoding.fromlocal(branch)) branchnodes = encodelist(nodes) heads.append('%s %s' % (branchname, branchnodes)) return '\n'.join(heads)
def add(self, manifest, files, desc, transaction, p1, p2, user, date=None, extra=None): # Convert to UTF-8 encoded bytestrings as the very first # thing: calling any method on a localstr object will turn it # into a str object and the cached UTF-8 string is thus lost. user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) user = user.strip() # An empty username or a username with a "\n" will make the # revision text contain two "\n\n" sequences -> corrupt # repository since read cannot unpack the revision. if not user: raise error.RevlogError(_("empty username")) if "\n" in user: raise error.RevlogError( _("username %s contains a newline") % repr(user)) # strip trailing whitespace and leading and trailing empty lines desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') if date: parseddate = "%d %d" % util.parsedate(date) else: parseddate = "%d %d" % util.makedate() if extra: branch = extra.get("branch") if branch in ("default", ""): del extra["branch"] elif branch in (".", "null", "tip"): raise error.RevlogError( _('the name \'%s\' is reserved') % branch) if extra: extra = encodeextra(extra) parseddate = "%s %s" % (parseddate, extra) l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] text = "\n".join(l) return self.addrevision(text, transaction, len(self), p1, p2)
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): yield False, None f = future() yield todict(namespace=encoding.fromlocal(namespace), key=encoding.fromlocal(key), old=encoding.fromlocal(old), new=encoding.fromlocal(new)), f d = f.value d, output = d.split('\n', 1) try: d = bool(int(d)) except ValueError: raise error.ResponseError(_('push failed (unexpected response):'), d) for l in output.splitlines(True): self.ui.status(_('remote: '), l) yield d
def lookup(self, key): self.requirecap('lookup', _('look up remote revision')) f = future() yield todict(key=encoding.fromlocal(key)), f d = f.value success, data = d[:-1].split(" ", 1) if int(success): yield bin(data) self._abort(error.RepoError(data))
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): yield False, None f = future() yield todict(namespace=encoding.fromlocal(namespace), key=encoding.fromlocal(key), old=encoding.fromlocal(old), new=encoding.fromlocal(new)), f d = f.value d, output = d.split('\n', 1) try: d = bool(int(d)) except ValueError: raise error.ResponseError( _('push failed (unexpected response):'), d) for l in output.splitlines(True): self.ui.status(_('remote: '), l) yield d
def setbranch(self, branch): if branch in ['tip', '.', 'null']: raise util.Abort(_('the name \'%s\' is reserved') % branch) self._branch = encoding.fromlocal(branch) f = self._opener('branch', 'w', atomictemp=True) try: f.write(self._branch + '\n') finally: f.close()
def listkeys(self, namespace): if not self.capable('pushkey'): return {} d = self._call("listkeys", namespace=encoding.fromlocal(namespace)) r = {} for l in d.splitlines(): k, v = l.split('\t') r[encoding.tolocal(k)] = encoding.tolocal(v) return r
def listkeys(self, namespace): if not self.capable("pushkey"): yield {}, None f = future() self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield {"namespace": encoding.fromlocal(namespace)}, f d = f.value self.ui.debug('received listkey for "%s": %i bytes\n' % (namespace, len(d))) yield pushkeymod.decodekeys(d)
def lookup(self, key): self.requirecap("lookup", _("look up remote revision")) f = future() yield {"key": encoding.fromlocal(key)}, f d = f.value success, data = d[:-1].split(" ", 1) if int(success): yield bin(data) self._abort(error.RepoError(data))
def pushkey(self, namespace, key, old, new): if not self.capable('pushkey'): yield False, None f = future() self.ui.debug('preparing pushkey for "%s:%s"\n' % (namespace, key)) yield {'namespace': encoding.fromlocal(namespace), 'key': encoding.fromlocal(key), 'old': encoding.fromlocal(old), 'new': encoding.fromlocal(new)}, f d = f.value d, output = d.split('\n', 1) try: d = bool(int(d)) except ValueError: raise error.ResponseError( _('push failed (unexpected response):'), d) for l in output.splitlines(True): self.ui.status(_('remote: '), l) yield d
def pushkey(self, namespace, key, old, new): if not self.capable("pushkey"): yield False, None f = future() self.ui.debug('preparing pushkey for "%s:%s"\n' % (namespace, key)) yield { "namespace": encoding.fromlocal(namespace), "key": encoding.fromlocal(key), "old": encoding.fromlocal(old), "new": encoding.fromlocal(new), }, f d = f.value d, output = d.split("\n", 1) try: d = bool(int(d)) except ValueError: raise error.ResponseError(_("push failed (unexpected response):"), d) for l in output.splitlines(True): self.ui.status(_("remote: "), l) yield d
def listkeys(self, namespace): if not self.capable('pushkey'): yield {}, None f = future() yield todict(namespace=encoding.fromlocal(namespace)), f d = f.value r = {} for l in d.splitlines(): k, v = l.split('\t') r[encoding.tolocal(k)] = encoding.tolocal(v) yield r
def listkeys(self, namespace): if not self.capable('pushkey'): yield {}, None f = future() self.ui.debug('preparing listkeys for "%s"\n' % namespace) yield {'namespace': encoding.fromlocal(namespace)}, f d = f.value r = {} for l in d.splitlines(): k, v = l.split('\t') r[encoding.tolocal(k)] = encoding.tolocal(v) yield r
def metadata(): base = "repo: %s\nnode: %s\nbranch: %s\n" % (repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch())) tags = "".join("tag: %s\n" % t for t in ctx.tags() if repo.tagtype(t) == "global") if not tags: repo.ui.pushbuffer() opts = {"template": "{latesttag}\n{latesttagdistance}", "style": "", "patch": None, "git": None} cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) ltags, dist = repo.ui.popbuffer().split("\n") tags = "".join("latesttag: %s\n" % t for t in ltags.split(":")) tags += "latesttagdistance: %s\n" % dist return base + tags
def write(self, repo): try: f = repo.opener(_filename(repo), "w", atomictemp=True) cachekey = [hex(self.tipnode), str(self.tiprev)] if self.filteredhash is not None: cachekey.append(hex(self.filteredhash)) f.write(" ".join(cachekey) + '\n') for label, nodes in sorted(self.iteritems()): for node in nodes: f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) f.close() except (IOError, OSError, util.Abort): # Abort may be raise by read only opener pass
def makememctx(repo, parents, text, user, date, branch, files, store, editor=None): def getfilectx(repo, memctx, path): data, (islink, isexec), copied = store.getfile(path) return memfilectx(path, data, islink=islink, isexec=isexec, copied=copied) extra = {} if branch: extra['branch'] = encoding.fromlocal(branch) ctx = memctx(repo, parents, text, files, getfilectx, user, date, extra) if editor: ctx._text = editor(repo, ctx, []) return ctx
def add(self, manifest, files, desc, transaction, p1, p2, user, date=None, extra=None): # Convert to UTF-8 encoded bytestrings as the very first # thing: calling any method on a localstr object will turn it # into a str object and the cached UTF-8 string is thus lost. user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) user = user.strip() # An empty username or a username with a "\n" will make the # revision text contain two "\n\n" sequences -> corrupt # repository since read cannot unpack the revision. if not user: raise error.RevlogError(_("empty username")) if "\n" in user: raise error.RevlogError(_("username %s contains a newline") % repr(user)) # strip trailing whitespace and leading and trailing empty lines desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') if date: parseddate = "%d %d" % util.parsedate(date) else: parseddate = "%d %d" % util.makedate() if extra: branch = extra.get("branch") if branch in ("default", ""): del extra["branch"] elif branch in (".", "null", "tip"): raise error.RevlogError(_('the name \'%s\' is reserved') % branch) if extra: extra = encodeextra(extra) parseddate = "%s %s" % (parseddate, extra) l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] text = "\n".join(l) return self.addrevision(text, transaction, len(self), p1, p2)
def setbranch(self, branch): self._branch = encoding.fromlocal(branch) f = self._opener('branch', 'w', atomictemp=True) try: f.write(self._branch + '\n') f.close() # make sure filecache has the correct stat info for _branch after # replacing the underlying file ce = self._filecache['_branch'] if ce: ce.refresh() except: # re-raises f.discard() raise
def metadata(): base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch())) tags = ''.join('tag: %s\n' % t for t in ctx.tags() if repo.tagtype(t) == 'global') if not tags: repo.ui.pushbuffer() opts = {'template': '{latesttag}\n{latesttagdistance}', 'style': '', 'patch': None, 'git': None} cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) ltags, dist = repo.ui.popbuffer().split('\n') tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':')) tags += 'latesttagdistance: %s\n' % dist return base + tags
def write(self, tr=None): """Save branch cache if it is dirty.""" repo = self._repo if self._rbcnamescount < len(self._names): try: if self._rbcnamescount != 0: f = repo.vfs.open(_rbcnames, 'ab') if f.tell() == self._rbcsnameslen: f.write('\0') else: f.close() repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) self._rbcnamescount = 0 self._rbcrevslen = 0 if self._rbcnamescount == 0: f = repo.vfs.open(_rbcnames, 'wb') f.write('\0'.join( encoding.fromlocal(b) for b in self._names[self._rbcnamescount:])) self._rbcsnameslen = f.tell() f.close() except (IOError, OSError, util.Abort) as inst: repo.ui.debug("couldn't write revision branch cache names: " "%s\n" % inst) return self._rbcnamescount = len(self._names) start = self._rbcrevslen * _rbcrecsize if start != len(self._rbcrevs): revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize) try: f = repo.vfs.open(_rbcrevs, 'ab') if f.tell() != start: repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) f.seek(start) f.truncate() end = revs * _rbcrecsize f.write(self._rbcrevs[start:end]) f.close() except (IOError, OSError, util.Abort) as inst: repo.ui.debug("couldn't write revision branch cache: %s\n" % inst) return self._rbcrevslen = revs
def branchmap(self): d = self.do_read("branchmap") try: branchmap = {} for branchpart in d.splitlines(): branchheads = branchpart.split(' ') branchname = urllib.unquote(branchheads[0]) # Earlier servers (1.3.x) send branch names in (their) local # charset. The best we can do is assume it's identical to our # own local charset, in case it's not utf-8. try: branchname.decode('utf-8') except UnicodeDecodeError: branchname = encoding.fromlocal(branchname) branchheads = [bin(x) for x in branchheads[1:]] branchmap[branchname] = branchheads return branchmap except: raise error.ResponseError(_("unexpected response:"), d)
def branchmap(self): d = self._call("branchmap") try: branchmap = {} for branchpart in d.splitlines(): branchname, branchheads = branchpart.split(' ', 1) branchname = urllib.unquote(branchname) # Earlier servers (1.3.x) send branch names in (their) local # charset. The best we can do is assume it's identical to our # own local charset, in case it's not utf-8. try: branchname.decode('utf-8') except UnicodeDecodeError: branchname = encoding.fromlocal(branchname) branchheads = decodelist(branchheads) branchmap[branchname] = branchheads return branchmap except TypeError: self._abort(error.ResponseError(_("unexpected response:"), d))
def branchmap(self): d = self._call("branchmap") try: branchmap = {} for branchpart in d.splitlines(): branchname, branchheads = branchpart.split(" ", 1) branchname = urllib.unquote(branchname) # Earlier servers (1.3.x) send branch names in (their) local # charset. The best we can do is assume it's identical to our # own local charset, in case it's not utf-8. try: branchname.decode("utf-8") except UnicodeDecodeError: branchname = encoding.fromlocal(branchname) branchheads = decodelist(branchheads) branchmap[branchname] = branchheads return branchmap except TypeError: self._abort(error.ResponseError(_("unexpected response:"), d))
def addbranchrevs(lrepo, repo, branches, revs): if not branches: return revs or None, revs and revs[0] or None revs = revs and list(revs) or [] if not repo.capable('branchmap'): revs.extend(branches) return revs, revs[0] branchmap = repo.branchmap() for branch in branches: if branch == '.': if not lrepo or not lrepo.local(): raise util.Abort(_("dirstate branch not accessible")) revs.append(lrepo.dirstate.branch()) else: butf8 = encoding.fromlocal(branch) if butf8 in branchmap: revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) else: revs.append(branch) return revs, revs[0]
def metadata(): base = 'repo: %s\nnode: %s\nbranch: %s\n' % ( repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch())) tags = ''.join('tag: %s\n' % t for t in ctx.tags() if repo.tagtype(t) == 'global') if not tags: repo.ui.pushbuffer() opts = { 'template': '{latesttag}\n{latesttagdistance}', 'style': '', 'patch': None, 'git': None } cmdutil.show_changeset(repo.ui, repo, opts).show(ctx) ltags, dist = repo.ui.popbuffer().split('\n') tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':')) tags += 'latesttagdistance: %s\n' % dist return base + tags
def __init__(self, repo, text="", user=None, date=None, extra=None, changes=None): self._repo = repo self._rev = None self._node = None self._text = text if date: self._date = util.parsedate(date) if user: self._user = user if changes: self._status = list(changes[:4]) self._unknown = changes[4] self._ignored = changes[5] self._clean = changes[6] else: self._unknown = None self._ignored = None self._clean = None self._extra = {} if extra: self._extra = extra.copy() if 'branch' not in self._extra: try: branch = encoding.fromlocal(self._repo.dirstate.branch()) except UnicodeDecodeError: raise util.Abort(_('branch name not in UTF-8!')) self._extra['branch'] = branch if self._extra['branch'] == '': self._extra['branch'] = 'default'
def listkeys(repo, proto, namespace): d = pushkeymod.list(repo, encoding.tolocal(namespace)).items() t = '\n'.join(['%s\t%s' % (encoding.fromlocal(k), encoding.fromlocal(v)) for k, v in d]) return t
def setbranch(self, branch): if branch in ['tip', '.', 'null']: raise util.Abort(_('the name \'%s\' is reserved') % branch) self._branch = encoding.fromlocal(branch) self._opener("branch", "w").write(self._branch + '\n')