def localbranchpath(self, name): if name == 'default': name = '' if name: bdir = self.join('branches') return os.path.join(bdir, store.encodefilename(name)) else: return self.path
def expandpath(path, default=None): ep = oldexpandpath(path, default) if ep != path: return ep bent = store.encodefilename(encoding.fromlocal(path)) if os.path.isdir(os.path.join('.hg', 'branches', bent)): return 'lbranch://%s' % path return ep
def localbranch(self, name): # switch to local branch, creating if necessary def checkdir(d): if not os.path.isdir(d): if os.path.exists(d): raise util.Abort(_('%s is not a directory') % d) return False return True if self.dirstate.parents()[1] != nullid: raise util.Abort(_('merge in progress')) obranch = self.getlocalbranch() lname = encoding.fromlocal(name) if obranch == name: return omf = self.changectx('').manifest() del self.changelog del self.manifest if not name: lbpath = self.join('localbranch') if os.path.exists(lbpath): os.unlink(lbpath) else: bdir = self.join('branches') if not checkdir(bdir): os.mkdir(bdir) dest = os.path.join(bdir, store.encodefilename(lname)) if not checkdir(dest): # check for non-store layout if self.spath == self.path: os.mkdir(dest) datadir = os.path.join(dest, 'data') util.copyfiles(self.join('data'), datadir) for f in ('00changelog.i', '00changelog.d', '00manifest.i', '00manifest.d'): src = self.join(f) if os.path.exists(src): util.copyfiles(src, os.path.join(dest, f)) else: os.mkdir(dest) spath = os.path.join(dest, 'store') util.copyfiles(self.spath, spath) self.opener('localbranch', 'w').write(lname + '\n') self.loadlocalbranch(name) ctx = repo.changectx('tip') wlock = self.wlock() try: self.refreshdirstate(ctx, omf) finally: wlock.release()
def get(filename,encode=False): if encode: filename = store.encodefilename(filename) print filename dir = os.path.join(LOCAL_BASE_DIR,os.path.dirname(filename)) if not os.path.exists(dir): os.makedirs(dir) try: url = "%s/%s" % (URL.geturl(),filename) f = urllib2.urlopen(url) local_file = open(os.path.join(LOCAL_BASE_DIR,filename),"w") local_file.write(f.read()) local_file.close() except urllib2.HTTPError, e: print "HTTP ERROR:",e.code, url
def get(filename, encode=False): if encode: filename = store.encodefilename(filename) print filename dir = os.path.join(LOCAL_BASE_DIR, os.path.dirname(filename)) if not os.path.exists(dir): os.makedirs(dir) try: url = "%s/%s" % (URL.geturl(), filename) f = urllib2.urlopen(url) local_file = open(os.path.join(LOCAL_BASE_DIR, filename), "w") local_file.write(f.read()) local_file.close() except urllib2.HTTPError, e: print "HTTP ERROR:", e.code, url
def _mirrorrepo(ui, repo, url): """Mirror a source repository into the .hg directory of another.""" u = util.url(url) if u.islocal(): raise error.Abort(_('source repo cannot be local')) # Remove scheme from path and normalize reserved characters. path = url.replace('%s://' % u.scheme, '').replace('/', '_') mirrorpath = repo.vfs.join(store.encodefilename(path)) peer = hg.peer(ui, {}, url) mirrorrepo = hg.repository(ui, mirrorpath, create=not os.path.exists(mirrorpath)) missingheads = [head for head in peer.heads() if head not in mirrorrepo] if missingheads: ui.write(_('pulling %s into %s\n' % (url, mirrorpath))) exchange.pull(mirrorrepo, peer) return mirrorrepo
print "HTTP ERROR:",e.code, url except urllib2.URLError, e: print "URL ERROR:",e.reason, url # 1 - Get predictable file names from the repo print "Getting predictable files" for filename in STATIC_FILES: if not os.path.exists(os.path.join(LOCAL_BASE_DIR,filename)): get(filename) else: print "Skipping file as it already exists: %s" % (filename) # If we want a single file. Do that here. This code sucks and should be condensed at some point if args.file: file = args.file filename = os.path.join(".hg/store/data/", store.encodefilename(file)+".i") if not os.path.exists(os.path.join(LOCAL_BASE_DIR,filename)): get(filename) print "Getting %s" % (filename) else: print "Already exists, skipping %s" % (filename) # Ugly but I don't care right now (going for working, not pretty) filename = os.path.join(".hg/store/data/", store.encodefilename(file)+".d") if not os.path.exists(os.path.join(LOCAL_BASE_DIR,filename)): get(filename) print "Getting %s" % (filename) else: print "Already exists, skipping %s" % (filename) # Try and restore the file. Dirty hack but whatever
print "URL ERROR:", e.reason, url # 1 - Get predictable file names from the repo print "Getting predictable files" for filename in STATIC_FILES: if not os.path.exists(os.path.join(LOCAL_BASE_DIR, filename)): get(filename) else: print "Skipping file as it already exists: %s" % (filename) # If we want a single file. Do that here. This code sucks and should be condensed at some point if args.file: file = args.file filename = os.path.join(".hg/store/data/", store.encodefilename(file) + ".i") if not os.path.exists(os.path.join(LOCAL_BASE_DIR, filename)): get(filename) print "Getting %s" % (filename) else: print "Already exists, skipping %s" % (filename) # Ugly but I don't care right now (going for working, not pretty) filename = os.path.join(".hg/store/data/", store.encodefilename(file) + ".d") if not os.path.exists(os.path.join(LOCAL_BASE_DIR, filename)): get(filename) print "Getting %s" % (filename) else: print "Already exists, skipping %s" % (filename)